BeanIO 2.0.4

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

java.lang.Object
  extended by org.beanio.internal.parser.ParsingContext
      extended by org.beanio.internal.parser.UnmarshallingContext
          extended by org.beanio.internal.parser.format.xml.XmlUnmarshallingContext

public class XmlUnmarshallingContext
extends UnmarshallingContext

An UnmarshallingContext for an XML formatted record.

The record value type is a Document.

Since:
2.0
Author:
Kevin Seim

Field Summary
 
Fields inherited from class org.beanio.internal.parser.ParsingContext
MARSHALLING, UNMARSHALLING
 
Constructor Summary
XmlUnmarshallingContext(int groupDepth)
          Constructs a new XmlUnmarshallingContext
 
Method Summary
 Element findElement(XmlNode node)
          Finds a child element of the current position.
 Document getDocument()
          Returns the XML document object model (DOM) for the current record.
 Element getPosition()
          Returns the current unmarshalled position in the DOM tree, or null if a node has not been matched yet.
 Element getPreviousElement()
          Returns the last parsed DOM element for a field or bean collection.
 Iteration popIteration()
          Pops the last Iteration pushed onto the stack.
 void popPosition()
          Updates position to its parent (element), or null if the parent element is the document itself.
 void pushIteration(Iteration b)
          Pushes an Iteration onto a stack for adjusting field positions and indices.
 Element pushPosition(XmlNode node)
          Updates position by finding a child of the current position that matches a given node.
 Element pushPosition(XmlNode node, int depth, boolean isGroup)
          Updates position by finding a child of the current position that matches a given node.
 void setPreviousElement(Element e)
          Sets the last parsed DOM element for a field or bean collection.
 void setRecordValue(Object value)
          Sets the value of the record returned from the RecordReader
 Object toRecordValue(Node node)
          Converts a Node to a record value.
 
Methods inherited from class org.beanio.internal.parser.UnmarshallingContext
addFieldError, addRecordError, addRecordError, getLineNumber, getLocale, getMessageFactory, getMode, getRecordContext, getRecordCount, getRecordReader, hasFieldErrors, hasRecordErrors, isEOF, newMalformedRecordException, newUnsatisfiedGroupException, newUnsatisfiedRecordException, nextRecord, prepare, recordCompleted, recordException, recordSkipped, recordStarted, recordUnexpectedException, recordUnidentifiedException, setFieldText, setLocale, setMessageFactory, setRecordReader, toRecordValue, toRecordValue, validate
 
Methods inherited from class org.beanio.internal.parser.ParsingContext
createHeap, getAdjustedFieldPosition, getLocal, getRelativeFieldIndex, isRepeating, setLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlUnmarshallingContext

public XmlUnmarshallingContext(int groupDepth)
Constructs a new XmlUnmarshallingContext

Parameters:
groupDepth - the maximum depth of an element mapped to a Group in the DOM
Method Detail

setRecordValue

public void setRecordValue(Object value)
Description copied from class: UnmarshallingContext
Sets the value of the record returned from the RecordReader

Specified by:
setRecordValue in class UnmarshallingContext
Parameters:
value - the record value read by a record reader
See Also:
RecordReader

pushIteration

public void pushIteration(Iteration b)
Description copied from class: ParsingContext
Pushes an Iteration onto a stack for adjusting field positions and indices.

Overrides:
pushIteration in class ParsingContext
Parameters:
b - the Iteration to push
See Also:
ParsingContext.popIteration()

popIteration

public Iteration popIteration()
Description copied from class: ParsingContext
Pops the last Iteration pushed onto the stack.

Overrides:
popIteration in class ParsingContext
See Also:
ParsingContext.pushIteration(Iteration)

getPreviousElement

public Element getPreviousElement()
Returns the last parsed DOM element for a field or bean collection.

Returns:
the last parsed element

setPreviousElement

public void setPreviousElement(Element e)
Sets the last parsed DOM element for a field or bean collection.

Parameters:
e - the last parsed element

getDocument

public Document getDocument()
Returns the XML document object model (DOM) for the current record.

Returns:
the XML document object model

getPosition

public Element getPosition()
Returns the current unmarshalled position in the DOM tree, or null if a node has not been matched yet.

Returns:
the current parent DOM node
See Also:
pushPosition(XmlNode, int, boolean), pushPosition(XmlNode)

pushPosition

public Element pushPosition(XmlNode node,
                            int depth,
                            boolean isGroup)
Updates position by finding a child of the current position that matches a given node. If isGroup is true, the node is indexed by its depth so that calls to this method for subsequent records in the same group can update position according to the depth of the record.

Parameters:
node - the XmlNode to match
depth - the depth of the node in the DOM tree
isGroup - whether the node is mapped to a Group
Returns:
the matched node or null if not matched

pushPosition

public Element pushPosition(XmlNode node)
Updates position by finding a child of the current position that matches a given node.

Parameters:
node - the XmlNode to match
Returns:
the matching element, or null if not found
See Also:
getPosition()

popPosition

public void popPosition()
Updates position to its parent (element), or null if the parent element is the document itself.

See Also:
getPosition()

findElement

public Element findElement(XmlNode node)
Finds a child element of the current position.

Parameters:
node - the XmlNodeUtil
Returns:
the matched element or null if not found

toRecordValue

public Object toRecordValue(Node node)
Description copied from class: UnmarshallingContext
Converts a Node to a record value.

Overrides:
toRecordValue in class UnmarshallingContext
Parameters:
node - the Node to convert
Returns:
the record value, or null if not supported

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim