Package org.beanio
Interface Unmarshaller
-
- All Superinterfaces:
Debuggable
- All Known Implementing Classes:
UnmarshallerImpl
public interface Unmarshaller extends Debuggable
Interface for unmarshalling single records.An
Unmarshaller
can be used to unmarshal a bean object bound to arecord
in a mapping file. Unmarshalling bean objects that span multiple records is not supported and will cause aBeanReaderException
.An
Unmarshaller
instance is stateful. If a BeanIO mapping file declares record ordering and expected occurrences, aBeanWriterException
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 anUnmarshaller
is not thread safe and should not be used to unmarshal multiple records concurrently.- Since:
- 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RecordContext
getRecordContext()
Returns record information for the most recent unmarshalled bean object.java.lang.String
getRecordName()
Returns the record or group name of the most recent unmarshalled bean object.java.lang.Object
unmarshal(java.lang.String record)
Unmarshals a bean object from the given record text.java.lang.Object
unmarshal(java.lang.String[] fields)
Unmarshals a bean object from the givenString[]
of fields.java.lang.Object
unmarshal(java.util.List<java.lang.String> fields)
Unmarshals a bean object from the givenList
of fields.java.lang.Object
unmarshal(org.w3c.dom.Node node)
Unmarshals a bean object from the givenNode
.-
Methods inherited from interface org.beanio.internal.util.Debuggable
debug, debug
-
-
-
-
Method Detail
-
unmarshal
java.lang.Object unmarshal(java.lang.String record) throws BeanReaderException, MalformedRecordException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
Unmarshals a bean object from the given record text. This method is supported by all stream formats.- Parameters:
record
- the record text to unmarhal- Returns:
- the unmarshalled bean object
- Throws:
BeanReaderException
- 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 validation
-
unmarshal
java.lang.Object unmarshal(java.util.List<java.lang.String> fields) throws BeanReaderException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
Unmarshals a bean object from the givenList
of fields. This method is supported by CSV and delimited formatted streams only.- Parameters:
fields
- theList
of fields to unmarshal- Returns:
- the unmarshalled bean object
- Throws:
BeanReaderException
- if aList
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 validation
-
unmarshal
java.lang.Object unmarshal(java.lang.String[] fields) throws BeanReaderException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
Unmarshals a bean object from the givenString[]
of fields. This method is supported by CSV and delimited formatted streams only.- Parameters:
fields
- theString[]
of fields to unmarshal- Returns:
- the unmarshalled bean object
- Throws:
BeanReaderException
- if aString[]
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 validation
-
unmarshal
java.lang.Object unmarshal(org.w3c.dom.Node node) throws BeanReaderException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
Unmarshals a bean object from the givenNode
. This method is supported by XML formatted streams only.- Parameters:
node
- theNode
to unmarshal- Returns:
- the unmarshalled bean object
- Throws:
BeanReaderException
- if aNode
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 validation
-
getRecordName
java.lang.String getRecordName()
Returns the record or group name of the most recent unmarshalled bean object.- Returns:
- the record or group name
-
getRecordContext
RecordContext getRecordContext()
Returns record information for the most recent unmarshalled bean object.- Returns:
- the unmarshalled
RecordContext
-
-