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
DefaultMarshallerimplementation.- 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 voiddebug()Prints the internal view of the stream configuration toSystem.outvoiddebug(java.io.PrintStream out)Prints the internal view of the stream configuration.protected java.lang.ObjectgetRecordValue()Returns the record value for the most recent marshalled bean object.Marshallermarshal(java.lang.Object bean)Marshals a single bean object.Marshallermarshal(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[]forcsvanddelimitedformatted streams.org.w3c.dom.DocumenttoDocument()Returns the most recent marshalled bean object as aDocumentforxmlformatted streams.java.util.List<java.lang.String>toList()Returns the most recent marshalled bean object as aListforcsvanddelimitedformatted streams.java.lang.StringtoString()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- theUnmarshallingContextlayout- the stream layoutrecordMarshaller- theRecordMarshallerfor converting record text to record values
-
-
Method Detail
-
marshal
public Marshaller marshal(java.lang.Object bean) throws BeanWriterException
Description copied from interface:MarshallerMarshals a single bean object.- Specified by:
marshalin 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:MarshallerMarshals a single bean object.- Specified by:
marshalin 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:MarshallerReturns the most recent marshalled bean object as aString. This method is supported by all stream formats.- Specified by:
toStringin interfaceMarshaller- Overrides:
toStringin classjava.lang.Object- Returns:
- the record text
-
toArray
public java.lang.String[] toArray() throws BeanWriterExceptionDescription copied from interface:MarshallerReturns the most recent marshalled bean object as aString[]forcsvanddelimitedformatted streams.- Specified by:
toArrayin interfaceMarshaller- Returns:
- the
Stringarray of fields - Throws:
BeanWriterException- if an array is not supported by the stream format
-
toList
public java.util.List<java.lang.String> toList() throws BeanWriterExceptionDescription copied from interface:MarshallerReturns the most recent marshalled bean object as aListforcsvanddelimitedformatted streams.- Specified by:
toListin interfaceMarshaller- Returns:
- the
Listof fields - Throws:
BeanWriterException- if an array is not supported by the stream format
-
toDocument
public org.w3c.dom.Document toDocument() throws BeanWriterExceptionDescription copied from interface:MarshallerReturns the most recent marshalled bean object as aDocumentforxmlformatted streams.- Specified by:
toDocumentin interfaceMarshaller- Returns:
- the
Document - Throws:
BeanWriterException- ifDocumentis 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:DebuggablePrints the internal view of the stream configuration toSystem.out- Specified by:
debugin interfaceDebuggable
-
debug
public void debug(java.io.PrintStream out)
Description copied from interface:DebuggablePrints the internal view of the stream configuration.- Specified by:
debugin interfaceDebuggable- Parameters:
out- thePrintStreamto write to
-
-