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
AMarshallingContextfor XML records.- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description protected org.w3c.dom.Documentdocumentprotected org.w3c.dom.Nodeparent-
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 voidclear()Clear is invoked after each bean object (record or group) is marshalled.voidcloseGroup(XmlNode node)Indicates a group element should be closed before marshalling the next record.org.w3c.dom.DocumentgetDocument()Returns the document being marshalled.org.w3c.dom.NodegetParent()Returns the parent node to append in the document being marshalled.java.lang.ObjectgetRecordObject()Returns the record object to pass to theRecordWriterwhenMarshallingContext.writeRecord()is called.booleanisStreaming()Returns whether a stream is being marshalled, versus a single document.voidopenGroup(XmlNode node)Adds a group to be marshalled when the next record is written to the output stream.voidsetParent(org.w3c.dom.Node parent)Sets the parent node to append in the document being marshalled.voidsetStreaming(boolean streaming)Sets whether a stream is being marshalled, versus a single document.org.w3c.dom.DocumenttoDocument(java.lang.Object record)Converts a record object to aDocument.voidwriteRecord()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:MarshallingContextClear is invoked after each bean object (record or group) is marshalled.- Overrides:
clearin classMarshallingContext
-
getRecordObject
public java.lang.Object getRecordObject()
Description copied from class:MarshallingContextReturns the record object to pass to theRecordWriterwhenMarshallingContext.writeRecord()is called.- Specified by:
getRecordObjectin classMarshallingContext- Returns:
- the record object
-
writeRecord
public void writeRecord() throws java.io.IOExceptionDescription copied from class:MarshallingContextWrites the current record object to the record writer. This method will invoke theMarshallingContext.getRecordObject()method.- Overrides:
writeRecordin 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
Documentbeing 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- theXmlNodeto 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:MarshallingContextConverts a record object to aDocument.- Overrides:
toDocumentin classMarshallingContext- Parameters:
record- the record object to convert- Returns:
- the
Documentresult, 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
-
-