Package com.oss.util

Class ASN1ValueFormat

java.lang.Object
com.oss.util.ASN1ValueFormat

public class ASN1ValueFormat extends Object
This utility class facilitates customization of the formatted string, returned by the toString(ASN1ValueFormat) method of the AbstractData. Setter methods return this object to enable serial application of customizations, such as
 fmt.setTruncationLimit(0).enableMultiline();
    
Since:
ASN.1/Java 6.2
  • Constructor Details

    • ASN1ValueFormat

      public ASN1ValueFormat()
      The default constructor. By default, the following formatting options are implied:
      • the truncation of values is disabled
      • complex values are formatted to multiple lines
      • the width of indentation level is set to 2 positions
      • the left hand of the value assignment is not included
      • the formatting does not stop on errors
      Which is equivalent to
       fmt.setTruncationLimit(0)
          .enableMultiline()
          .excludeValueAssignment()
          .enableDebugging();
              
  • Method Details

    • getTruncationLimit

      public int getTruncationLimit()
      Get current setting of the truncation limit. Zero limit means that the truncation is disabled.
      Returns:
      the setting of the truncation limit.
    • setTruncationLimit

      public ASN1ValueFormat setTruncationLimit(int limit)
      Set the truncation limit. Zero limit means that the lengthy values are never truncated.
      Parameters:
      limit - the value of truncation limit.
      Returns:
      this object.
    • getIndentWidth

      public int getIndentWidth()
      Get current setting of the indent width.
      Returns:
      the setting of the indent width.
    • enableMultiline

      public ASN1ValueFormat enableMultiline(int indentWidth)
      Specify that the value notation for complex values is formatted to multiple lines. For better readability, components nested in the value are printed with default indentation specified by the indentWidth parameter. For example:
       value MyType ::= {
         a "Some string",
         b 100
       }
              
      Parameters:
      indentWidth - the width of one indentation level.
      Returns:
      this object.
    • enableMultiline

      public ASN1ValueFormat enableMultiline()
      Specify that the value notation for complex values is formatted to multiple lines. For better readability, components nested in the value are printed with default indentation by two positions. For example:
       value MyType ::= {
         a "Some string",
         b 100
       }
              
      Returns:
      this object.
    • disableMultiline

      public ASN1ValueFormat disableMultiline()
      Specify that the value notation for complex values is formatted to the single line. For example:
       value MyType ::= { a "Some string", b 100 }
              
      Returns:
      this object.
    • isMultilineEnabled

      public boolean isMultilineEnabled()
      Get current setting of multi-line printing.
      Returns:
      true if complex values are formatted to multiple lines.
    • includeValueAssignment

      public ASN1ValueFormat includeValueAssignment()
      Specify that the value is formatted as an ASN.1 value assignment. The format of an ASN.1 value assignment is the value name followed by the type name and the value notation: name Type ::= valueNotation. For example:
       a A ::= {1 2 3 4 5}
              
      Returns:
      this object.
    • excludeValueAssignment

      public ASN1ValueFormat excludeValueAssignment()
      Specify that the value is formatted as an ASN.1 value notation. In this case the left-hand of the value assignment containing the value name and the type name is omitted. For example:
       {1 2 3 4 5}
              
      Returns:
      this object.
    • isValueAssignmentIncluded

      public boolean isValueAssignmentIncluded()
      Indicates whether the value is formatted as a value assignment.
      Returns:
      true if values are formatted as value assignments.
    • enablePrintingOfImpliedValues

      public ASN1ValueFormat enablePrintingOfImpliedValues()
      Specify that components with DEFAULT values are always present in the output even if the components are absent in the it's parent's value.
      Returns:
      this object.
    • disablePrintingOfImpliedValues

      public ASN1ValueFormat disablePrintingOfImpliedValues()
      Specify that DEFAULT values for absent components are not printed.
      Returns:
      this object.
    • isPrintingOfImpliedValuesEnabled

      public boolean isPrintingOfImpliedValuesEnabled()
      Indicates whether DEFAULT values should be included into the output even if were not explicitly specified.
      Returns:
      true if DEFAULT values should be printed.
    • enableDebugging

      public ASN1ValueFormat enableDebugging()
      Specifies that formatting should continue even if the value contains some errors. Errors are reported in the output as ASN.1 comments. For example:
       MyType a = new MyType(new IA5String(null), 100);
       dataPrinter.enableDebugging();
       dataPrinter.println(a);
      
       The output:
       -----------
       value A ::= {
         a -- java.lang.NullPointerException --,
         b 100
       }
              
      Returns:
      this object.
    • disableDebugging

      public ASN1ValueFormat disableDebugging()
      Specifies that formatting should be aborted if the value contains an error.
      Returns:
      this object.
    • isDebuggingEnabled

      public boolean isDebuggingEnabled()
      Indicates how errors in the value are handled.
      Returns:
      true if formatting will continue after the error in the value is detected.