Package com.oss.util
Class ASN1ValueFormat
java.lang.Object
com.oss.util.ASN1ValueFormat
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionSpecifies that formatting should be aborted if the value contains an error.Specify that the value notation for complex values is formatted to the single line.Specify that DEFAULT values for absent components are not printed.Specifies that formatting should continue even if the value contains some errors.Specify that the value notation for complex values is formatted to multiple lines.enableMultiline
(int indentWidth) Specify that the value notation for complex values is formatted to multiple lines.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.Specify that the value is formatted as an ASN.1 value notation.int
Get current setting of the indent width.int
Get current setting of the truncation limit.Specify that the value is formatted as an ASN.1 value assignment.boolean
Indicates how errors in the value are handled.boolean
Get current setting of multi-line printing.boolean
Indicates whether DEFAULT values should be included into the output even if were not explicitly specified.boolean
Indicates whether the value is formatted as a value assignment.setTruncationLimit
(int limit) Set the truncation limit.
-
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
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
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
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 theindentWidth
parameter. For example:value MyType ::= { a "Some string", b 100 }
- Parameters:
indentWidth
- the width of one indentation level.- Returns:
- this object.
-
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
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
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
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
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
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
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
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.
-