Package org.beanio
Interface Unmarshaller
-
- All Superinterfaces:
Debuggable
- All Known Implementing Classes:
UnmarshallerImpl
public interface Unmarshaller extends Debuggable
Interface for unmarshalling single records.An
Unmarshallercan be used to unmarshal a bean object bound to arecordin a mapping file. Unmarshalling bean objects that span multiple records is not supported and will cause aBeanReaderException.An
Unmarshallerinstance is stateful. If a BeanIO mapping file declares record ordering and expected occurrences, aBeanWriterExceptionmay be thrown for records read out of sequence or that have exceeded their maximum occurrences.There is some performance benefit for reusing the same
Unmarshallerinstance, but anUnmarshalleris 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 RecordContextgetRecordContext()Returns record information for the most recent unmarshalled bean object.java.lang.StringgetRecordName()Returns the record or group name of the most recent unmarshalled bean object.java.lang.Objectunmarshal(java.lang.String record)Unmarshals a bean object from the given record text.java.lang.Objectunmarshal(java.lang.String[] fields)Unmarshals a bean object from the givenString[]of fields.java.lang.Objectunmarshal(java.util.List<java.lang.String> fields)Unmarshals a bean object from the givenListof fields.java.lang.Objectunmarshal(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, InvalidRecordExceptionUnmarshals 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, InvalidRecordExceptionUnmarshals a bean object from the givenListof fields. This method is supported by CSV and delimited formatted streams only.- Parameters:
fields- theListof fields to unmarshal- Returns:
- the unmarshalled bean object
- Throws:
BeanReaderException- if aListis 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, InvalidRecordExceptionUnmarshals 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, InvalidRecordExceptionUnmarshals a bean object from the givenNode. This method is supported by XML formatted streams only.- Parameters:
node- theNodeto unmarshal- Returns:
- the unmarshalled bean object
- Throws:
BeanReaderException- if aNodeis 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
-
-