BeanIO 2.0.4

org.beanio.internal.parser.format.xml
Class XmlMarshallingContext

java.lang.Object
  extended by org.beanio.internal.parser.ParsingContext
      extended by org.beanio.internal.parser.MarshallingContext
          extended by org.beanio.internal.parser.format.xml.XmlMarshallingContext

public class XmlMarshallingContext
extends MarshallingContext

A MarshallingContext for XML records.

Since:
2.0
Author:
Kevin Seim

Field Summary
protected  Document document
           
protected  Node parent
           
 
Fields inherited from class org.beanio.internal.parser.ParsingContext
MARSHALLING, UNMARSHALLING
 
Constructor Summary
XmlMarshallingContext(int groupDepth)
          Constructs a new XmlMarshallingContext.
 
Method Summary
 void clear()
          Clear is invoked after each record is marshalled.
 void closeGroup(XmlNode node)
          Indicates a group element should be closed before marshalling the next record.
 Document getDocument()
          Returns the document being marshalled.
 Node getParent()
          Returns the parent node to append in the document being marshalled.
 Object getRecordObject()
          Returns the record object to pass to the RecordWriter when MarshallingContext.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(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.
 Document toDocument(Object record)
          Converts a record object to a Document.
 void writeRecord()
          Writes the current record object to the record writer.
 
Methods inherited from class org.beanio.internal.parser.MarshallingContext
getBean, getComponentName, getMode, getRecordWriter, setBean, setComponentName, setRecordWriter, toArray, toList
 
Methods inherited from class org.beanio.internal.parser.ParsingContext
createHeap, getAdjustedFieldPosition, getLocal, getRelativeFieldIndex, isRepeating, popIteration, pushIteration, setLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

document

protected Document document

parent

protected Node parent
Constructor Detail

XmlMarshallingContext

public XmlMarshallingContext(int groupDepth)
Constructs a new XmlMarshallingContext.

Parameters:
groupDepth - the maximum depth of a group in the parser tree
Method Detail

clear

public void clear()
Description copied from class: MarshallingContext
Clear is invoked after each record is marshalled.

Overrides:
clear in class MarshallingContext

getRecordObject

public Object getRecordObject()
Description copied from class: MarshallingContext
Returns the record object to pass to the RecordWriter when MarshallingContext.writeRecord() is called.

Specified by:
getRecordObject in class MarshallingContext
Returns:
the record object

writeRecord

public void writeRecord()
                 throws IOException
Description copied from class: MarshallingContext
Writes the current record object to the record writer. This method will invoke the MarshallingContext.getRecordObject() method.

Overrides:
writeRecord in class MarshallingContext
Throws:
IOException - if an I/O error occurs

getDocument

public 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 - the XmlNode to close

getParent

public Node getParent()
Returns the parent node to append in the document being marshalled.

Returns:
the parent Node

setParent

public void setParent(Node parent)
Sets the parent node to append in the document being marshalled.

Parameters:
parent - the parent Node

toDocument

public Document toDocument(Object record)
Description copied from class: MarshallingContext
Converts a record object to a Document.

Overrides:
toDocument in class MarshallingContext
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

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim