public interface Unmarshaller extends Debuggable
An Unmarshaller can be used to unmarshal a bean object bound to
a record in a mapping file. Unmarshalling bean objects that span multiple
records is not supported and will cause a BeanReaderException
.
An Unmarshaller instance is stateful. If a BeanIO mapping file declares
record ordering and expected occurrences, a BeanWriterException
may be thrown for
records read out of sequence or that have exceeded their maximum occurrences.
There is some performance benefit for reusing the same Unmarshaller instance, but an Unmarshaller is not thread safe and should not be used to unmarshal multiple records concurrently.
Modifier and Type | Method and Description |
---|---|
RecordContext |
getRecordContext()
Returns record information for the most recent unmarshalled bean object.
|
String |
getRecordName()
Returns the record or group name of the most recent unmarshalled bean object.
|
Object |
unmarshal(List<String> fields)
Unmarshals a bean object from the given
List of fields. |
Object |
unmarshal(Node node)
Unmarshals a bean object from the given
Node . |
Object |
unmarshal(String record)
Unmarshals a bean object from the given record text.
|
Object |
unmarshal(String[] fields)
Unmarshals a bean object from the given String[] of fields.
|
debug, debug
Object unmarshal(String record) throws BeanReaderException, MalformedRecordException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
record
- the record text to unmarhalBeanReaderException
- if the bean is bound to a record group, or some other
rare (but fatal) error occursMalformedRecordException
- if the record text could not be parsed (due to the
expected syntax of the stream format)UnidentifiedRecordException
- if the record type could not be identifiedUnexpectedRecordException
- if the record is out of sequenceInvalidRecordException
- if the record fails validationObject unmarshal(List<String> fields) throws BeanReaderException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
List
of fields. This method is supported by
CSV and delimited formatted streams only.fields
- the List
of fields to unmarshalBeanReaderException
- if a List
is not supported by the stream format,
or if the bean is bound to a record group, or if some other rare (but fatal) error occursUnidentifiedRecordException
- if the record type could not be identifiedUnexpectedRecordException
- if the record is out of sequenceInvalidRecordException
- if the record fails validationObject unmarshal(String[] fields) throws BeanReaderException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
fields
- the String[] of fields to unmarshalBeanReaderException
- if a String[] is not supported by the stream format,
or if the bean is bound to a record group, or if some other rare (but fatal) error occursUnidentifiedRecordException
- if the record type could not be identifiedUnexpectedRecordException
- if the record is out of sequenceInvalidRecordException
- if the record fails validationObject unmarshal(Node node) throws BeanReaderException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
Node
. This method is supported by
XML formatted streams only.node
- the Node
to unmarshalBeanReaderException
- if a Node
is not supported by the stream format,
or if the bean is bound to a record group, or if some other rare (but fatal) error occursUnidentifiedRecordException
- if the record type could not be identifiedUnexpectedRecordException
- if the record is out of sequenceInvalidRecordException
- if the record fails validationString getRecordName()
RecordContext getRecordContext()
RecordContext