BeanIO 2.0.4

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
Author:
Kevin Seim

Method Summary
 int getFieldCount(String fieldName)
          Returns the number of times the given field was present in the stream.
 Map<String,Collection<String>> getFieldErrors()
          Returns a Map of all field errors.
 Collection<String> getFieldErrors(String fieldName)
          Returns the field errors for a given field.
 String getFieldText(String fieldName)
          Returns the raw text of a field found in this record.
 String getFieldText(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.
 Collection<String> getRecordErrors()
          Returns a collection of record level error messages.
 int getRecordLineNumber()
          Deprecated. use getLineNumber()
 String getRecordName()
          Returns the name of the record from the stream configuration.
 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

int getRecordLineNumber()
Deprecated. use 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

getRecordText

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

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

Collection<String> getRecordErrors()
Returns a collection of record level error messages.

Returns:
the Collection of record level error messages

getFieldCount

int getFieldCount(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

String getFieldText(String fieldName)
Returns the raw text of a field found in this record. Field text may be null under the following circumstances:

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

String getFieldText(String fieldName,
                    int index)
Returns the raw text of a field found in this record. Field text may be null under the following circumstances:

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

Map<String,Collection<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

Collection<String> getFieldErrors(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

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim