public class BeanWriterImpl extends Object implements BeanWriter, StatefulWriter
BeanReader
implementation.Constructor and Description |
---|
BeanWriterImpl(MarshallingContext context,
Selector layout)
Constructs a new BeanWriterImpl.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this output stream.
|
void |
debug()
Prints the internal view of the stream configuration
to
System.out |
void |
debug(PrintStream out)
Prints the internal view of the stream configuration.
|
void |
flush()
Flushes this output stream.
|
void |
restoreState(String namespace,
Map<String,Object> state)
Restores a Map of previously stored state information.
|
void |
updateState(String namespace,
Map<String,Object> state)
Updates a Map with the current state of the Writer to allow for
restoration at a later time.
|
void |
write(Object bean)
Writes a bean object to this output stream.
|
void |
write(String recordName,
Object bean)
Writes a bean object to this output stream.
|
public BeanWriterImpl(MarshallingContext context, Selector layout)
context
- the MarshallingContext
layout
- the root Selector
node in the parsing treepublic void write(Object bean) throws BeanWriterException
BeanWriter
write
in interface BeanWriter
bean
- the bean object to writeBeanWriterException
- if a record could not be identified for marshalling,
or in a few other rare (but fatal) casesBeanWriterIOException
- if the underlying output stream throws an IOException
,
or if this writer is closedpublic void write(String recordName, Object bean) throws BeanWriterException
BeanWriter
write
in interface BeanWriter
recordName
- the record or group name bound to the bean object from the mapping filebean
- the bean object to writeBeanWriterException
- if a record could not be identified for marshalling,
or in a few other rare (but fatal) casesBeanWriterIOException
- if the underlying output stream throws an IOException
,
or if this writer is closedpublic void flush() throws BeanWriterIOException
BeanWriter
flush
in interface BeanWriter
BeanWriterIOException
- if the underlying output stream throws an IOException
,
or if this writer is closedpublic void close() throws BeanWriterIOException
BeanWriter
close
in interface BeanWriter
BeanWriterIOException
- if the underlying output stream throws an IOException
,
or if this writer is already closedpublic void updateState(String namespace, Map<String,Object> state)
StatefulWriter
updateState
in interface StatefulWriter
namespace
- a String to prefix all state keys withstate
- the Map to update with the latest statepublic void restoreState(String namespace, Map<String,Object> state) throws IllegalStateException
StatefulWriter
restoreState
in interface StatefulWriter
namespace
- a String to prefix all state keys withstate
- the Map containing the state to restoreIllegalStateException
- if the Map is missing any state informationpublic void debug()
Debuggable
System.out
debug
in interface Debuggable
public void debug(PrintStream out)
Debuggable
debug
in interface Debuggable
out
- the PrintStream
to write to