Package org.beanio.internal.parser
Class UnmarshallerImpl
- java.lang.Object
-
- org.beanio.internal.parser.UnmarshallerImpl
-
- All Implemented Interfaces:
Debuggable
,Unmarshaller
public class UnmarshallerImpl extends java.lang.Object implements Unmarshaller
DefaultUnmarshaller
implementation.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description UnmarshallerImpl(UnmarshallingContext context, Selector layout, RecordUnmarshaller recordUnmarshaller)
Constructs a newUnmarshallerImpl
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
debug()
Prints the internal view of the stream configuration toSystem.out
void
debug(java.io.PrintStream out)
Prints the internal view of the stream configuration.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 text)
Unmarshals a bean object from the given record text.java.lang.Object
unmarshal(java.lang.String[] array)
Unmarshals a bean object from the givenString[]
of fields.java.lang.Object
unmarshal(java.util.List<java.lang.String> list)
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
.
-
-
-
Constructor Detail
-
UnmarshallerImpl
public UnmarshallerImpl(UnmarshallingContext context, Selector layout, RecordUnmarshaller recordUnmarshaller)
Constructs a newUnmarshallerImpl
- Parameters:
context
- theUnmarshallingContext
layout
- the stream layoutrecordUnmarshaller
- theRecordUnmarshaller
for converting record text to record values
-
-
Method Detail
-
unmarshal
public java.lang.Object unmarshal(java.lang.String text) throws MalformedRecordException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
Description copied from interface:Unmarshaller
Unmarshals a bean object from the given record text. This method is supported by all stream formats.- Specified by:
unmarshal
in interfaceUnmarshaller
- Parameters:
text
- the record text to unmarhal- Returns:
- the unmarshalled bean object
- Throws:
MalformedRecordException
- 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
public java.lang.Object unmarshal(java.util.List<java.lang.String> list) throws BeanReaderException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
Description copied from interface:Unmarshaller
Unmarshals a bean object from the givenList
of fields. This method is supported by CSV and delimited formatted streams only.- Specified by:
unmarshal
in interfaceUnmarshaller
- Parameters:
list
- 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
public java.lang.Object unmarshal(java.lang.String[] array) throws BeanReaderException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
Description copied from interface:Unmarshaller
Unmarshals a bean object from the givenString[]
of fields. This method is supported by CSV and delimited formatted streams only.- Specified by:
unmarshal
in interfaceUnmarshaller
- Parameters:
array
- 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
public java.lang.Object unmarshal(org.w3c.dom.Node node) throws BeanReaderException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
Description copied from interface:Unmarshaller
Unmarshals a bean object from the givenNode
. This method is supported by XML formatted streams only.- Specified by:
unmarshal
in interfaceUnmarshaller
- 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
public java.lang.String getRecordName()
Description copied from interface:Unmarshaller
Returns the record or group name of the most recent unmarshalled bean object.- Specified by:
getRecordName
in interfaceUnmarshaller
- Returns:
- the record or group name
-
getRecordContext
public RecordContext getRecordContext()
Description copied from interface:Unmarshaller
Returns record information for the most recent unmarshalled bean object.- Specified by:
getRecordContext
in interfaceUnmarshaller
- Returns:
- the unmarshalled
RecordContext
-
debug
public void debug()
Description copied from interface:Debuggable
Prints the internal view of the stream configuration toSystem.out
- Specified by:
debug
in interfaceDebuggable
-
debug
public void debug(java.io.PrintStream out)
Description copied from interface:Debuggable
Prints the internal view of the stream configuration.- Specified by:
debug
in interfaceDebuggable
- Parameters:
out
- thePrintStream
to write to
-
-