Class XmlUnmarshallingContext
- java.lang.Object
-
- org.beanio.internal.parser.ParsingContext
-
- org.beanio.internal.parser.UnmarshallingContext
-
- org.beanio.internal.parser.format.xml.XmlUnmarshallingContext
-
public class XmlUnmarshallingContext extends UnmarshallingContext
AnUnmarshallingContext
for an XML formatted record.The record value type is a
Document
.- Since:
- 2.0
-
-
Field Summary
-
Fields inherited from class org.beanio.internal.parser.ParsingContext
MARSHALLING, UNMARSHALLING
-
-
Constructor Summary
Constructors Constructor Description XmlUnmarshallingContext(int groupDepth)
Constructs a newXmlUnmarshallingContext
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.w3c.dom.Element
findElement(XmlNode node)
Finds a child element of the currentposition
.org.w3c.dom.Document
getDocument()
Returns the XML document object model (DOM) for the current record.org.w3c.dom.Element
getPosition()
Returns the current unmarshalled position in the DOM tree, or null if a node has not been matched yet.org.w3c.dom.Element
getPreviousElement()
Returns the last parsed DOM element for a field or bean collection.Iteration
popIteration()
Pops the lastIteration
pushed onto the stack.void
popPosition()
Updatesposition
to its parent (element), or null if the parent element is the document itself.void
pushIteration(Iteration b)
Pushes anIteration
onto a stack for adjusting field positions and indices.org.w3c.dom.Element
pushPosition(XmlNode node)
Updatesposition
by finding a child of the current position that matches a given node.org.w3c.dom.Element
pushPosition(XmlNode node, int depth, boolean isGroup)
Updatesposition
by finding a child of the current position that matches a given node.void
setPreviousElement(org.w3c.dom.Element e)
Sets the last parsed DOM element for a field or bean collection.void
setRecordValue(java.lang.Object value)
Sets the value of the record returned from theRecordReader
java.lang.Object
toRecordValue(org.w3c.dom.Node node)
Converts aNode
to a record value.-
Methods inherited from class org.beanio.internal.parser.UnmarshallingContext
addFieldError, addRecordError, addRecordError, getLineNumber, getLocale, getMessageFactory, getMode, getRecordContext, getRecordCount, getRecordReader, getTextLengthCounter, 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
clear, createHeap, getAdjustedFieldPosition, getLocal, getRelativeFieldIndex, isRepeating, setLocal
-
-
-
-
Constructor Detail
-
XmlUnmarshallingContext
public XmlUnmarshallingContext(int groupDepth)
Constructs a newXmlUnmarshallingContext
- Parameters:
groupDepth
- the maximum depth of an element mapped to aGroup
in the DOM
-
-
Method Detail
-
setRecordValue
public void setRecordValue(java.lang.Object value)
Description copied from class:UnmarshallingContext
Sets the value of the record returned from theRecordReader
- Specified by:
setRecordValue
in classUnmarshallingContext
- 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 anIteration
onto a stack for adjusting field positions and indices.- Overrides:
pushIteration
in classParsingContext
- Parameters:
b
- theIteration
to push- See Also:
ParsingContext.popIteration()
-
popIteration
public Iteration popIteration()
Description copied from class:ParsingContext
Pops the lastIteration
pushed onto the stack.- Overrides:
popIteration
in classParsingContext
- See Also:
ParsingContext.pushIteration(Iteration)
-
getPreviousElement
public org.w3c.dom.Element getPreviousElement()
Returns the last parsed DOM element for a field or bean collection.- Returns:
- the last parsed element
-
setPreviousElement
public void setPreviousElement(org.w3c.dom.Element e)
Sets the last parsed DOM element for a field or bean collection.- Parameters:
e
- the last parsed element
-
getDocument
public org.w3c.dom.Document getDocument()
Returns the XML document object model (DOM) for the current record.- Returns:
- the XML document object model
-
getPosition
public org.w3c.dom.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 org.w3c.dom.Element pushPosition(XmlNode node, int depth, boolean isGroup)
Updatesposition
by finding a child of the current position that matches a given node. IfisGroup
is true, the node is indexed by its depth so that calls to this method for subsequent records in the same group can updateposition
according to the depth of the record.
-
pushPosition
public org.w3c.dom.Element pushPosition(XmlNode node)
Updatesposition
by finding a child of the current position that matches a given node.- Parameters:
node
- theXmlNode
to match- Returns:
- the matching element, or null if not found
- See Also:
getPosition()
-
popPosition
public void popPosition()
Updatesposition
to its parent (element), or null if the parent element is the document itself.- See Also:
getPosition()
-
findElement
public org.w3c.dom.Element findElement(XmlNode node)
Finds a child element of the currentposition
.- Parameters:
node
- theXmlNodeUtil
- Returns:
- the matched element or null if not found
-
toRecordValue
public java.lang.Object toRecordValue(org.w3c.dom.Node node)
Description copied from class:UnmarshallingContext
Converts aNode
to a record value.- Overrides:
toRecordValue
in classUnmarshallingContext
- Parameters:
node
- theNode
to convert- Returns:
- the record value, or null if not supported
-
-