Package org.beanio

Interface RecordContext

  • All Known Implementing Classes:
    ErrorContext

    public interface RecordContext
    Provides information about a record parsed by a BeanReader or Unmarshaller.

    Depending on the current state of the BeanReader or Unmarshaller, some information may not be available.

    Since:
    2.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      int getFieldCount​(java.lang.String fieldName)
      Returns the number of times the given field was present in the stream.
      java.util.Map<java.lang.String,​java.util.Collection<java.lang.String>> getFieldErrors()
      Returns a Map of all field errors.
      java.util.Collection<java.lang.String> getFieldErrors​(java.lang.String fieldName)
      Returns the field errors for a given field.
      java.lang.String getFieldText​(java.lang.String fieldName)
      Returns the raw text of a field found in this record.
      java.lang.String getFieldText​(java.lang.String fieldName, int index)
      Returns the raw text of a field found in this record.
      int getLineNumber()
      Returns the line number of this record, or 0 if the stream does not use new lines to terminate records.
      java.util.Collection<java.lang.String> getRecordErrors()
      Returns a collection of record level error messages.
      int getRecordLineNumber()
      Deprecated.
      java.lang.String getRecordName()
      Returns the name of the record from the stream configuration.
      java.lang.String getRecordText()
      Returns the raw text of the parsed record.
      boolean hasErrors()
      Returns whether this record has any record or field level errors.
      boolean hasFieldErrors()
      Returns whether there are one or more field level errors.
      boolean hasRecordErrors()
      Returns whether there are one or more record level errors.
    • Method Detail

      • getLineNumber

        int getLineNumber()
        Returns the line number of this record, or 0 if the stream does not use new lines to terminate records.
        Returns:
        the line number of this record
      • getRecordLineNumber

        @Deprecated
        int getRecordLineNumber()
        Deprecated.
        Returns the line number of this record, or 0 if the stream does not use new lines to terminate records.
        Returns:
        the line number of this record
      • getRecordText

        java.lang.String getRecordText()
        Returns the raw text of the parsed record. Record text is not supported by XML stream formats, and null is returned instead.
        Returns:
        the raw text of the parser record
      • getRecordName

        java.lang.String getRecordName()
        Returns the name of the record from the stream configuration. The record name may be null if was not determined before an exception was thrown.
        Returns:
        the name of the record from the stream configuration
      • hasErrors

        boolean hasErrors()
        Returns whether this record has any record or field level errors.
        Returns:
        true if this record has any errors, false otherwise
      • hasRecordErrors

        boolean hasRecordErrors()
        Returns whether there are one or more record level errors.
        Returns:
        true if there are one or more record level error, false otherwise
      • getRecordErrors

        java.util.Collection<java.lang.String> getRecordErrors()
        Returns a collection of record level error messages.
        Returns:
        the Collection of record level error messages
      • getFieldCount

        int getFieldCount​(java.lang.String fieldName)
        Returns the number of times the given field was present in the stream.
        Parameters:
        fieldName - the name of the field
        Returns:
        the number of times the field was present in the stream
      • getFieldText

        java.lang.String getFieldText​(java.lang.String fieldName)
        Returns the raw text of a field found in this record. Field text may be null under the following circumstances:
        • A record level exception was thrown before a field was parsed
        • fieldName was not declared in the mapping file
        • The field was not present in the record

        If the field repeats in the stream, this method returns the field text for the first occurrence of the field.

        Parameters:
        fieldName - the name of the field
        Returns:
        the unparsed field text
      • getFieldText

        java.lang.String getFieldText​(java.lang.String fieldName,
                                      int index)
        Returns the raw text of a field found in this record. Field text may be null under the following circumstances:
        • A record level exception was thrown before a field was parsed
        • fieldName was not declared in the mapping file
        • The field was not present in the record
        Parameters:
        fieldName - the name of the field to get the text for
        index - the index of the field (beginning at 0), for repeating fields
        Returns:
        the unparsed field text
      • hasFieldErrors

        boolean hasFieldErrors()
        Returns whether there are one or more field level errors.
        Returns:
        true if there are one or more field level errors, false otherwise
      • getFieldErrors

        java.util.Map<java.lang.String,​java.util.Collection<java.lang.String>> getFieldErrors()
        Returns a Map of all field errors. The name of the field is used for the Map key, and the value is a Collection of field error messages.
        Returns:
        a Map of all field errors
      • getFieldErrors

        java.util.Collection<java.lang.String> getFieldErrors​(java.lang.String fieldName)
        Returns the field errors for a given field.
        Parameters:
        fieldName - the name of the field
        Returns:
        the Collection of field errors, or null if no errors were reported for the field