BeanIO 2.0.4

org.beanio.internal.parser
Class ErrorContext

java.lang.Object
  extended by org.beanio.internal.parser.ErrorContext
All Implemented Interfaces:
Cloneable, RecordContext

public class ErrorContext
extends Object
implements RecordContext, Cloneable

Since:
2.0
Author:
Kevin Seim

Constructor Summary
ErrorContext()
          Constructs a new ErrorContext.
 
Method Summary
 void addFieldError(String fieldName, String message)
          Adds a field error message.
 void addRecordError(String message)
          Adds a record level error message.
 void clear()
          Clears this context;
 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()
          Returns the starting line number of the last record read from the record reader.
 String getRecordName()
          Returns the name of the last record read from the record reader, or null if not known.
 String getRecordText()
          Returns the raw text of the last record read from the record reader.
 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.
 void setFieldText(String fieldName, String text, boolean repeating)
          Sets the raw field text for a named field.
 void setLineNumber(int lineNumber)
          Sets the starting line number of the last record read from the record reader.
 void setRecordName(String recordName)
          Sets the name of the last record read from the record reader.
 void setRecordText(String text)
          Sets the raw text of the last record read from the record reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ErrorContext

public ErrorContext()
Constructs a new ErrorContext.

Method Detail

clear

public void clear()
Clears this context;


getRecordText

public String getRecordText()
Returns the raw text of the last record read from the record reader.

Specified by:
getRecordText in interface RecordContext
Returns:
the raw text of the last record read

setRecordText

public void setRecordText(String text)
Sets the raw text of the last record read from the record reader.

Parameters:
text - the raw text of the last record read

getRecordLineNumber

public int getRecordLineNumber()
Returns the starting line number of the last record read from the record reader.

Specified by:
getRecordLineNumber in interface RecordContext
Returns:
the line number of the last record

setLineNumber

public void setLineNumber(int lineNumber)
Sets the starting line number of the last record read from the record reader.

Parameters:
lineNumber - the line number of the last record

getRecordName

public String getRecordName()
Returns the name of the last record read from the record reader, or null if not known.

Specified by:
getRecordName in interface RecordContext
Returns:
the name of the record

setRecordName

public void setRecordName(String recordName)
Sets the name of the last record read from the record reader.

Parameters:
recordName - the record name

addFieldError

public void addFieldError(String fieldName,
                          String message)
Adds a field error message.

Parameters:
fieldName - the name of the field
message - the error message to add

addRecordError

public void addRecordError(String message)
Adds a record level error message.

Parameters:
message - the error message to add

setFieldText

public void setFieldText(String fieldName,
                         String text,
                         boolean repeating)
Sets the raw field text for a named field.

Parameters:
fieldName - the name of the field
text - the raw field text
repeating - whether the field repeats in the stream

hasErrors

public boolean hasErrors()
Description copied from interface: RecordContext
Returns whether this record has any record or field level errors.

Specified by:
hasErrors in interface RecordContext
Returns:
true if this record has any errors, false otherwise

hasRecordErrors

public boolean hasRecordErrors()
Description copied from interface: RecordContext
Returns whether there are one or more record level errors.

Specified by:
hasRecordErrors in interface RecordContext
Returns:
true if there are one or more record level error, false otherwise

getRecordErrors

public Collection<String> getRecordErrors()
Description copied from interface: RecordContext
Returns a collection of record level error messages.

Specified by:
getRecordErrors in interface RecordContext
Returns:
the Collection of record level error messages

getFieldCount

public int getFieldCount(String fieldName)
Description copied from interface: RecordContext
Returns the number of times the given field was present in the stream.

Specified by:
getFieldCount in interface RecordContext
Parameters:
fieldName - the name of the field
Returns:
the number of times the field was present in the stream

getFieldText

public String getFieldText(String fieldName)
Description copied from interface: RecordContext
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.

Specified by:
getFieldText in interface RecordContext
Parameters:
fieldName - the name of the field
Returns:
the unparsed field text

getFieldText

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

Specified by:
getFieldText in interface RecordContext
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

public boolean hasFieldErrors()
Description copied from interface: RecordContext
Returns whether there are one or more field level errors.

Specified by:
hasFieldErrors in interface RecordContext
Returns:
true if there are one or more field level errors, false otherwise

getFieldErrors

public Map<String,Collection<String>> getFieldErrors()
Description copied from interface: RecordContext
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.

Specified by:
getFieldErrors in interface RecordContext
Returns:
a Map of all field errors

getFieldErrors

public Collection<String> getFieldErrors(String fieldName)
Description copied from interface: RecordContext
Returns the field errors for a given field.

Specified by:
getFieldErrors in interface RecordContext
Parameters:
fieldName - the name of the field
Returns:
the Collection of field errors, or null if no errors were reported for the field

getLineNumber

public int getLineNumber()
Description copied from interface: RecordContext
Returns the line number of this record, or 0 if the stream does not use new lines to terminate records.

Specified by:
getLineNumber in interface RecordContext
Returns:
the line number of this record

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim