public abstract class MarshallingContext extends ParsingContext
Subclasses must implement getRecordObject()
which is invoked
when writeRecord()
is called to write a record object to the
configured RecordWriter
.
MARSHALLING, UNMARSHALLING
Constructor and Description |
---|
MarshallingContext()
Constructs a new MarshallingContext.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear is invoked after each bean object (record or group) is marshalled.
|
Object |
getBean()
Returns the bean object to marshal.
|
String |
getComponentName()
Returns the component name of the record or group to marshal.
|
char |
getMode()
Returns the parsing mode.
|
protected abstract Object |
getRecordObject()
Returns the record object to pass to the
RecordWriter when
writeRecord() is called. |
RecordWriter |
getRecordWriter()
Returns the
RecordWriter to write to. |
void |
setBean(Object bean)
Sets the bean object to marshal.
|
void |
setComponentName(String componentName)
Sets the component name of the record or group to marshal.
|
void |
setRecordWriter(RecordWriter recordWriter)
Set the
RecordWriter to write to. |
String[] |
toArray(Object record)
Converts a record object to a String[].
|
Document |
toDocument(Object record)
Converts a record object to a
Document . |
List<String> |
toList(Object record)
Converts a record object to a
List . |
void |
writeRecord()
Writes the current record object to the record writer.
|
createHeap, getAdjustedFieldPosition, getLocal, getRelativeFieldIndex, isRepeating, popIteration, pushIteration, setLocal
public MarshallingContext()
public final char getMode()
ParsingContext
getMode
in class ParsingContext
ParsingContext.UNMARSHALLING
or ParsingContext.MARSHALLING
public void clear()
clear
in class ParsingContext
public void writeRecord() throws IOException
getRecordObject()
method.IOException
- if an I/O error occursprotected abstract Object getRecordObject()
RecordWriter
when
writeRecord()
is called.public String[] toArray(Object record)
record
- the record object to convertpublic List<String> toList(Object record)
List
.record
- the record object to convertList
result, or null if not supportedpublic Document toDocument(Object record)
Document
.record
- the record object to convertDocument
result, or null if not supportedpublic String getComponentName()
public void setComponentName(String componentName)
componentName
- the component name to marshalpublic Object getBean()
public void setBean(Object bean)
bean
- the bean objectpublic RecordWriter getRecordWriter()
RecordWriter
to write to.RecordWriter
public void setRecordWriter(RecordWriter recordWriter)
RecordWriter
to write to.recordWriter
- the RecordWriter