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
AnUnmarshallingContextfor 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.ElementfindElement(XmlNode node)Finds a child element of the currentposition.org.w3c.dom.DocumentgetDocument()Returns the XML document object model (DOM) for the current record.org.w3c.dom.ElementgetPosition()Returns the current unmarshalled position in the DOM tree, or null if a node has not been matched yet.org.w3c.dom.ElementgetPreviousElement()Returns the last parsed DOM element for a field or bean collection.IterationpopIteration()Pops the lastIterationpushed onto the stack.voidpopPosition()Updatespositionto its parent (element), or null if the parent element is the document itself.voidpushIteration(Iteration b)Pushes anIterationonto a stack for adjusting field positions and indices.org.w3c.dom.ElementpushPosition(XmlNode node)Updatespositionby finding a child of the current position that matches a given node.org.w3c.dom.ElementpushPosition(XmlNode node, int depth, boolean isGroup)Updatespositionby finding a child of the current position that matches a given node.voidsetPreviousElement(org.w3c.dom.Element e)Sets the last parsed DOM element for a field or bean collection.voidsetRecordValue(java.lang.Object value)Sets the value of the record returned from theRecordReaderjava.lang.ObjecttoRecordValue(org.w3c.dom.Node node)Converts aNodeto 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 aGroupin the DOM
-
-
Method Detail
-
setRecordValue
public void setRecordValue(java.lang.Object value)
Description copied from class:UnmarshallingContextSets the value of the record returned from theRecordReader- Specified by:
setRecordValuein classUnmarshallingContext- Parameters:
value- the record value read by a record reader- See Also:
RecordReader
-
pushIteration
public void pushIteration(Iteration b)
Description copied from class:ParsingContextPushes anIterationonto a stack for adjusting field positions and indices.- Overrides:
pushIterationin classParsingContext- Parameters:
b- theIterationto push- See Also:
ParsingContext.popIteration()
-
popIteration
public Iteration popIteration()
Description copied from class:ParsingContextPops the lastIterationpushed onto the stack.- Overrides:
popIterationin 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)
Updatespositionby finding a child of the current position that matches a given node. IfisGroupis true, the node is indexed by its depth so that calls to this method for subsequent records in the same group can updatepositionaccording to the depth of the record.
-
pushPosition
public org.w3c.dom.Element pushPosition(XmlNode node)
Updatespositionby finding a child of the current position that matches a given node.- Parameters:
node- theXmlNodeto match- Returns:
- the matching element, or null if not found
- See Also:
getPosition()
-
popPosition
public void popPosition()
Updatespositionto 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:UnmarshallingContextConverts aNodeto a record value.- Overrides:
toRecordValuein classUnmarshallingContext- Parameters:
node- theNodeto convert- Returns:
- the record value, or null if not supported
-
-