Package com.oss.asn1

Class CSVTool

java.lang.Object
com.oss.asn1.CSVTool

public final class CSVTool extends Object
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
  • Method Details

    • getColumnSeparator

      public String 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

      public void setColumnSeparator(String separator)
      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

      public String 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

      public void setHeaderNameSeparator(String separator)
      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

      public CSVTool.Layout getLayout()
      Returns the layout of the CSV output that is currently selected.
      Returns:
      the layout of the CSV output that is currently selected.
    • setLayout

      public void setLayout(CSVTool.Layout layout)
      Sets the layout of the CSV output.
      Parameters:
      layout - specifies the layout of the CSV output.
    • getHeader

      public CSVTool.Header getHeader()
      Returns the format 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

      public void setHeader(CSVTool.Header header)
      Sets the format 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 is true, the PDU name is added as a prefix to the name of the first column of the CSV header.
    • getBooleanFormat

      public CSVTool.BooleanFormat getBooleanFormat()
      Returns the current setting for the format that is used to represent BOOLEAN 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

      public void setBooleanFormat(CSVTool.BooleanFormat booleanFormat)
      Sets the format that is used to represent BOOLEAN type values in the CSV output.
      Parameters:
      booleanFormat - specifies the format that is used to represent BOOLEAN type values in the CSV output.
    • getEnumFormat

      public CSVTool.EnumFormat getEnumFormat()
      Returns the current setting for the format that is used to represent ENUMERATED 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

      public void setEnumFormat(CSVTool.EnumFormat enumFormat)
      Sets the format that is used to represent ENUMERATED type values in the CSV output.
      Parameters:
      enumFormat - specifies the format that is used to represent ENUMERATED type values in the CSV output.
    • getOctetStringFormat

      public CSVTool.StringFormat getOctetStringFormat()
      Returns the current setting for the format that is used to represent OCTET 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

      public void setOctetStringFormat(CSVTool.StringFormat stringFormat)
      Sets the format that is used to represent OCTET STRING type values in the CSV output.
      Parameters:
      stringFormat - specifies the format that is used to represent OCTET STRING type values in the CSV output.
    • getGeneralizedTimeFormat

      public CSVTool.DateFormat getGeneralizedTimeFormat()
      Returns the current setting for the format that is used to represent GeneralizedTime 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

      public void setGeneralizedTimeFormat(CSVTool.DateFormat dateFormat)
      Specifies the format that is used to represent GeneralizedTime type values in the CSV output.
      Parameters:
      dateFormat - specifies the format that is used to represent GeneralizedTime 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 the OSS.UserClass directive and extend the generated Java class to implement the CustomFormatting interface. Because detection of components that implement custom formatting adds a minor overhead, this setting is disabled by default.
      Parameters:
      enable - when the parameter is true, custom formatting of simple values is enabled in the CSV output.
    • print

      public void print(AbstractData data, PrintWriter out) throws CSVPrintFailedException
      Prints the AbstractData object in CSV format.
      Parameters:
      data - the input AbstractData object.
      out - the PrintWriter 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

      public void setCSVSettings(CSVTool.Settings setting)
      Sets the format of the CSV output using predefined configurations.
      Parameters:
      setting - specifies a predefined set of formatting options.