Package org.jibx.runtime
Interface IUnmarshallingContext
-
- All Known Implementing Classes:
UnmarshallingContext
public interface IUnmarshallingContextUser interface for deserializer from XML. This provides methods used to set up and control the marshalling process, as well as access to the unmarshalling object stack while unmarshalling.- Author:
- Dennis M. Sosnoski
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringgetDocumentName()Return the supplied document name.intgetStackDepth()Get current unmarshalling object stack depth.ObjectgetStackObject(int depth)Get object from unmarshalling stack.ObjectgetStackTop()Get top object on unmarshalling stack.IUnmarshallergetUnmarshaller(String mapname)Find the unmarshaller for a particular class in the current context.ObjectgetUserContext()Get the user context object.booleanisAt(String ns, String name)Check if next tag is start of element.booleanisEnd()Check if next tag is an end tag.booleanisStart()Check if next tag is a start tag.voidpopObject()Pop unmarshalled object from stack.voidpushObject(Object obj)Push created object to unmarshalling stack.voidreset()Reset unmarshalling information.voidsetDocument(InputStream ins, String enc)Set document to be parsed from stream.voidsetDocument(InputStream ins, String name, String enc)Set named document to be parsed from stream.voidsetDocument(Reader rdr)Set document to be parsed from reader.voidsetDocument(Reader rdr, String name)Set named document to be parsed from reader.voidsetUserContext(Object obj)Set a user context object.ObjectunmarshalDocument(InputStream ins, String enc)Unmarshal document from stream to object.ObjectunmarshalDocument(InputStream ins, String name, String enc)Unmarshal named document from stream to object.ObjectunmarshalDocument(Reader rdr)Unmarshal document from reader to object.ObjectunmarshalDocument(Reader rdr, String name)Unmarshal named document from reader to object.ObjectunmarshalElement()Unmarshal the current element.
-
-
-
Method Detail
-
setDocument
void setDocument(InputStream ins, String enc) throws JiBXException
Set document to be parsed from stream.- Parameters:
ins- stream supplying document dataenc- document input encoding, ornullif to be determined by parser- Throws:
JiBXException- if error creating parser
-
setDocument
void setDocument(Reader rdr) throws JiBXException
Set document to be parsed from reader.- Parameters:
rdr- reader supplying document data- Throws:
JiBXException- if error creating parser
-
setDocument
void setDocument(InputStream ins, String name, String enc) throws JiBXException
Set named document to be parsed from stream.- Parameters:
ins- stream supplying document dataname- document nameenc- document input encoding, ornullif to be determined by parser- Throws:
JiBXException- if error creating parser
-
setDocument
void setDocument(Reader rdr, String name) throws JiBXException
Set named document to be parsed from reader.- Parameters:
rdr- reader supplying document dataname- document name- Throws:
JiBXException- if error creating parser
-
reset
void reset()
Reset unmarshalling information. This releases all references to unmarshalled objects and prepares the context for potential reuse. It is automatically called when input is set.
-
unmarshalElement
Object unmarshalElement() throws JiBXException
Unmarshal the current element. If not currently positioned at a start or end tag this first advances the parse to the next start or end tag. There must be an unmarshalling defined for the current element, and this unmarshalling is used to build an object from that element.- Returns:
- unmarshalled object from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
unmarshalDocument
Object unmarshalDocument(InputStream ins, String enc) throws JiBXException
Unmarshal document from stream to object. The effect of this is the same as ifsetDocument(java.io.InputStream, java.lang.String)were called, followed byunmarshalElement()- Parameters:
ins- stream supplying document dataenc- document input encoding, ornullif to be determined by parser- Returns:
- unmarshalled object
- Throws:
JiBXException- if error creating parser
-
unmarshalDocument
Object unmarshalDocument(Reader rdr) throws JiBXException
Unmarshal document from reader to object. The effect of this is the same as ifsetDocument(java.io.InputStream, java.lang.String)were called, followed byunmarshalElement()- Parameters:
rdr- reader supplying document data- Returns:
- unmarshalled object
- Throws:
JiBXException- if error creating parser
-
unmarshalDocument
Object unmarshalDocument(InputStream ins, String name, String enc) throws JiBXException
Unmarshal named document from stream to object. The effect of this is the same as ifsetDocument(java.io.InputStream, java.lang.String)were called, followed byunmarshalElement()- Parameters:
ins- stream supplying document dataname- document nameenc- document input encoding, ornullif to be determined by parser- Returns:
- unmarshalled object
- Throws:
JiBXException- if error creating parser
-
unmarshalDocument
Object unmarshalDocument(Reader rdr, String name) throws JiBXException
Unmarshal named document from reader to object. The effect of this is the same as ifsetDocument(java.io.InputStream, java.lang.String)were called, followed byunmarshalElement()- Parameters:
rdr- reader supplying document dataname- document name- Returns:
- unmarshalled object
- Throws:
JiBXException- if error creating parser
-
getDocumentName
String getDocumentName()
Return the supplied document name.- Returns:
- supplied document name (
nullif none)
-
isAt
boolean isAt(String ns, String name) throws JiBXException
Check if next tag is start of element. If not currently positioned at a start or end tag this first advances the parse to the next start or end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)name- element name expected- Returns:
trueif at start of element with supplied name,falseif not- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
isStart
boolean isStart() throws JiBXExceptionCheck if next tag is a start tag. If not currently positioned at a start or end tag this first advances the parse to the next start or end tag.- Returns:
trueif at start of element,falseif at end- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
isEnd
boolean isEnd() throws JiBXExceptionCheck if next tag is an end tag. If not currently positioned at a start or end tag this first advances the parse to the next start or end tag.- Returns:
trueif at end of element,falseif at start- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
getUnmarshaller
IUnmarshaller getUnmarshaller(String mapname) throws JiBXException
Find the unmarshaller for a particular class in the current context.- Parameters:
mapname- unmarshaller mapping name (generally the class name to be handled, or abstract mapping type name)- Returns:
- unmarshalling handler for class
- Throws:
JiBXException- if unable to create unmarshaller
-
setUserContext
void setUserContext(Object obj)
Set a user context object. This context object is not used directly by JiBX, but can be accessed by all types of user extension methods. The context object is automatically cleared by thereset()method, so to make use of this you need to first call the appropriate version of thesetDocument()method, then this method, and finally theunmarshalElement()method.- Parameters:
obj- user context object, ornullif clearing existing context object- See Also:
getUserContext()
-
getUserContext
Object getUserContext()
Get the user context object.- Returns:
- user context object, or
nullif no context object set - See Also:
setUserContext(Object)
-
pushObject
void pushObject(Object obj)
Push created object to unmarshalling stack. This must be called before beginning the unmarshalling of the object. It is only called for objects with structure, not for those converted directly to and from text.- Parameters:
obj- object being unmarshalled
-
popObject
void popObject() throws JiBXExceptionPop unmarshalled object from stack.- Throws:
JiBXException- if stack empty
-
getStackDepth
int getStackDepth()
Get current unmarshalling object stack depth. This allows tracking nested calls to unmarshal one object while in the process of unmarshalling another object. The bottom item on the stack is always the root object being unmarshalled.- Returns:
- number of objects in unmarshalling stack
-
getStackObject
Object getStackObject(int depth)
Get object from unmarshalling stack. This stack allows tracking nested calls to unmarshal one object while in the process of unmarshalling another object. The bottom item on the stack is always the root object being unmarshalled.- Parameters:
depth- object depth in stack to be retrieved (must be in the range of zero to the current depth minus one).- Returns:
- object from unmarshalling stack
-
getStackTop
Object getStackTop()
Get top object on unmarshalling stack. This is safe to call even when no objects are on the stack.- Returns:
- object from unmarshalling stack, or
nullif none
-
-