Class ContextWrapper<T extends Context>

java.lang.Object
com.univocity.parsers.common.ContextWrapper<T>
All Implemented Interfaces:
Context
Direct Known Subclasses:
ContextSnapshot, ParsingContextWrapper

public abstract class ContextWrapper<T extends Context> extends Object implements Context
A simple a wrapper for a Context.
  • Field Details

    • context

      protected final T extends Context context
  • Constructor Details

    • ContextWrapper

      public ContextWrapper(T context)
      Wraps a Context.
      Parameters:
      context - the context object to be wrapped.
  • Method Details

    • headers

      public String[] headers()
      Description copied from interface: Context
      Returns the file headers that identify each parsed record.
      Specified by:
      headers in interface Context
      Returns:
      the headers used to identify each record parsed from the input.
    • extractedFieldIndexes

      public int[] extractedFieldIndexes()
      Description copied from interface: Context
      Returns the indexes of each field extracted from the input when fields are selected.

      The indexes are relative to their original position in the input.

      For example, if the input has the fields "A, B, C, D", and the selected fields are "A, D", then the extracted field indexes will return [0, 3]

      If no fields were selected, then this method will return null. This means all fields are being parsed.

      Specified by:
      extractedFieldIndexes in interface Context
      Returns:
      The indexes of each selected field; null if no fields were selected.
      See Also:
    • columnsReordered

      public boolean columnsReordered()
      Description copied from interface: Context
      Indicates whether selected fields are being reordered.

      If columns are reordered, each parsed record will contain values only for the selected fields, as specified by Context.extractedFieldIndexes()

      Specified by:
      columnsReordered in interface Context
      Returns:
      true if the parsed records are being reordered by the parser, false otherwise
      See Also:
    • indexOf

      public int indexOf(String header)
      Description copied from interface: Context
      Returns the position of a header (0 based).
      Specified by:
      indexOf in interface Context
      Parameters:
      header - the header whose position will be returned
      Returns:
      the position of the given header, or -1 if it could not be found.
    • indexOf

      public int indexOf(Enum<?> header)
      Description copied from interface: Context
      Returns the position of a header (0 based).
      Specified by:
      indexOf in interface Context
      Parameters:
      header - the header whose position will be returned
      Returns:
      the position of the given header, or -1 if it could not be found.
    • currentColumn

      public int currentColumn()
      Description copied from interface: Context
      Returns the column index of the record being processed.
      Specified by:
      currentColumn in interface Context
      Returns:
      the column index of the record being processed.
    • currentRecord

      public long currentRecord()
      Description copied from interface: Context
      Returns the index of the last valid record parsed from the input
      Specified by:
      currentRecord in interface Context
      Returns:
      the index of the last valid record parsed from the input
    • stop

      public void stop()
      Description copied from interface: Context
      Stops the parsing process. Any open resources in use by the parser are closed automatically unless CommonParserSettings.isAutoClosingEnabled() evaluates to false.
      Specified by:
      stop in interface Context
    • isStopped

      public boolean isStopped()
      Description copied from interface: Context
      Identifies whether the parser is running.
      Specified by:
      isStopped in interface Context
      Returns:
      true if the parser is stopped, false otherwise.
    • selectedHeaders

      public String[] selectedHeaders()
      Description copied from interface: Context
      Returns the sequence of headers that have been selected. If no selection has been made, all available headers will be returned, producing the same output as a call to method Context.headers().
      Specified by:
      selectedHeaders in interface Context
      Returns:
      the sequence of selected headers, or all headers if no selection has been made.
    • errorContentLength

      public int errorContentLength()
      Description copied from interface: Context
      Returns the length limit of parsed contents appearing in exception messages when an error occurs

      If 0, then no exceptions will include the content being manipulated in their attributes, and the "<omitted>" string will appear in error messages as the parsed content.

      defaults to -1 (no limit)

      .
      Specified by:
      errorContentLength in interface Context
      Returns:
      the maximum length of the data content to display in exception messages
    • toRecord

      public Record toRecord(String[] row)
      Description copied from interface: Context
      Converts the given parsed row to a Record
      Specified by:
      toRecord in interface Context
      Parameters:
      row - the row to be converted into a Record
      Returns:
      a Record representing the given row.
    • recordMetaData

      public RecordMetaData recordMetaData()
      Description copied from interface: Context
      Returns the metadata information associated with records produced by the current parsing process.
      Specified by:
      recordMetaData in interface Context
      Returns:
      the record metadata.