|
BeanIO 2.0.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Marshaller
Interface for marshalling bean objects.
A Marshaller can be used to marshal a bean object bound to
a record in a mapping file. Marshalling bean objects that span multiple
records is not supported and will cause a BeanWriterException
.
Depending on the stream format, a bean object can be marshalled to one or more formats. All stream formats support marshalling to a String value, as shown in the following example:
marshaller.marshal(object).toString();
A Marshaller instance is stateful. If a BeanIO mapping file declares
record ordering and expected occurrences, a BeanWriterException
may be thrown for
bean objects written out of sequence or that have exceeded a record's maximum occurrences.
There is some performance benefit for reusing the same Marshaller instance, but a Marshaller is not thread safe and should not be used to concurrently marshal multiple bean objects.
Method Summary | |
---|---|
Marshaller |
marshal(Object bean)
Marshals a single bean object. |
Marshaller |
marshal(String recordName,
Object bean)
Marshals a single bean object. |
String[] |
toArray()
Returns the most recent marshalled bean object as a String[] for csv and delimited formatted streams. |
Document |
toDocument()
Returns the most recent marshalled bean object as a Document for xml
formatted streams. |
List<String> |
toList()
Returns the most recent marshalled bean object as a List for csv
and delimited formatted streams. |
String |
toString()
Returns the most recent marshalled bean object as a String. |
Method Detail |
---|
Marshaller marshal(Object bean) throws BeanWriterException
bean
- the bean object to marshal
BeanWriterException
- if a record is not matched for the given bean object,
or in some other rare (but fatal) conditionsMarshaller marshal(String recordName, Object bean) throws BeanWriterException
recordName
- the name of the record to marshalbean
- the bean object to marshal
BeanWriterException
- if a record is not matched for the given record name
and bean object, or in some other rare (but fatal) conditionsString toString() throws BeanWriterException
toString
in class Object
BeanWriterException
- if a fatal error occursString[] toArray() throws BeanWriterException
BeanWriterException
- if an array is not supported by the stream formatList<String> toList() throws BeanWriterException
List
for csv
and delimited formatted streams.
List
of fields
BeanWriterException
- if an array is not supported by the stream formatDocument toDocument() throws BeanWriterException
Document
for xml
formatted streams.
Document
BeanWriterException
- if Document
is not supported by the stream format
|
BeanIO 2.0.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |