|
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.StreamDefinition
public abstract class StreamDefinition
A StreamDefinition stores all information needed to parse an input stream and format an output stream, and is used to create BeanReader and BeanWriter instances.
Internally, a stream definition is a tree structure with GroupDefinition instances for branches and RecordDefinition instances for leaves.
All classes and subclasses used to define a stream may be shared across multiple threads and must be thread-safe.
Field Summary | |
---|---|
static int |
READ_ONLY_MODE
Stream definition supports reading only |
static int |
READ_WRITE_MODE
Stream definition supports reading and writing |
static int |
WRITE_ONLY_MODE
Stream definition supports writing only |
Constructor Summary | |
---|---|
StreamDefinition(String format)
Creates a new StreamDefinition . |
Method Summary | |
---|---|
BeanReader |
createBeanReader(Reader in,
Locale locale)
Creates a new BeanReader for reading from the given input stream. |
BeanWriter |
createBeanWriter(Writer out)
Creates a new BeanWriter for writing to the given output stream. |
protected abstract RecordReader |
createDefaultReader(Reader in)
Creates a default RecordReader to read from the given input stream. |
protected abstract RecordWriter |
createDefaultWriter(Writer out)
Creates a default RecordWriter for writing to the given output stream. |
protected Record |
createRecord()
Constructs a new Record for this stream to operate on. |
Record |
createRecord(Locale locale)
Constructs a new Record for this stream to operate on. |
RecordReader |
createRecordReader(Reader in)
Creates a new RecordReader to read from the given input stream. |
RecordWriter |
createRecordWriter(Writer out)
Creates a new RecordWriter for writing to the given output stream. |
String |
getFieldErrorMessage(String recordName,
String fieldName,
String rule)
Returns a field level error message. |
String |
getFieldLabel(String recordName,
String fieldName)
Returns the localized label for a field. |
String |
getFormat()
Returns the stream format, one of 'csv', 'delimited' or 'fixedlength'. |
protected String |
getLabel(String key)
Returns a label from the configured resource bundle. |
int |
getMode()
Returns the allowed mode of operation for this stream configuration. |
String |
getName()
Returns the name of this stream context. |
String |
getRecordErrorMessage(String recordName,
String rule)
Returns a record level error message. |
String |
getRecordLabel(String recordName)
Returns the localized label for a record. |
GroupDefinition |
getRootGroupDefinition()
Returns the top level or root group definition for this stream, to which all child records and subgroups were added. |
protected GroupDefinition |
newGroupDefinition()
This method is called to instantiate a new group definition so that subclasses may override the implementation. |
protected GroupNode |
newGroupNode(GroupDefinition definition)
Constructs a new group node for parsing an input stream. |
protected RecordNode |
newRecordNode(RecordDefinition definition)
Constructs a new record node for parsing an input stream. |
void |
setDefaultResourceBundle(ResourceBundle defaultResourceBundle)
Sets the default resource bundle to check of messages not found in the primary resource bundle. |
void |
setMaxOccurs(int maxOccurs)
Sets the maximum number of times the record layout can be read from the input stream. |
void |
setMinOccurs(int minOccurs)
Sets the minimum number of times the record layout must be read from in the input stream. |
void |
setMode(int mode)
Sets the allowed mode of operation for this stream configuration. |
void |
setName(String name)
Sets the name of this stream context. |
void |
setReaderFactory(RecordReaderFactory readerFactory)
Sets the record reader factory to use to create new RecordReader's. |
void |
setResourceBundle(ResourceBundle resourceBundle)
Sets the primary resource bundle to check for messages. |
void |
setWriterFactory(RecordWriterFactory writerFactory)
Sets the record writer factory to use to create new RecordWriter's. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int READ_WRITE_MODE
public static final int READ_ONLY_MODE
public static final int WRITE_ONLY_MODE
Constructor Detail |
---|
public StreamDefinition(String format)
StreamDefinition
.
Method Detail |
---|
protected GroupDefinition newGroupDefinition()
public String getName()
public void setName(String name)
name
- the new name of this stream contextpublic String getFormat()
public int getMode()
READ_WRITE_MODE
if reading and writing from a stream is allowed,READ_ONLY_MODE
if only reading is allowed,WRITE_ONLY_MODE
if only writing is allowedpublic void setMode(int mode)
mode
- READ_WRITE_MODE
if reading and writing from a stream is allowed,READ_ONLY_MODE
if only reading is allowed,WRITE_ONLY_MODE
if only writing is allowedpublic final Record createRecord(Locale locale)
locale
- the locale to use for rendering error messages
protected Record createRecord()
public String getRecordLabel(String recordName)
MessageFactory
getRecordLabel
in interface MessageFactory
recordName
- the name of the record
public String getFieldLabel(String recordName, String fieldName)
MessageFactory
getFieldLabel
in interface MessageFactory
recordName
- the name of the record the field belongs tofieldName
- the name of the field
protected String getLabel(String key)
key
- the resource bundle key
public String getFieldErrorMessage(String recordName, String fieldName, String rule)
MessageFactory
getFieldErrorMessage
in interface MessageFactory
recordName
- the name of the recordfieldName
- the name of the fieldrule
- the name of the validation rule
public String getRecordErrorMessage(String recordName, String rule)
MessageFactory
getRecordErrorMessage
in interface MessageFactory
recordName
- the name of the recordrule
- the name of the validation rule
public RecordReader createRecordReader(Reader in)
createDefaultReader(Reader)
.
in
- the input stream to read from
protected abstract RecordReader createDefaultReader(Reader in)
createRecordReader(Reader)
if no record
reader factory was configured.
in
- the input stream to read from
public RecordWriter createRecordWriter(Writer out)
createDefaultWriter(Writer)
.
out
- the output stream to write to
protected abstract RecordWriter createDefaultWriter(Writer out)
createRecordWriter(Writer)
if no record
writer factory was configured.
out
- the output stream to write to
public void setReaderFactory(RecordReaderFactory readerFactory)
readerFactory
- the new record reader factorypublic void setWriterFactory(RecordWriterFactory writerFactory)
writerFactory
- the new record writer factorpublic void setResourceBundle(ResourceBundle resourceBundle)
resourceBundle
- the resource bundlepublic void setDefaultResourceBundle(ResourceBundle defaultResourceBundle)
defaultResourceBundle
- the default resource bundlepublic final GroupDefinition getRootGroupDefinition()
public void setMinOccurs(int minOccurs)
minOccurs
- the minimum number of times the record layout
must be read from the input streampublic void setMaxOccurs(int maxOccurs)
maxOccurs
- the maximum number of times the record layout can be
read from the input straempublic BeanReader createBeanReader(Reader in, Locale locale)
in
- the input stream to read fromlocale
- the locale to use for rendering error messages
public BeanWriter createBeanWriter(Writer out)
out
- the output stream to write to
protected GroupNode newGroupNode(GroupDefinition definition)
definition
- the group definition
protected RecordNode newRecordNode(RecordDefinition definition)
definition
- the record definition
|
BeanIO 1.2.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |