Package org.beanio.internal.parser
Class MarshallerImpl
- java.lang.Object
-
- org.beanio.internal.parser.MarshallerImpl
-
- All Implemented Interfaces:
Debuggable
,Marshaller
public class MarshallerImpl extends java.lang.Object implements Marshaller
DefaultMarshaller
implementation.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description MarshallerImpl(MarshallingContext context, Selector layout, RecordMarshaller recordMarshaller)
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.protected java.lang.Object
getRecordValue()
Returns the record value for the most recent marshalled bean object.Marshaller
marshal(java.lang.Object bean)
Marshals a single bean object.Marshaller
marshal(java.lang.String recordName, java.lang.Object bean)
Marshals a single bean object.java.lang.String[]
toArray()
Returns the most recent marshalled bean object as aString[]
forcsv
anddelimited
formatted streams.org.w3c.dom.Document
toDocument()
Returns the most recent marshalled bean object as aDocument
forxml
formatted streams.java.util.List<java.lang.String>
toList()
Returns the most recent marshalled bean object as aList
forcsv
anddelimited
formatted streams.java.lang.String
toString()
Returns the most recent marshalled bean object as aString
.
-
-
-
Constructor Detail
-
MarshallerImpl
public MarshallerImpl(MarshallingContext context, Selector layout, RecordMarshaller recordMarshaller)
Constructs a newUnmarshallerImpl
- Parameters:
context
- theUnmarshallingContext
layout
- the stream layoutrecordMarshaller
- theRecordMarshaller
for converting record text to record values
-
-
Method Detail
-
marshal
public Marshaller marshal(java.lang.Object bean) throws BeanWriterException
Description copied from interface:Marshaller
Marshals a single bean object.- Specified by:
marshal
in interfaceMarshaller
- Parameters:
bean
- the bean object to marshal- Returns:
- this
Marshaller
- Throws:
BeanWriterException
- if a record is not matched for the given bean object, or in some other rare (but fatal) conditionsInvalidBeanException
- if BeanIO is configured to validate fields during marshalling, and a field does not meet the configured validation rules
-
marshal
public Marshaller marshal(java.lang.String recordName, java.lang.Object bean) throws BeanWriterException
Description copied from interface:Marshaller
Marshals a single bean object.- Specified by:
marshal
in interfaceMarshaller
- Parameters:
recordName
- the name of the record to marshalbean
- the bean object to marshal- Returns:
- this
Marshaller
- Throws:
BeanWriterException
- if a record is not matched for the given record name and bean object, or in some other rare (but fatal) conditionsInvalidBeanException
- if BeanIO is configured to validate fields during marshalling, and a field does not meet the configured validation rules
-
toString
public java.lang.String toString()
Description copied from interface:Marshaller
Returns the most recent marshalled bean object as aString
. This method is supported by all stream formats.- Specified by:
toString
in interfaceMarshaller
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the record text
-
toArray
public java.lang.String[] toArray() throws BeanWriterException
Description copied from interface:Marshaller
Returns the most recent marshalled bean object as aString[]
forcsv
anddelimited
formatted streams.- Specified by:
toArray
in interfaceMarshaller
- Returns:
- the
String
array of fields - Throws:
BeanWriterException
- if an array is not supported by the stream format
-
toList
public java.util.List<java.lang.String> toList() throws BeanWriterException
Description copied from interface:Marshaller
Returns the most recent marshalled bean object as aList
forcsv
anddelimited
formatted streams.- Specified by:
toList
in interfaceMarshaller
- Returns:
- the
List
of fields - Throws:
BeanWriterException
- if an array is not supported by the stream format
-
toDocument
public org.w3c.dom.Document toDocument() throws BeanWriterException
Description copied from interface:Marshaller
Returns the most recent marshalled bean object as aDocument
forxml
formatted streams.- Specified by:
toDocument
in interfaceMarshaller
- Returns:
- the
Document
- Throws:
BeanWriterException
- ifDocument
is not supported by the stream format
-
getRecordValue
protected java.lang.Object getRecordValue()
Returns the record value for the most recent marshalled bean object.- Returns:
- the record value
-
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
-
-