Package org.beanio.internal.parser
Class BeanWriterImpl
- java.lang.Object
-
- org.beanio.internal.parser.BeanWriterImpl
-
- All Implemented Interfaces:
java.lang.AutoCloseable,BeanWriter,Debuggable,StatefulWriter
public class BeanWriterImpl extends java.lang.Object implements BeanWriter, StatefulWriter
ABeanReaderimplementation.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description BeanWriterImpl(MarshallingContext context, Selector layout)Constructs a newBeanWriterImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this output stream.voiddebug()Prints the internal view of the stream configuration toSystem.outvoiddebug(java.io.PrintStream out)Prints the internal view of the stream configuration.voidflush()Flushes this output stream.voidrestoreState(java.lang.String namespace, java.util.Map<java.lang.String,java.lang.Object> state)Restores a Map of previously stored state information.voidupdateState(java.lang.String namespace, java.util.Map<java.lang.String,java.lang.Object> state)Updates a Map with the current state of the Writer to allow for restoration at a later time.voidwrite(java.lang.Object bean)Writes a bean object to this output stream.voidwrite(java.lang.String recordName, java.lang.Object bean)Writes a bean object to this output stream.
-
-
-
Constructor Detail
-
BeanWriterImpl
public BeanWriterImpl(MarshallingContext context, Selector layout)
Constructs a newBeanWriterImpl.- Parameters:
context- theMarshallingContextlayout- the rootSelectornode in the parsing tree
-
-
Method Detail
-
write
public void write(java.lang.Object bean) throws BeanWriterExceptionDescription copied from interface:BeanWriterWrites a bean object to this output stream.- Specified by:
writein interfaceBeanWriter- Parameters:
bean- the bean object to write- Throws:
BeanWriterException- if a record could not be identified for marshalling, or in a few other rare (but fatal) casesBeanWriterIOException- if the underlying output stream throws anIOException, or if this writer is closedInvalidBeanException- if BeanIO is configured to validate fields during marshalling, and a field does not meet the configured validation rules
-
write
public void write(java.lang.String recordName, java.lang.Object bean) throws BeanWriterExceptionDescription copied from interface:BeanWriterWrites a bean object to this output stream.- Specified by:
writein interfaceBeanWriter- Parameters:
recordName- the record or group name bound to the bean object from the mapping filebean- the bean object to write- Throws:
BeanWriterException- if a record could not be identified for marshalling, or in a few other rare (but fatal) casesBeanWriterIOException- if the underlying output stream throws anIOException, or if this writer is closedInvalidBeanException- if BeanIO is configured to validate fields during marshalling, and a field does not meet the configured validation rules
-
flush
public void flush() throws BeanWriterIOExceptionDescription copied from interface:BeanWriterFlushes this output stream.- Specified by:
flushin interfaceBeanWriter- Throws:
BeanWriterIOException- if the underlying output stream throws anIOException, or if this writer is closed
-
close
public void close() throws BeanWriterIOExceptionDescription copied from interface:BeanWriterCloses this output stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceBeanWriter- Throws:
BeanWriterIOException- if the underlying output stream throws anIOException, or if this writer is already closed
-
updateState
public void updateState(java.lang.String namespace, java.util.Map<java.lang.String,java.lang.Object> state)Description copied from interface:StatefulWriterUpdates a Map with the current state of the Writer to allow for restoration at a later time.- Specified by:
updateStatein interfaceStatefulWriter- Parameters:
namespace- a String to prefix all state keys withstate- the Map to update with the latest state
-
restoreState
public void restoreState(java.lang.String namespace, java.util.Map<java.lang.String,java.lang.Object> state) throws java.lang.IllegalStateExceptionDescription copied from interface:StatefulWriterRestores a Map of previously stored state information.- Specified by:
restoreStatein interfaceStatefulWriter- Parameters:
namespace- a String to prefix all state keys withstate- the Map containing the state to restore- Throws:
java.lang.IllegalStateException- if the Map is missing any state information
-
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
-
-