Package com.oss.asn1
Class CSVTool
java.lang.Object
com.oss.asn1.CSVTool
Implements conversion of an
AbstractData
data object
to CSV format. The class supports the following settings that
can be used to customize the output CSV:
Minimum nesting level of simple values included in the CSV |
To create a partial CSV, select the Minimum nesting level inside a PDU type, used as a starting point for including simple values in the output CSV. |
Maximum nesting level of simple values included in the CSV |
To create a partial CSV, select the maximum nesting level inside a PDU type, starting from which values of simple types should NOT be included in the output CSV. |
Column separator |
A character sequence used to separate column values and column names in the CSV header. |
Header name separator |
A character sequence used to separate the components of the full column name in the CSV header. |
Maximum number of extra CSVs for SET OF/SEQUENCE OF |
Values of SET OF and SEQUENCE OF types with multiple components are mapped into several CSV records where only one component differs and the rest are repeated. This setting can be used to limit the maximum number of components in each SET OF or SEQUENCE OF for which an extra CSV should be created. |
PDU name |
Enable this setting to prefix the first column name of the CSV header with the PDU name. |
Layout |
Selects the layout of the CSV output. |
Header |
Selects the CSV header format in the CSV output. |
BOOLEAN format |
Specifies how BOOLEAN values are presented in the CSV output. |
ENUMERATED format |
Specifies how ENUMERATED values are presented in the CSV output. |
OCTET STRING format |
Specifies how binary data contained in an OCTET STRING
type are presented in the CSV output. |
GeneralizedTime format |
Specifies how GeneralizedTime type values are
presented in the CSV output. |
- Since:
- ASN.1/Java 8.4
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Defines supported formats for displayingBOOLEAN
type values in the CSV output.static enum
Defines supported formats for displayingGeneralizedTime
type values in the CSV output.static enum
Defines supported formats for displayingENUMERATED
type values in the CSV output.static enum
Defines supported formats of the CSV header.static enum
Defines supported layouts of the CSV output.static enum
Predefined CSV configurations.static enum
Defines supported formats for displayingOCTET STRING
type values in the CSV output. -
Method Summary
Modifier and TypeMethodDescriptionvoid
enableCustomFormatting
(boolean enable) Enables or disables custom formatting of simple values in the CSV output.Returns the current setting for the format that is used to representBOOLEAN
type values in the CSV output.Returns a character sequence used to separate column values and column names in the CSV header.Returns the current setting for the format that is used to representENUMERATED
type values in the CSV output.Returns the current setting for the format that is used to representGeneralizedTime
type values in the CSV output.Returns theformat of the CSV header
in the CSV output that is currently selected.Returns a character sequence used to separate components of the full column name in the CSV header.Returns thelayout
of the CSV output that is currently selected.int
Returns the current value of the "Maximum nesting level of simple values included in the CSV" setting.int
Returns the current value of the "Minimum nesting level of simple values included in the CSV" setting.Returns the current setting for the format that is used to representOCTET STRING
type values in the CSV output.int
Returns the current value of the "Maximum number of extra CSVs for SET OF/SEQUENCE OF" setting.boolean
Indicates whether prefixing of the first column name of the CSV header with the PDU name is selected.void
includePDUNameInHeader
(boolean flag) Enables or disables prefixing of the first column name of the CSV header with the PDU name.void
print
(AbstractData data, PrintWriter out) Prints theAbstractData
object in CSV format.void
setBooleanFormat
(CSVTool.BooleanFormat booleanFormat) Sets the format that is used to representBOOLEAN
type values in the CSV output.void
setColumnSeparator
(String separator) Sets a character sequence used to separate column values and column names in the CSV header.void
setCSVSettings
(CSVTool.Settings setting) Sets the format of the CSV output using predefined configurations.void
setEnumFormat
(CSVTool.EnumFormat enumFormat) Sets the format that is used to representENUMERATED
type values in the CSV output.void
setGeneralizedTimeFormat
(CSVTool.DateFormat dateFormat) Specifies the format that is used to representGeneralizedTime
type values in the CSV output.void
setHeader
(CSVTool.Header header) Sets theformat of the CSV header
in the CSV output.void
setHeaderNameSeparator
(String separator) Sets a character sequence used to separate components of a full column name in the CSV header.void
setLayout
(CSVTool.Layout layout) Sets thelayout
of the CSV output.void
setMaximumNestingLevel
(int max) To create a partial CSV, select the maximum nesting level inside a PDU type, starting from which values of simple types should NOT be included in the output CSV.void
setMinimumNestingLevel
(int min) To create a partial CSV, select the minimum nesting level inside a PDU type, used as a starting point for including simple values in the output CSV.void
setOctetStringFormat
(CSVTool.StringFormat stringFormat) Sets the format that is used to representOCTET STRING
type values in the CSV output.void
setSequenceOfTruncationLimit
(int max) This setting can be used to limit the maximum number of components in each SET OF or SEQUENCE OF for which an extra CSV should be created.
-
Method Details
-
getColumnSeparator
Returns a character sequence used to separate column values and column names in the CSV header.- Returns:
- the string used to separate column values and column names in the CSV header.
-
setColumnSeparator
Sets a character sequence used to separate column values and column names in the CSV header.- Parameters:
separator
- the string used to separate column values and column names in the CSV header.
-
getHeaderNameSeparator
Returns a character sequence used to separate components of the full column name in the CSV header.- Returns:
- the character sequence used to separate components of the full column name in the CSV header.
-
setHeaderNameSeparator
Sets a character sequence used to separate components of a full column name in the CSV header.- Parameters:
separator
- the string used to separate components of a full column name in the CSV header.
-
getSequenceOfTruncationLimit
public int getSequenceOfTruncationLimit()Returns the current value of the "Maximum number of extra CSVs for SET OF/SEQUENCE OF" setting.- Returns:
- the current value of the "Maximum number of extra CSVs for SET OF/SEQUENCE OF" setting. A value of 0 means that no limit is imposed.
-
setSequenceOfTruncationLimit
public void setSequenceOfTruncationLimit(int max) This setting can be used to limit the maximum number of components in each SET OF or SEQUENCE OF for which an extra CSV should be created. Values of SET OF and SEQUENCE OF types with multiple components are mapped into several CSV records where only one component differs and the rest are repeated.- Parameters:
max
- specifies the maximum number of components in each SET OF or SEQUENCE OF for which an extra CSV should be created. A value of 0 means that no limit is imposed.
-
getMinimumNestingLevel
public int getMinimumNestingLevel()Returns the current value of the "Minimum nesting level of simple values included in the CSV" setting.- Returns:
- the current value of the "Minimum nesting level of simple values included in the CSV" setting. A value of 0 means that no limit is imposed.
-
setMinimumNestingLevel
public void setMinimumNestingLevel(int min) To create a partial CSV, select the minimum nesting level inside a PDU type, used as a starting point for including simple values in the output CSV.- Parameters:
min
- specifies the minimum nesting level inside a PDU type, used as a starting point for including simple values in the output CSV. A value of 0 means that no limit is imposed.
-
getMaximumNestingLevel
public int getMaximumNestingLevel()Returns the current value of the "Maximum nesting level of simple values included in the CSV" setting.- Returns:
- the current value of the "Maximum nesting level of simple values included in the CSV" setting.
-
setMaximumNestingLevel
public void setMaximumNestingLevel(int max) To create a partial CSV, select the maximum nesting level inside a PDU type, starting from which values of simple types should NOT be included in the output CSV.- Parameters:
max
- specifies the maximum nesting level inside a PDU type, starting from which values of simple types should NOT be included in the output CSV. A value of 0 means that no limit is imposed.
-
getLayout
Returns thelayout
of the CSV output that is currently selected.- Returns:
- the layout of the CSV output that is currently selected.
-
setLayout
Sets thelayout
of the CSV output.- Parameters:
layout
- specifies the layout of the CSV output.
-
getHeader
Returns theformat of the CSV header
in the CSV output that is currently selected.- Returns:
- the format of the CSV header in the CSV output that is currently selected.
-
setHeader
Sets theformat of the CSV header
in the CSV output.- Parameters:
header
- specifies the format of the CSV header in the CSV output.
-
includePDUNameInHeader
public boolean includePDUNameInHeader()Indicates whether prefixing of the first column name of the CSV header with the PDU name is selected.- Returns:
true
when the first column name of the CSV header in the CSV output is prefixed with the PDU name.
-
includePDUNameInHeader
public void includePDUNameInHeader(boolean flag) Enables or disables prefixing of the first column name of the CSV header with the PDU name.- Parameters:
flag
- when the parameter istrue
, the PDU name is added as a prefix to the name of the first column of the CSV header.
-
getBooleanFormat
Returns the current setting for the format that is used to representBOOLEAN
type values in the CSV output.- Returns:
- the current setting of the format that is used to represent
BOOLEAN
type values in the CSV output.
-
setBooleanFormat
Sets the format that is used to representBOOLEAN
type values in the CSV output.- Parameters:
booleanFormat
- specifies the format that is used to representBOOLEAN
type values in the CSV output.
-
getEnumFormat
Returns the current setting for the format that is used to representENUMERATED
type values in the CSV output.- Returns:
- the current setting of the format that is used to represent
ENUMERATED
type values in the CSV output.
-
setEnumFormat
Sets the format that is used to representENUMERATED
type values in the CSV output.- Parameters:
enumFormat
- specifies the format that is used to representENUMERATED
type values in the CSV output.
-
getOctetStringFormat
Returns the current setting for the format that is used to representOCTET STRING
type values in the CSV output.- Returns:
- the current setting of the format that is used to represent
OCTET STRING
type values in the CSV output.
-
setOctetStringFormat
Sets the format that is used to representOCTET STRING
type values in the CSV output.- Parameters:
stringFormat
- specifies the format that is used to representOCTET STRING
type values in the CSV output.
-
getGeneralizedTimeFormat
Returns the current setting for the format that is used to representGeneralizedTime
type values in the CSV output.- Returns:
- the current setting for the format that is used to represent
GeneralizedTime
type values in the CSV output.
-
setGeneralizedTimeFormat
Specifies the format that is used to representGeneralizedTime
type values in the CSV output.- Parameters:
dateFormat
- specifies the format that is used to representGeneralizedTime
type values in the CSV output.
-
enableCustomFormatting
public void enableCustomFormatting(boolean enable) Enables or disables custom formatting of simple values in the CSV output. Particular schemas use binary data (OCTET STRING
) to represent time stamp values, BCD numbers, or IP addresses. You can use customized formatting to display such binary data in human-readable format. To implement custom formatting, use theOSS.UserClass
directive and extend the generated Java class to implement theCustomFormatting
interface. Because detection of components that implement custom formatting adds a minor overhead, this setting is disabled by default.- Parameters:
enable
- when the parameter istrue
, custom formatting of simple values is enabled in the CSV output.
-
print
Prints theAbstractData
object in CSV format.- Parameters:
data
- the inputAbstractData
object.out
- thePrintWriter
where the CSV output is written.- Throws:
CSVPrintFailedException
- Thrown to indicate that the input object contains invalid data and cannot be converted to CSV.
-
setCSVSettings
Sets the format of the CSV output using predefined configurations.- Parameters:
setting
- specifies a predefined set of formatting options.
-