BeanIO 2.0.4

org.beanio
Interface Unmarshaller

All Known Implementing Classes:
UnmarshallerImpl

public interface Unmarshaller

Interface for unmarshalling single records.

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.

Since:
2.0
Author:
Kevin Seim

Method Summary
 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.
 

Method Detail

unmarshal

Object unmarshal(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 occurs
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 identified
UnexpectedRecordException - if the record is out of sequence
InvalidRecordException - if the record fails validation

unmarshal

Object unmarshal(List<String> fields)
                 throws BeanReaderException,
                        UnidentifiedRecordException,
                        UnexpectedRecordException,
                        InvalidRecordException
Unmarshals a bean object from the given List of fields. This method is supported by CSV and delimited formatted streams only.

Parameters:
fields - the List of fields to unmarshal
Returns:
the unmarshalled bean object
Throws:
BeanReaderException - 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 occurs
UnidentifiedRecordException - if the record type could not be identified
UnexpectedRecordException - if the record is out of sequence
InvalidRecordException - if the record fails validation

unmarshal

Object unmarshal(String[] fields)
                 throws BeanReaderException,
                        UnidentifiedRecordException,
                        UnexpectedRecordException,
                        InvalidRecordException
Unmarshals a bean object from the given String[] of fields. This method is supported by CSV and delimited formatted streams only.

Parameters:
fields - the String[] of fields to unmarshal
Returns:
the unmarshalled bean object
Throws:
BeanReaderException - 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 occurs
UnidentifiedRecordException - if the record type could not be identified
UnexpectedRecordException - if the record is out of sequence
InvalidRecordException - if the record fails validation

unmarshal

Object unmarshal(Node node)
                 throws BeanReaderException,
                        UnidentifiedRecordException,
                        UnexpectedRecordException,
                        InvalidRecordException
Unmarshals a bean object from the given Node. This method is supported by XML formatted streams only.

Parameters:
node - the Node to unmarshal
Returns:
the unmarshalled bean object
Throws:
BeanReaderException - 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 occurs
UnidentifiedRecordException - if the record type could not be identified
UnexpectedRecordException - if the record is out of sequence
InvalidRecordException - if the record fails validation

getRecordName

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

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim