Class XmlMarshallingContext
- java.lang.Object
-
- org.beanio.internal.parser.ParsingContext
-
- org.beanio.internal.parser.MarshallingContext
-
- org.beanio.internal.parser.format.xml.XmlMarshallingContext
-
public class XmlMarshallingContext extends MarshallingContext
AMarshallingContext
for XML records.- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description protected org.w3c.dom.Document
document
protected org.w3c.dom.Node
parent
-
Fields inherited from class org.beanio.internal.parser.ParsingContext
MARSHALLING, UNMARSHALLING
-
-
Constructor Summary
Constructors Constructor Description XmlMarshallingContext(int groupDepth)
Constructs a newXmlMarshallingContext
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear is invoked after each bean object (record or group) is marshalled.void
closeGroup(XmlNode node)
Indicates a group element should be closed before marshalling the next record.org.w3c.dom.Document
getDocument()
Returns the document being marshalled.org.w3c.dom.Node
getParent()
Returns the parent node to append in the document being marshalled.java.lang.Object
getRecordObject()
Returns the record object to pass to theRecordWriter
whenMarshallingContext.writeRecord()
is called.boolean
isStreaming()
Returns whether a stream is being marshalled, versus a single document.void
openGroup(XmlNode node)
Adds a group to be marshalled when the next record is written to the output stream.void
setParent(org.w3c.dom.Node parent)
Sets the parent node to append in the document being marshalled.void
setStreaming(boolean streaming)
Sets whether a stream is being marshalled, versus a single document.org.w3c.dom.Document
toDocument(java.lang.Object record)
Converts a record object to aDocument
.void
writeRecord()
Writes the current record object to the record writer.-
Methods inherited from class org.beanio.internal.parser.MarshallingContext
getBean, getComponentName, getMode, getRecordWriter, getTextLengthCounter, setBean, setComponentName, setRecordWriter, toArray, toList
-
Methods inherited from class org.beanio.internal.parser.ParsingContext
createHeap, getAdjustedFieldPosition, getLocal, getRelativeFieldIndex, isRepeating, popIteration, pushIteration, setLocal
-
-
-
-
Method Detail
-
clear
public void clear()
Description copied from class:MarshallingContext
Clear is invoked after each bean object (record or group) is marshalled.- Overrides:
clear
in classMarshallingContext
-
getRecordObject
public java.lang.Object getRecordObject()
Description copied from class:MarshallingContext
Returns the record object to pass to theRecordWriter
whenMarshallingContext.writeRecord()
is called.- Specified by:
getRecordObject
in classMarshallingContext
- Returns:
- the record object
-
writeRecord
public void writeRecord() throws java.io.IOException
Description copied from class:MarshallingContext
Writes the current record object to the record writer. This method will invoke theMarshallingContext.getRecordObject()
method.- Overrides:
writeRecord
in classMarshallingContext
- Throws:
java.io.IOException
- if an I/O error occurs
-
getDocument
public org.w3c.dom.Document getDocument()
Returns the document being marshalled.- Returns:
- the
Document
being marshalled
-
openGroup
public void openGroup(XmlNode node)
Adds a group to be marshalled when the next record is written to the output stream.- Parameters:
node
- the group element to add
-
closeGroup
public void closeGroup(XmlNode node)
Indicates a group element should be closed before marshalling the next record.- Parameters:
node
- theXmlNode
to close
-
getParent
public org.w3c.dom.Node getParent()
Returns the parent node to append in the document being marshalled.- Returns:
- the parent
Node
-
setParent
public void setParent(org.w3c.dom.Node parent)
Sets the parent node to append in the document being marshalled.- Parameters:
parent
- the parentNode
-
toDocument
public org.w3c.dom.Document toDocument(java.lang.Object record)
Description copied from class:MarshallingContext
Converts a record object to aDocument
.- Overrides:
toDocument
in classMarshallingContext
- Parameters:
record
- the record object to convert- Returns:
- the
Document
result, or null if not supported
-
setStreaming
public void setStreaming(boolean streaming)
Sets whether a stream is being marshalled, versus a single document.- Parameters:
streaming
- true if marshalling a stream, false if marshalling single documents
-
isStreaming
public boolean isStreaming()
Returns whether a stream is being marshalled, versus a single document.- Returns:
- true if marshalling a stream, false if marshalling single documents
-
-