|
BeanIO 1.2.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.beanio.parser.Record
public class Record
A Record holds state information about the last record read from an input stream. A single Record instance is used repeatedly while reading the input stream. Before each record is read, clear() is called to clear the state of the last record.
Constructor Summary | |
---|---|
Record()
Constructs a new Record. |
Method Summary | |
---|---|
String |
addFieldError(String fieldName,
String fieldText,
String rule,
Object... params)
Adds a field error to this record. |
protected void |
addFieldErrorMessage(String fieldName,
String message)
Adds a field error message. |
String |
addRecordError(String rule,
Object... params)
Adds a record level error to this record. |
protected void |
addRecordErrorMessage(String message)
Adds a record level error message. |
void |
clear()
Clears the current state of the record before the next record is read. |
BeanReaderContext |
getContext()
Returns the current state of the bean reader stored by this class. |
int |
getFieldOffset()
Returns the index (or offset) of the current collection being parsed. |
List<Integer> |
getFieldOffsets()
Returns the stack of field offsets. |
String |
getFieldText(String fieldName)
Returns the unparsed text of a field from this record (if set). |
String |
getFieldText(String fieldName,
int index)
Returns the unparsed text of a field from this record (if set). |
Locale |
getLocale()
Returns the locale used to format 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 |
hasFieldErrors()
Returns true if a field error was reported while parsing this record. |
boolean |
hasFieldErrors(String fieldName)
Returns true if a field error was reported for a specific field. |
boolean |
hasRecordErrors()
Returns true if a record level error was reported while parsing this record. |
void |
popField()
Pops the last field from the stack. |
void |
pushField()
Pushes a field onto the stack. |
void |
setFieldOffset(int index)
Sets the current index of the collection being parsed, from which all subsequent parsing will be offset. |
void |
setFieldText(String fieldName,
String text)
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 |
setLocale(Locale locale)
Sets the locale used to format error messages. |
void |
setMessageContext(MessageFactory messageContext)
Sets the MessageContext to use to format erorr messages. |
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. |
void |
setValue(Object value)
Sets the value of the record as returned from the RecordReader |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Record()
Method Detail |
---|
public void clear()
public void setValue(Object value)
value
- the record value read by a record readerRecordReader
public BeanReaderContext getContext()
public boolean hasFieldErrors()
public boolean hasFieldErrors(String fieldName)
fieldName
- the name of the field to check
public boolean hasRecordErrors()
public String addFieldError(String fieldName, String fieldText, String rule, Object... params)
fieldName
- the name of the field in errorfieldText
- the invalid field textrule
- the name of the failed validation ruleparams
- an optional list of parameters for formatting the error message
public String addRecordError(String rule, Object... params)
rule
- the name of the failed validation ruleparams
- an optional list of parameters for formatting the error message
protected void addFieldErrorMessage(String fieldName, String message)
fieldName
- the name of the fieldmessage
- the error message to addprotected void addRecordErrorMessage(String message)
message
- the error message to addpublic String getRecordText()
public void setRecordText(String text)
text
- the raw text of the last record readpublic int getRecordLineNumber()
public void setLineNumber(int lineNumber)
lineNumber
- the line number of the last recordpublic String getRecordName()
public void setRecordName(String recordName)
recordName
- public Locale getLocale()
public void setLocale(Locale locale)
locale
- public void setMessageContext(MessageFactory messageContext)
messageContext
- the MessageContext to use to format
erorr messagespublic void setFieldText(String fieldName, String text)
fieldName
- the name of the fieldtext
- the raw field textpublic String getFieldText(String fieldName)
If the field is a collection, this method returns the field text for the first occurrence of the field.
fieldName
- the name of the field to get the text for
setFieldText(String, String)
public String getFieldText(String fieldName, int index)
fieldName
- the name of the field to get the text forindex
- the index of the field, beginning at 0, for collection type
fields
setFieldText(String, String)
public void pushField()
public void setFieldOffset(int index)
index
- the current collection indexpublic int getFieldOffset()
public void popField()
public List<Integer> getFieldOffsets()
public String toString()
toString
in class Object
|
BeanIO 1.2.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |