Package org.jibx.runtime.impl
Class UnmarshallingContext
- java.lang.Object
-
- org.jibx.runtime.impl.UnmarshallingContext
-
- All Implemented Interfaces:
IUnmarshallingContext
public class UnmarshallingContext extends Object implements IUnmarshallingContext
Pull parser wrapper supplying convenience methods for access. Most of these methods are designed for use in code generated by the binding generator.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description protected String[]m_idClassesClass names of referenced types (nullunless class-specific IDs used).protected Map[]m_idMapsID maps for finding references.protected Stringm_idrefLast IDREF value parsed.protected String[]m_namesNames for elements associated with class mappings.protected String[]m_namespacesNamespaces for elements associated with class mappings.protected Object[]m_objectStackStack of objects being unmarshalled.protected intm_stackDepthCurrent unmarshalling stack depth.protected Mapm_transientUnmarshalMapMapping from element name to class index for transient mappings.protected IUnmarshaller[]m_unmarshallersUnmarshallers for classes in mapping definition (lazy create of actual unmarshaller instances)protected Mapm_unmarshalMapMapping from element name to class index for global mappings (cached from binding factory).protected Objectm_userContextUser context object (not used by JiBX, only for user convenience).
-
Constructor Summary
Constructors Constructor Description UnmarshallingContext()Default constructor.UnmarshallingContext(int nmap, String[] umcs, String[] nss, String[] names, String[] idcs, IBindingFactory ifact)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringaccumulateText()Accumulate text content.voidaddUnmarshalling(String mapname, String ns, String name, String cname)Define unmarshalling for element.booleanattributeBoolean(String ns, String name)Get boolean value of attribute from current start tag.booleanattributeBoolean(String ns, String name, boolean dflt)Get boolean value of optional attribute from current start tag.byteattributeByte(String ns, String name)Get byte value of attribute from current start tag.byteattributeByte(String ns, String name, byte dflt)Get byte value of optional attribute from current start tag.charattributeChar(String ns, String name)Get char value of attribute from current start tag.charattributeChar(String ns, String name, char dflt)Get char value of optional attribute from current start tag.DateattributeDate(String ns, String name)Getjava.util.Datevalue of attribute from current start tag.DateattributeDate(String ns, String name, Date dflt)Getjava.util.Datevalue of optional attribute from current start tag.doubleattributeDouble(String ns, String name)Get double value of attribute from current start tag.doubleattributeDouble(String ns, String name, double dflt)Get double value of optional attribute from current start tag.intattributeEnumeration(String ns, String name, String[] enums, int[] vals)Get enumeration attribute value from current start tag.intattributeEnumeration(String ns, String name, String[] enums, int[] vals, int dflt)Get optional enumeration attribute value from current start tag.ObjectattributeExistingIDREF(String ns, String name, int index)Get previously defined object corresponding to IDREF attribute from current start tag.floatattributeFloat(String ns, String name)Get float value of attribute from current start tag.floatattributeFloat(String ns, String name, float dflt)Get float value of optional attribute from current start tag.ObjectattributeForwardIDREF(String ns, String name, int index)Get object (if defined yet) corresponding to IDREF attribute from current start tag.intattributeInt(String ns, String name)Get integer value of attribute from current start tag.intattributeInt(String ns, String name, int dflt)Get integer value of optional attribute from current start tag.longattributeLong(String ns, String name)Get long value of attribute from current start tag.longattributeLong(String ns, String name, long dflt)Get long value of optional attribute from current start tag.shortattributeShort(String ns, String name)Get short value of attribute from current start tag.shortattributeShort(String ns, String name, short dflt)Get short value of optional attribute from current start tag.StringattributeText(String ns, String name)Get text value of attribute from current start tag.StringattributeText(String ns, String name, String dflt)Get text value of optional attribute from current start tag.static StringbuildNameString(String ns, String name)Build name with optional namespace.StringbuildPositionString()Build current parse input position description.voidcheckAllowedAttributes(String[] nss, String[] names)Check that only allowed attributes are present on current start tag.booleanconvertBoolean(String text)Convert boolean value.byteconvertByte(String text)Convert byte value with exception wrapper.charconvertChar(String text)Convert char value with exception wrapper.DateconvertDate(String text)Convertjava.util.Datevalue with exception wrapper.doubleconvertDouble(String text)Convert double value with exception wrapper.intconvertEnum(String target, String[] enums, int[] vals)Find required text value in enumeration.intconvertEnum(String target, String[] enums, int[] vals, int dflt)Find optional text value in enumeration.floatconvertFloat(String text)Convert float value with exception wrapper.longconvertLong(String text)Convert long value with exception wrapper.shortconvertShort(String text)Convert short value with exception wrapper.intcurrentEvent()Get the current parse event type.StringcurrentNameString()Build current element name, with optional namespace.voiddefineID(String id, int index, Object obj)Define object for ID.ObjectfindDefinedID(String id, int index)Find previously defined object corresponding to an ID.ObjectfindID(String id, int index)Find the object corresponding to an ID.intgetActiveNamespaceCount()Get count of active namespaces.StringgetActiveNamespacePrefix(int index)Get prefix for an active namespace.StringgetActiveNamespaceUri(int index)Get URI for an active namespace.intgetAttributeCount()Get number of attributes for current START_ELEMENT event.StringgetAttributeName(int index)Get attribute name for current START_ELEMENT event.StringgetAttributeNamespace(int index)Get attribute namespace for current START_ELEMENT event.StringgetAttributePrefix(int index)Get attribute namespace prefix for current START_ELEMENT event.StringgetAttributeValue(int index)Get attribute value for current START_ELEMENT event.StringgetDocumentName()Return the supplied document name.StringgetElementName()Returns current element name.StringgetElementNamespace()Returns current element namespace URI.IBindingFactorygetFactory()Return the binding factory used to create this unmarshaller.StringgetInputEncoding()Return the input encoding, if known.StringgetName()Get name associated with current parse event.StringgetNamespace()Get namespace associated with current parse event.intgetNamespaceCount()Get number of namespace declarations for current START_ELEMENT event.StringgetNamespacePrefix(int index)Get namespace prefix for namespace declaration on current START_ELEMENT event.StringgetNamespaceUri(int index)Get namespace URI for namespace declaration on current START_ELEMENT event.StringgetNamespaceUri(String prefix)Get namespace URI matching prefix.StringgetPrefix()Get namespace prefix associated with current parse event.intgetStackDepth()Get current unmarshalling object stack depth.ObjectgetStackObject(int depth)Get object from unmarshalling stack.ObjectgetStackTop()Get top object on unmarshalling stack.StringgetText()Get text value for current event.IUnmarshallergetUnmarshaller(String mapname)Find the unmarshaller for a particular class in the current context.IUnmarshallergetUnmarshaller(String ns, String name)Find the unmarshaller for a particular element name (including namespace) in the current context.ObjectgetUserContext()Get the user context object.booleanhasAnyAttribute(String[] nss, String[] names)Check if any of several attributes is present on current start tag.booleanhasAttribute(String ns, String name)Check if attribute is present on current start tag.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.protected voidmapUnmarshalling(int index)Map unmarshalling for element.intnext()Advance to next major parse event.intnextToken()Advance to next parse event.byteparseContentByte(String ns, String tag)Parse past end of element, returning byte value of content.charparseContentChar(String ns, String tag)Parse past end of element, returning char value of content.intparseContentEnumeration(String ns, String tag, String[] enums, int[] vals)Parse past end of element, returning enumeration value of content.intparseContentInt(String ns, String tag)Parse past end of element, returning integer value of content.shortparseContentShort(String ns, String tag)Parse past end of element, returning short value of content.StringparseContentText()Parse required text content.StringparseContentText(String ns, String tag)Parse past end of element, returning optional text content.booleanparseElementBoolean(String ns, String tag)Parse entire element, returning boolean value of content.booleanparseElementBoolean(String ns, String tag, boolean dflt)Parse entire element, returning boolean value of optional content.byteparseElementByte(String ns, String tag)Parse entire element, returning byte value of content.byteparseElementByte(String ns, String tag, byte dflt)Parse entire element, returning byte value of optional content.charparseElementChar(String ns, String tag)Parse entire element, returning char value of content.charparseElementChar(String ns, String tag, char dflt)Parse entire element, returning char value of optional content.DateparseElementDate(String ns, String tag)Parse past end of element, returningjava.util.Datevalue of content.DateparseElementDate(String ns, String tag, Date dflt)Parse entire element, returningjava.util.Datevalue of optional content.doubleparseElementDouble(String ns, String tag)Parse past end of element, returning double value of content.doubleparseElementDouble(String ns, String tag, double dflt)Parse entire element, returning double value of optional content.intparseElementEnumeration(String ns, String tag, String[] enums, int[] vals, int dflt)Parse entire element, returning enumeration value of optional content.ObjectparseElementExistingIDREF(String ns, String tag, int index)Parse entire element, returning previously defined object corresponding to content interpreted as IDREF.floatparseElementFloat(String ns, String tag)Parse past end of element, returning float value of content.floatparseElementFloat(String ns, String tag, float dflt)Parse entire element, returning float value of optional content.ObjectparseElementForwardIDREF(String ns, String tag, int index)Parse entire element, returning object (if defined yet) corresponding to content interpreted as IDREF.intparseElementInt(String ns, String tag)Parse entire element, returning integer value of content.intparseElementInt(String ns, String tag, int dflt)Parse entire optional element, returning integer value of content.longparseElementLong(String ns, String tag)Parse past end of element, returning long value of content.longparseElementLong(String ns, String tag, long dflt)Parse entire element, returning long value of optional content.shortparseElementShort(String ns, String tag)Parse entire element, returning short value of content.shortparseElementShort(String ns, String tag, short dflt)Parse entire element, returning short value of optional content.StringparseElementText(String ns, String tag)Parse entire element, returning text content.StringparseElementText(String ns, String tag, String dflt)Parse entire element, returning optional text content.booleanparseIfStartTag(String ns, String name)Parse past start of expected element.voidparsePastCurrentEndTag(String ns, String name)Parse past current end of element.voidparsePastElement(String ns, String tag)Parse past element, ignoring all content.voidparsePastEndTag(String ns, String name)Parse past end of element.voidparsePastStartTag(String ns, String name)Parse past start of element.voidparseToStartTag(String ns, String name)Parse to start of element.voidpopObject()Pop unmarshalled object from stack.voidpushObject(Object obj)Push created object to unmarshalling stack.voidpushTrackedObject(Object obj)Push created object to unmarshalling stack with position tracking.voidregisterBackFill(int index, BackFillReference fill)Register back fill item for last parsed ID value.voidregisterBackFill(String id, int index, BackFillReference fill)Register back fill item for undefined ID value.voidremoveUnmarshalling(String mapname)Undefine unmarshalling for element.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(InputStream ins, String name, String enc, boolean nsa)Set 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.voidsetDocument(Reader rdr, String name, boolean nsa)Set document to be parsed from reader.voidsetDocument(IXMLReader rdr)Set input document parse source directly.voidsetFromContext(UnmarshallingContext parent)Initializes the context to use the same parser and document as another unmarshalling context.voidsetUserContext(Object obj)Set a user context object.voidskipElement()Skip past current element.voidthrowEndTagNameError(String ns, String name)Throw exception for expected element end tag not found.voidthrowException(String msg)Throw exception with position information.voidthrowException(String msg, Exception ex)Throw exception with position information and nested exception.voidthrowNameException(String msg, String ns, String name)Throw exception including a name and position information.voidthrowStartTagException(String msg)Throw exception with start tag and position information.voidthrowStartTagException(String msg, Exception ex)Throw exception with start tag, position information, and nested exception.voidthrowStartTagNameError(String ns, String name)Throw exception for expected element start tag not found.StringtoEnd()Parse to end tag.StringtoStart()Parse to start tag.inttoTag()Parse to start or end tag.voidtrackObject(Object obj)Set position tracking information for object, if supported.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 required element.ObjectunmarshalElement(Class clas)Unmarshal required element of specified type.ObjectunmarshalOptionalElement()Unmarshal optional element.
-
-
-
Field Detail
-
m_unmarshallers
protected IUnmarshaller[] m_unmarshallers
Unmarshallers for classes in mapping definition (lazy create of actual unmarshaller instances)
-
m_namespaces
protected String[] m_namespaces
Namespaces for elements associated with class mappings.
-
m_names
protected String[] m_names
Names for elements associated with class mappings.
-
m_idMaps
protected Map[] m_idMaps
ID maps for finding references.
-
m_idClasses
protected String[] m_idClasses
Class names of referenced types (nullunless class-specific IDs used).
-
m_stackDepth
protected int m_stackDepth
Current unmarshalling stack depth.
-
m_objectStack
protected Object[] m_objectStack
Stack of objects being unmarshalled.
-
m_unmarshalMap
protected Map m_unmarshalMap
Mapping from element name to class index for global mappings (cached from binding factory). Entries areIntegervalues if single match,int[]if multiple matches, giving the mapping index.
-
m_transientUnmarshalMap
protected Map m_transientUnmarshalMap
Mapping from element name to class index for transient mappings. Entries areIntegervalues if single match,ArrayListif multiple matches, giving the mapping index.
-
m_idref
protected String m_idref
Last IDREF value parsed.
-
m_userContext
protected Object m_userContext
User context object (not used by JiBX, only for user convenience).
-
-
Constructor Detail
-
UnmarshallingContext
public UnmarshallingContext(int nmap, String[] umcs, String[] nss, String[] names, String[] idcs, IBindingFactory ifact)Constructor. Builds the actual parser and initializes internal data structures.- Parameters:
nmap- number of mapping definitions includedumcs- names of unmarshaller classes for indexes with fixed unmarshallers (as opposed to mapping slots, which may be overridden; reference kept, must be constant)nss- namespaces for elements of classes with global definitionsnames- names for elements of classes with global definitionsidcs- array of class names with IDs (nullif no IDs or global IDs)ifact- binding factory creating this unmarshaller
-
UnmarshallingContext
public UnmarshallingContext()
Default constructor. This can be used for creating a context outside of the generated code for special purposes.
-
-
Method Detail
-
buildNameString
public static String buildNameString(String ns, String name)
Build name with optional namespace. Just returns the appropriate name format.- Parameters:
ns- namespace URI of namename- local name part of name- Returns:
- formatted name string
-
currentNameString
public String currentNameString()
Build current element name, with optional namespace.- Returns:
- formatted name string
-
buildPositionString
public String buildPositionString()
Build current parse input position description.- Returns:
- text description of current parse position
-
throwStartTagNameError
public void throwStartTagNameError(String ns, String name) throws JiBXException
Throw exception for expected element start tag not found.- Parameters:
ns- namespace URI of namename- local name part of name- Throws:
JiBXException- always thrown
-
throwEndTagNameError
public void throwEndTagNameError(String ns, String name) throws JiBXException
Throw exception for expected element end tag not found.- Parameters:
ns- namespace URI of namename- local name part of name- Throws:
JiBXException- always thrown
-
throwNameException
public void throwNameException(String msg, String ns, String name) throws JiBXException
Throw exception including a name and position information.- Parameters:
msg- leading message textns- namespace URI of namename- local name part of name- Throws:
JiBXException- always thrown
-
setDocument
public void setDocument(InputStream ins, String name, String enc, boolean nsa) throws JiBXException
Set document to be parsed from stream. This call is not part of the interface definition, but is supplied to allow direct control of the namespace processing by the compiler. The option of disabling namespaces should be considered experimental and may not be supported in the future.- Parameters:
ins- stream supplying document dataname- document name (nullif unknown)enc- document input encoding, ornullif to be determined by parsernsa- enable namespace processing for parser flag- Throws:
JiBXException- if error creating parser
-
setDocument
public void setDocument(InputStream ins, String enc) throws JiBXException
Set document to be parsed from stream.- Specified by:
setDocumentin interfaceIUnmarshallingContext- Parameters:
ins- stream supplying document dataenc- document input encoding, ornullif to be determined by parser- Throws:
JiBXException- if error creating parser
-
setDocument
public void setDocument(Reader rdr, String name, boolean nsa) throws JiBXException
Set document to be parsed from reader. This call is not part of the interface definition, but is supplied to allow direct control of the namespace processing by the compiler. The option of disabling namespaces should be considered experimental and may not be supported in the future.- Parameters:
rdr- reader supplying document dataname- document name (nullif unknown)nsa- enable namespace processing for parser flag- Throws:
JiBXException- if error creating parser
-
setDocument
public void setDocument(Reader rdr) throws JiBXException
Set document to be parsed from reader.- Specified by:
setDocumentin interfaceIUnmarshallingContext- Parameters:
rdr- reader supplying document data- Throws:
JiBXException- if error creating parser
-
setDocument
public void setDocument(InputStream ins, String name, String enc) throws JiBXException
Set named document to be parsed from stream.- Specified by:
setDocumentin interfaceIUnmarshallingContext- Parameters:
ins- stream supplying document dataname- document nameenc- document input encoding, ornullif to be determined by parser- Throws:
JiBXException- if error creating parser
-
setDocument
public void setDocument(Reader rdr, String name) throws JiBXException
Set named document to be parsed from reader.- Specified by:
setDocumentin interfaceIUnmarshallingContext- Parameters:
rdr- reader supplying document dataname- document name- Throws:
JiBXException- if error creating parser
-
setDocument
public void setDocument(IXMLReader rdr)
Set input document parse source directly.- Parameters:
rdr- document parse event reader
-
setFromContext
public void setFromContext(UnmarshallingContext parent)
Initializes the context to use the same parser and document as another unmarshalling context. This method is designed for use when an initial context needs to create and invoke a secondary context in the course of an unmarshalling operation.- Parameters:
parent- context supplying parser and document to be unmarshalled
-
reset
public 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.- Specified by:
resetin interfaceIUnmarshallingContext
-
toStart
public String toStart() throws JiBXException
Parse to start tag. Ignores character data seen prior to a start tag, but throws exception if an end tag or the end of the document is seen before a start tag. Leaves the parser positioned at the start tag.- Returns:
- element name of start tag found
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
toEnd
public String toEnd() throws JiBXException
Parse to end tag. Ignores character data seen prior to an end tag, but throws exception if a start tag or the end of the document is seen before an end tag. Leaves the parser positioned at the end tag.- Returns:
- element name of end tag found
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
toTag
public int toTag() throws JiBXExceptionParse to start or 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:
- parser event type for start tag or end tag
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
isAt
public 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.- Specified by:
isAtin interfaceIUnmarshallingContext- 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)
-
hasAttribute
public boolean hasAttribute(String ns, String name) throws JiBXException
Check if attribute is present on current start tag. Throws an exception if not currently positioned on a start tag.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
trueif named attribute is present,falseif not- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
hasAnyAttribute
public boolean hasAnyAttribute(String[] nss, String[] names) throws JiBXException
Check if any of several attributes is present on current start tag. Throws an exception if not currently positioned on a start tag.- Parameters:
nss- namespace URIs for expected attributes (each may benullor the empty string for the empty namespace)names- attribute names expected- Returns:
trueif at least one of the named attributes is present,falseif not- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
checkAllowedAttributes
public void checkAllowedAttributes(String[] nss, String[] names) throws JiBXException
Check that only allowed attributes are present on current start tag. Throws an exception if not currently positioned on a start tag, or if an attribute is present which is not in the list.- Parameters:
nss- namespace URIs for allowed attributes (each may benullor the empty string for the empty namespace)names- alphabetical list of attribute names expected (duplicates names are ordered by namespace URI)- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
parseToStartTag
public void parseToStartTag(String ns, String name) throws JiBXException
Parse to start of element. Ignores character data to next start or end tag, but throws exception if an end tag is seen before a start tag, or if the start tag seen does not match the expected name. Leaves the parse positioned at the start tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)name- element name expected- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
parsePastStartTag
public void parsePastStartTag(String ns, String name) throws JiBXException
Parse past start of element. Ignores character data to next start or end tag, but throws exception if an end tag is seen before a start tag, or if the start tag seen does not match the expected name. Leaves the parse positioned following the start tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)name- element name expected- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
parseIfStartTag
public boolean parseIfStartTag(String ns, String name) throws JiBXException
Parse past start of expected element. If not currently positioned at a start or end tag this first advances the parser to the next tag. If the expected start tag is found it is skipped and the parse is left positioned following the start tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)name- element name expected- Returns:
trueif start tag found,falseif not- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
parsePastCurrentEndTag
public void parsePastCurrentEndTag(String ns, String name) throws JiBXException
Parse past current end of element. Ignores character data to next start or end tag, but throws exception if a start tag is seen before a end tag, or if the end tag seen does not match the expected name. Leaves the parse positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)name- element name expected- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
parsePastEndTag
public void parsePastEndTag(String ns, String name) throws JiBXException
Parse past end of element. If currently at a start tag parses past that start tag, then ignores character data to next start or end tag, and throws exception if a start tag is seen before a end tag, or if the end tag seen does not match the expected name. Leaves the parse positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)name- element name expected- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
isStart
public 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.- Specified by:
isStartin interfaceIUnmarshallingContext- Returns:
trueif at start of element,falseif at end- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
isEnd
public 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.- Specified by:
isEndin interfaceIUnmarshallingContext- Returns:
trueif at end of element,falseif at start- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
accumulateText
public String accumulateText() throws JiBXException
Accumulate text content. This skips past comments and processing instructions, and consolidates text and entities to a single string. Any unexpanded entity references found are treated as errors.- Returns:
- consolidated text string (empty string if no text components)
- Throws:
JiBXException- on error in unmarshalling
-
parseContentText
public String parseContentText() throws JiBXException
Parse required text content. Assumes the parse is already positioned at the text content, so just returns the text.- Returns:
- content text found
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseContentText
public String parseContentText(String ns, String tag) throws JiBXException
Parse past end of element, returning optional text content. Assumes you've already parsed past the start tag of the element, so it just looks for text content followed by the end tag, and returns with the parser positioned after the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- content text from element
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseContentInt
public int parseContentInt(String ns, String tag) throws JiBXException
Parse past end of element, returning integer value of content. Assumes you've already parsed past the start tag of the element, so it just looks for text content followed by the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- converted value from element text
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseElementText
public String parseElementText(String ns, String tag) throws JiBXException
Parse entire element, returning text content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- content text from element
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseElementText
public String parseElementText(String ns, String tag, String dflt) throws JiBXException
Parse entire element, returning optional text content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag. Returns the default text if the element is not found.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expecteddflt- default text value- Returns:
- content text from element
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
attributeText
public String attributeText(String ns, String name) throws JiBXException
Get text value of attribute from current start tag. Throws an exception if the attribute value is not found in the start tag.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
- attribute value text
- Throws:
JiBXException- if attribute not present
-
attributeText
public String attributeText(String ns, String name, String dflt)
Get text value of optional attribute from current start tag. If the attribute is not present the supplied default value is returned instead.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expecteddflt- value to be returned if attribute is not present- Returns:
- attribute value text
-
findID
public Object findID(String id, int index) throws JiBXException
Find the object corresponding to an ID. This method just handles the lookup and checks the object type.- Parameters:
id- ID textindex- expected reference type index- Returns:
- object corresponding to IDREF, or
nullif not yet defined - Throws:
JiBXException- on any error
-
findDefinedID
public Object findDefinedID(String id, int index) throws JiBXException
Find previously defined object corresponding to an ID. This does the lookup and checks that the referenced object has been defined.- Parameters:
id- ID textindex- expected reference type index- Returns:
- object corresponding to IDREF
- Throws:
JiBXException- on any error
-
parseElementForwardIDREF
public Object parseElementForwardIDREF(String ns, String tag, int index) throws JiBXException
Parse entire element, returning object (if defined yet) corresponding to content interpreted as IDREF. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- attribute name expectedindex- expected reference type index- Returns:
- object corresponding to IDREF, or
nullif not yet defined - Throws:
JiBXException- on any error (possibly wrapping other exception)
-
attributeForwardIDREF
public Object attributeForwardIDREF(String ns, String name, int index) throws JiBXException
Get object (if defined yet) corresponding to IDREF attribute from current start tag.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expectedindex- expected reference type index- Returns:
- object corresponding to IDREF, or
nullif not yet defined - Throws:
JiBXException- if attribute not present, or ID mapped to a different type of object than expected
-
parseElementExistingIDREF
public Object parseElementExistingIDREF(String ns, String tag, int index) throws JiBXException
Parse entire element, returning previously defined object corresponding to content interpreted as IDREF. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- attribute name expectedindex- expected reference type index- Returns:
- object corresponding to IDREF
- Throws:
JiBXException- if attribute not present, ID not defined, or mapped to a different type of object than expected
-
attributeExistingIDREF
public Object attributeExistingIDREF(String ns, String name, int index) throws JiBXException
Get previously defined object corresponding to IDREF attribute from current start tag.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expectedindex- expected reference type index- Returns:
- object corresponding to IDREF
- Throws:
JiBXException- if attribute not present, ID not defined, or mapped to a different type of object than expected
-
attributeInt
public int attributeInt(String ns, String name) throws JiBXException
Get integer value of attribute from current start tag. Throws an exception if the attribute is not found in the start tag, or if it is not a valid integer value.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
- attribute integer value
- Throws:
JiBXException- if attribute not present or not a valid integer value
-
attributeInt
public int attributeInt(String ns, String name, int dflt) throws JiBXException
Get integer value of optional attribute from current start tag. If the attribute is not present the supplied default value is returned instead.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expecteddflt- value to be returned if attribute is not present- Returns:
- attribute integer value
- Throws:
JiBXException- if attribute value is not a valid integer
-
parseElementInt
public int parseElementInt(String ns, String tag) throws JiBXException
Parse entire element, returning integer value of content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
parseElementInt
public int parseElementInt(String ns, String tag, int dflt) throws JiBXException
Parse entire optional element, returning integer value of content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag. Returns the default value if the element is missing or has no content.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expecteddflt- default value- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
convertEnum
public int convertEnum(String target, String[] enums, int[] vals) throws JiBXException
Find required text value in enumeration. Looks up and returns the enumeration value corresponding to the target text.- Parameters:
target- text to be found in enumerationenums- ordered array of texts included in enumerationvals- array of values to be returned for corresponding text match positions (position returned directly if this isnull)- Returns:
- enumeration value for target text
- Throws:
JiBXException- if target text not found in enumeration
-
convertEnum
public int convertEnum(String target, String[] enums, int[] vals, int dflt) throws JiBXException
Find optional text value in enumeration. Looks up and returns the enumeration value corresponding to the target text, or the default value if the text isnull.- Parameters:
target- text to be found in enumeration (may benull)enums- ordered array of texts included in enumerationvals- array of values to be returned for corresponding text match positions (position returned directly if this isnull)dflt- default value returned if target text isnull- Returns:
- enumeration value for target text
- Throws:
JiBXException- if target text not found in enumeration
-
attributeEnumeration
public int attributeEnumeration(String ns, String name, String[] enums, int[] vals) throws JiBXException
Get enumeration attribute value from current start tag. Throws an exception if the attribute value is not found in the start tag or the text does not match a value defined in the enumeration table.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expectedenums- ordered array of texts included in enumerationvals- array of values to be returned for corresponding text match positions (position returned directly if this isnull)- Returns:
- enumeration value for target text
- Throws:
JiBXException- if attribute not present or value not found in enumeration list
-
attributeEnumeration
public int attributeEnumeration(String ns, String name, String[] enums, int[] vals, int dflt) throws JiBXException
Get optional enumeration attribute value from current start tag. Throws an exception if the attribute value is present but does not match a value defined in the enumeration table.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expectedenums- ordered array of texts included in enumerationvals- array of values to be returned for corresponding text match positions (position returned directly if this isnull)dflt- default value returned if attribute is not present- Returns:
- enumeration value for target text
- Throws:
JiBXException- if attribute not present or value not found in enumeration list
-
parseContentEnumeration
public int parseContentEnumeration(String ns, String tag, String[] enums, int[] vals) throws JiBXException
Parse past end of element, returning enumeration value of content. Assumes you've already parsed past the start tag of the element, so it just looks for text content followed by the end tag, and returns with the parser positioned after the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expectedenums- ordered array of texts included in enumerationvals- array of values to be returned for corresponding text match positions (position returned directly if this isnull)- Returns:
- enumeration value for element text
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseElementEnumeration
public int parseElementEnumeration(String ns, String tag, String[] enums, int[] vals, int dflt) throws JiBXException
Parse entire element, returning enumeration value of optional content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag. Returns the default value if no content is present.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expectedenums- ordered array of texts included in enumerationvals- array of values to be returned for corresponding text match positions (position returned directly if this isnull)dflt- default value- Returns:
- enumeration value for element text
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
convertByte
public byte convertByte(String text) throws JiBXException
Convert byte value with exception wrapper. This internal method is used by all the byte unmarshalling calls. It adds position information to any exceptions that occur.- Parameters:
text- text for value to be converted- Returns:
- converted byte value
- Throws:
JiBXException- if not a valid byte value
-
attributeByte
public byte attributeByte(String ns, String name) throws JiBXException
Get byte value of attribute from current start tag. Throws an exception if the attribute is not found in the start tag, or if it is not a valid integer value.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
- attribute byte value
- Throws:
JiBXException- if attribute not present or not a valid byte value
-
attributeByte
public byte attributeByte(String ns, String name, byte dflt) throws JiBXException
Get byte value of optional attribute from current start tag. If the attribute is not present the supplied default value is returned instead.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expecteddflt- value to be returned if attribute is not present- Returns:
- attribute byte value
- Throws:
JiBXException- if attribute value is not a valid byte
-
parseContentByte
public byte parseContentByte(String ns, String tag) throws JiBXException
Parse past end of element, returning byte value of content. Assumes you've already parsed past the start tag of the element, so it just looks for text content followed by the end tag, and returns with the parser positioned after the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- converted value from element text
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseElementByte
public byte parseElementByte(String ns, String tag) throws JiBXException
Parse entire element, returning byte value of content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
parseElementByte
public byte parseElementByte(String ns, String tag, byte dflt) throws JiBXException
Parse entire element, returning byte value of optional content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag. Returns the default value if no content is present.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expecteddflt- default value- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
convertShort
public short convertShort(String text) throws JiBXException
Convert short value with exception wrapper. This internal method is used by all the short unmarshalling calls. It adds position information to any exceptions that occur.- Parameters:
text- text for value to be converted- Returns:
- converted short value
- Throws:
JiBXException- if not a valid short value
-
attributeShort
public short attributeShort(String ns, String name) throws JiBXException
Get short value of attribute from current start tag. Throws an exception if the attribute is not found in the start tag, or if it is not a valid integer value.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
- attribute short value
- Throws:
JiBXException- if attribute not present or not a valid short value
-
attributeShort
public short attributeShort(String ns, String name, short dflt) throws JiBXException
Get short value of optional attribute from current start tag. If the attribute is not present the supplied default value is returned instead.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expecteddflt- value to be returned if attribute is not present- Returns:
- attribute short value
- Throws:
JiBXException- if attribute value is not a valid short
-
parseContentShort
public short parseContentShort(String ns, String tag) throws JiBXException
Parse past end of element, returning short value of content. Assumes you've already parsed past the start tag of the element, so it just looks for text content followed by the end tag, and returns with the parser positioned after the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- converted value from element text
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseElementShort
public short parseElementShort(String ns, String tag) throws JiBXException
Parse entire element, returning short value of content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
parseElementShort
public short parseElementShort(String ns, String tag, short dflt) throws JiBXException
Parse entire element, returning short value of optional content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag. Returns the default value if no content is present.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expecteddflt- default value- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
convertChar
public char convertChar(String text) throws JiBXException
Convert char value with exception wrapper. This internal method is used by all the char unmarshalling calls. It adds position information to any exceptions that occur.- Parameters:
text- text for value to be converted- Returns:
- converted char value
- Throws:
JiBXException- if not a valid char value
-
attributeChar
public char attributeChar(String ns, String name) throws JiBXException
Get char value of attribute from current start tag. Throws an exception if the attribute is not found in the start tag, or if it is not a valid integer value.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
- attribute char value
- Throws:
JiBXException- if attribute not present or not a valid char value
-
attributeChar
public char attributeChar(String ns, String name, char dflt) throws JiBXException
Get char value of optional attribute from current start tag. If the attribute is not present the supplied default value is returned instead.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expecteddflt- value to be returned if attribute is not present- Returns:
- attribute char value
- Throws:
JiBXException- if attribute value is not a valid char
-
parseContentChar
public char parseContentChar(String ns, String tag) throws JiBXException
Parse past end of element, returning char value of content. Assumes you've already parsed past the start tag of the element, so it just looks for text content followed by the end tag, and returns with the parser positioned after the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- converted value from element text
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseElementChar
public char parseElementChar(String ns, String tag) throws JiBXException
Parse entire element, returning char value of content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
parseElementChar
public char parseElementChar(String ns, String tag, char dflt) throws JiBXException
Parse entire element, returning char value of optional content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag. Returns the default value if the element is not present.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expecteddflt- default value- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
convertLong
public long convertLong(String text) throws JiBXException
Convert long value with exception wrapper. This internal method is used by all the long unmarshalling calls. It adds position information to any exceptions that occur.- Parameters:
text- text for value to be converted- Returns:
- converted long value
- Throws:
JiBXException- if not a valid long value
-
attributeLong
public long attributeLong(String ns, String name) throws JiBXException
Get long value of attribute from current start tag. Throws an exception if the attribute is not found in the start tag, or if it is not a valid integer value.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
- attribute long value
- Throws:
JiBXException- if attribute not present or not a valid long value
-
attributeLong
public long attributeLong(String ns, String name, long dflt) throws JiBXException
Get long value of optional attribute from current start tag. If the attribute is not present the supplied default value is returned instead.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expecteddflt- value to be returned if attribute is not present- Returns:
- attribute long value
- Throws:
JiBXException- if attribute value is not a valid long
-
parseElementLong
public long parseElementLong(String ns, String tag) throws JiBXException
Parse past end of element, returning long value of content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- converted value from element text
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseElementLong
public long parseElementLong(String ns, String tag, long dflt) throws JiBXException
Parse entire element, returning long value of optional content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag. Returns the default value if the element is not present.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expecteddflt- default value- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
convertBoolean
public boolean convertBoolean(String text) throws JiBXException
Convert boolean value. This internal method is used by all the boolean unmarshalling calls. It accepts "true" or "1" as equivalent, and "false" or "0" as equivalent, and throws exceptions for anything else.- Parameters:
text- text for value to be converted- Returns:
- converted boolean value
- Throws:
JiBXException- if not a valid boolean value
-
attributeBoolean
public boolean attributeBoolean(String ns, String name) throws JiBXException
Get boolean value of attribute from current start tag. Throws an exception if the attribute is not found in the start tag, or if it is not a valid integer value.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
- attribute boolean value
- Throws:
JiBXException- if attribute not present or not a valid boolean value
-
attributeBoolean
public boolean attributeBoolean(String ns, String name, boolean dflt) throws JiBXException
Get boolean value of optional attribute from current start tag. If the attribute is not present the supplied default value is returned instead.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expecteddflt- value to be returned if attribute is not present- Returns:
- attribute boolean value
- Throws:
JiBXException- if attribute value is not a valid boolean
-
parseElementBoolean
public boolean parseElementBoolean(String ns, String tag) throws JiBXException
Parse entire element, returning boolean value of content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- converted value from element text
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseElementBoolean
public boolean parseElementBoolean(String ns, String tag, boolean dflt) throws JiBXException
Parse entire element, returning boolean value of optional content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag. Returns the default value if the element is not present.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expecteddflt- default value- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
convertFloat
public float convertFloat(String text) throws JiBXException
Convert float value with exception wrapper. This internal method is used by all the float unmarshalling calls. It adds position information to any exceptions that occur.- Parameters:
text- text for value to be converted- Returns:
- converted float value
- Throws:
JiBXException- if not a valid float value
-
attributeFloat
public float attributeFloat(String ns, String name) throws JiBXException
Get float value of attribute from current start tag. Throws an exception if the attribute is not found in the start tag, or if it is not a valid integer value.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
- attribute float value
- Throws:
JiBXException- if attribute not present or not a valid float value
-
attributeFloat
public float attributeFloat(String ns, String name, float dflt) throws JiBXException
Get float value of optional attribute from current start tag. If the attribute is not present the supplied default value is returned instead.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expecteddflt- value to be returned if attribute is not present- Returns:
- attribute float value
- Throws:
JiBXException- if attribute value is not a valid float
-
parseElementFloat
public float parseElementFloat(String ns, String tag) throws JiBXException
Parse past end of element, returning float value of content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- converted value from element text
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseElementFloat
public float parseElementFloat(String ns, String tag, float dflt) throws JiBXException
Parse entire element, returning float value of optional content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag. Returns the default value if the element is not present.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expecteddflt- default value- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
convertDouble
public double convertDouble(String text) throws JiBXException
Convert double value with exception wrapper. This internal method is used by all the double unmarshalling calls. It adds position information to any exceptions that occur.- Parameters:
text- text for value to be converted- Returns:
- converted double value
- Throws:
JiBXException- if not a valid double value
-
attributeDouble
public double attributeDouble(String ns, String name) throws JiBXException
Get double value of attribute from current start tag. Throws an exception if the attribute is not found in the start tag, or if it is not a valid integer value.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
- attribute double value
- Throws:
JiBXException- if attribute not present or not a valid double value
-
attributeDouble
public double attributeDouble(String ns, String name, double dflt) throws JiBXException
Get double value of optional attribute from current start tag. If the attribute is not present the supplied default value is returned instead.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expecteddflt- value to be returned if attribute is not present- Returns:
- attribute double value
- Throws:
JiBXException- if attribute value is not a valid double
-
parseElementDouble
public double parseElementDouble(String ns, String tag) throws JiBXException
Parse past end of element, returning double value of content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- converted value from element text
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseElementDouble
public double parseElementDouble(String ns, String tag, double dflt) throws JiBXException
Parse entire element, returning double value of optional content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag. Returns the default value if the element is not present.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expecteddflt- default value- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
convertDate
public Date convertDate(String text) throws JiBXException
Convertjava.util.Datevalue with exception wrapper. This internal method is used by all the Date unmarshalling calls. It adds position information to any exceptions that occur.- Parameters:
text- text for value to be converted- Returns:
- converted Date value
- Throws:
JiBXException- if not a valid Date value
-
attributeDate
public Date attributeDate(String ns, String name) throws JiBXException
Getjava.util.Datevalue of attribute from current start tag. Throws an exception if the attribute is not found in the start tag, or if it is not a valid integer value.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
- attribute Date value
- Throws:
JiBXException- if attribute not present or not a valid Date value
-
attributeDate
public Date attributeDate(String ns, String name, Date dflt) throws JiBXException
Getjava.util.Datevalue of optional attribute from current start tag. If the attribute is not present the supplied default value is returned instead.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expecteddflt- value to be returned if attribute is not present- Returns:
- attribute Date value
- Throws:
JiBXException- if attribute value is not a valid Date
-
parseElementDate
public Date parseElementDate(String ns, String tag) throws JiBXException
Parse past end of element, returningjava.util.Datevalue of content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Returns:
- converted value from element text
- Throws:
JiBXException- on any error (possible wrapping other exception)
-
parseElementDate
public Date parseElementDate(String ns, String tag, Date dflt) throws JiBXException
Parse entire element, returningjava.util.Datevalue of optional content. Expects to find the element start tag, text content, and end tag, in that order, and returns with the parser positioned following the end tag. Returns the default value if the element is not present.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expecteddflt- default value- Returns:
- content text from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
registerBackFill
public void registerBackFill(String id, int index, BackFillReference fill) throws JiBXException
Register back fill item for undefined ID value. This adds a holder to the mapping table if not already present, then adds the back fill item to the holder.- Parameters:
id- target undefined ID valueindex- target reference type indexfill- back fill item- Throws:
JiBXException- if attribute not present, or ID already defined
-
registerBackFill
public void registerBackFill(int index, BackFillReference fill) throws JiBXExceptionRegister back fill item for last parsed ID value. This adds a holder to the mapping table if not already present, then adds the back fill item to the holder. This form of call always applies to the last IDREF value parsed (from either an element or an attribute).- Parameters:
index- target reference type indexfill- back fill item- Throws:
JiBXException- if attribute not present, or ID already defined
-
defineID
public void defineID(String id, int index, Object obj) throws JiBXException
Define object for ID. Adds the owning object to a map with the ID value as key. Throws an exception if the object class does not match that expected from forward references, or if another object has previously been registered with the same ID.- Parameters:
id- text ID valueindex- ID class index numberobj- object corresponding to element- Throws:
JiBXException- if duplicate ID or wrong class
-
mapUnmarshalling
protected void mapUnmarshalling(int index)
Map unmarshalling for element. Adds the entry for a particular class index to the unmarshalling map.- Parameters:
index- class index for unmarshalling definition to be added
-
addUnmarshalling
public void addUnmarshalling(String mapname, String ns, String name, String cname) throws JiBXException
Define unmarshalling for element. Enables the unmarshalling definition linking an element name (including namespace) with a handler.- Parameters:
mapname- mapping name associated with unmarshallerns- namespace for element (may benullor the empty string for the empty namespace)name- name for elementcname- unmarshaller class name- Throws:
JiBXException- if unknown mapping name
-
removeUnmarshalling
public void removeUnmarshalling(String mapname) throws JiBXException
Undefine unmarshalling for element. Disables the unmarshalling definition for a particular mapping name.- Parameters:
mapname- mapping name associated with unmarshaller- Throws:
JiBXException- if unknown mapping name
-
getUnmarshaller
public IUnmarshaller getUnmarshaller(String mapname) throws JiBXException
Find the unmarshaller for a particular class in the current context.- Specified by:
getUnmarshallerin interfaceIUnmarshallingContext- 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
-
getUnmarshaller
public IUnmarshaller getUnmarshaller(String ns, String name) throws JiBXException
Find the unmarshaller for a particular element name (including namespace) in the current context.- Parameters:
ns- namespace for element (may benullor the empty string for the empty namespace)name- name for element- Returns:
- unmarshalling handler for element, or
nullif none found - Throws:
JiBXException- if unable to create unmarshaller
-
unmarshalOptionalElement
public Object unmarshalOptionalElement() throws JiBXException
Unmarshal optional element. If not currently positioned at a start or end tag this first advances the parse to the next start or end tag.- Returns:
- unmarshalled object from element, or
nullif end tag rather than start tag seen - Throws:
JiBXException- on any error (possibly wrapping other exception)
-
unmarshalElement
public Object unmarshalElement(Class clas) throws JiBXException
Unmarshal required element of specified type. If not currently positioned at a start or end tag this first advances the parse to the next start or end tag. The returned object will always be assignable to the specified type.- Parameters:
clas- expected class of unmarshalled object- Returns:
- unmarshalled object from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
unmarshalElement
public Object unmarshalElement() throws JiBXException
Unmarshal required element. If not currently positioned at a start or end tag this first advances the parse to the next start or end tag.- Specified by:
unmarshalElementin interfaceIUnmarshallingContext- Returns:
- unmarshalled object from element
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
parsePastElement
public void parsePastElement(String ns, String tag) throws JiBXException
Parse past element, ignoring all content. This may be used while positioned either before or on the element start tag. It checks if currently positioned at the element start tag, and if so advances to the next parse event. Then looks for the next end tag, ignoring character data and skipping child elements. Leaves the parse positioned following the end tag.- Parameters:
ns- namespace URI for expected element (may benullor the empty string for the empty namespace)tag- element name expected- Throws:
JiBXException- on any error (possible wrapping other exception)
-
getElementName
public String getElementName() throws JiBXException
Returns current element name.- Returns:
- local name part of name, or
nullif not at a start or end tag - Throws:
JiBXException- if error from parser
-
getElementNamespace
public String getElementNamespace() throws JiBXException
Returns current element namespace URI.- Returns:
- namespace URI of name, or
nullif not at a start or end tag - Throws:
JiBXException- if error from parser
-
throwStartTagException
public void throwStartTagException(String msg) throws JiBXException
Throw exception with start tag and position information.- Parameters:
msg- exception message text- Throws:
JiBXException- always thrown
-
throwStartTagException
public void throwStartTagException(String msg, Exception ex) throws JiBXException
Throw exception with start tag, position information, and nested exception.- Parameters:
msg- exception message textex- nested exception- Throws:
JiBXException- always thrown
-
throwException
public void throwException(String msg) throws JiBXException
Throw exception with position information.- Parameters:
msg- exception message text- Throws:
JiBXException- always thrown
-
throwException
public void throwException(String msg, Exception ex) throws JiBXException
Throw exception with position information and nested exception.- Parameters:
msg- exception message textex- nested exception- Throws:
JiBXException- always thrown
-
unmarshalDocument
public 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, java.lang.String, boolean)were called, followed byunmarshalElement(java.lang.Class)- Specified by:
unmarshalDocumentin interfaceIUnmarshallingContext- 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
public 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, java.lang.String, boolean)were called, followed byunmarshalElement(java.lang.Class)- Specified by:
unmarshalDocumentin interfaceIUnmarshallingContext- Parameters:
rdr- reader supplying document data- Returns:
- unmarshalled object
- Throws:
JiBXException- if error creating parser
-
unmarshalDocument
public 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, java.lang.String, boolean)were called, followed byunmarshalElement(java.lang.Class)- Specified by:
unmarshalDocumentin interfaceIUnmarshallingContext- 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
public 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, java.lang.String, boolean)were called, followed byunmarshalElement(java.lang.Class)- Specified by:
unmarshalDocumentin interfaceIUnmarshallingContext- Parameters:
rdr- reader supplying document dataname- document name- Returns:
- unmarshalled object
- Throws:
JiBXException- if error creating parser
-
getFactory
public IBindingFactory getFactory()
Return the binding factory used to create this unmarshaller.- Returns:
- binding factory
-
getDocumentName
public String getDocumentName()
Return the supplied document name.- Specified by:
getDocumentNamein interfaceIUnmarshallingContext- Returns:
- supplied document name (
nullif none)
-
getInputEncoding
public String getInputEncoding()
Return the input encoding, if known. This is only valid after parsing of a document has been started.- Returns:
- input encoding (
nullif unknown)
-
setUserContext
public 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(java.lang.Class)method.- Specified by:
setUserContextin interfaceIUnmarshallingContext- Parameters:
obj- user context object, ornullif clearing existing context object- See Also:
getUserContext()
-
getUserContext
public Object getUserContext()
Get the user context object.- Specified by:
getUserContextin interfaceIUnmarshallingContext- Returns:
- user context object, or
nullif no context object set - See Also:
setUserContext(Object)
-
pushObject
public 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.- Specified by:
pushObjectin interfaceIUnmarshallingContext- Parameters:
obj- object being unmarshalled
-
trackObject
public void trackObject(Object obj)
Set position tracking information for object, if supported.- Parameters:
obj- object being tracked
-
pushTrackedObject
public void pushTrackedObject(Object obj)
Push created object to unmarshalling stack with position tracking. If the object supports setting source location information, the location is also set by this method.- Parameters:
obj- object being unmarshalled
-
popObject
public void popObject() throws JiBXExceptionPop unmarshalled object from stack.- Specified by:
popObjectin interfaceIUnmarshallingContext- Throws:
JiBXException- if no object on stack
-
getStackDepth
public 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.- Specified by:
getStackDepthin interfaceIUnmarshallingContext- Returns:
- number of objects in unmarshalling stack
-
getStackObject
public 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.- Specified by:
getStackObjectin interfaceIUnmarshallingContext- 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
public Object getStackTop()
Get top object on unmarshalling stack. This is safe to call even when no objects are on the stack.- Specified by:
getStackTopin interfaceIUnmarshallingContext- Returns:
- object from unmarshalling stack, or
nullif none
-
getActiveNamespaceCount
public int getActiveNamespaceCount()
Get count of active namespaces.- Returns:
- number of active namespaces in stack
-
getActiveNamespaceUri
public String getActiveNamespaceUri(int index)
Get URI for an active namespace.- Parameters:
index- index number of namespace to be returned- Returns:
- URI for namespace at position
- Throws:
IllegalArgumentException- if invalid index
-
getActiveNamespacePrefix
public String getActiveNamespacePrefix(int index)
Get prefix for an active namespace.- Parameters:
index- stack position of namespace to be returned- Returns:
- prefix for namespace at position
- Throws:
IllegalArgumentException- if invalid index
-
skipElement
public void skipElement() throws JiBXExceptionSkip past current element.- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
next
public int next() throws JiBXExceptionAdvance to next major parse event. This wraps the base parser call in order to catch and handle exceptions, and to preserve a reasonable level of parser independence.- Returns:
- event type for next major parse event (START_TAG, TEXT, END_TAG, or END_DOCUMENT)
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
nextToken
public int nextToken() throws JiBXExceptionAdvance to next parse event. This wraps the base parser call in order to catch and handle exceptions, and to preserve a reasonable level of parser independence.- Returns:
- event type for next parse event
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
currentEvent
public int currentEvent() throws JiBXExceptionGet the current parse event type. This wraps the base parser call in order to catch and handle exceptions, and to preserve a reasonable level of parser independence.- Returns:
- event type for current parse event
- Throws:
JiBXException- on any error (possibly wrapping other exception)
-
getName
public String getName()
Get name associated with current parse event.- Returns:
- name text for name associated with event (START_ELEMENT, END_ELEMENT, or ENTITY_REF only)
- Throws:
IllegalStateException- if not at a start or end tag (optional)
-
getNamespace
public String getNamespace()
Get namespace associated with current parse event.- Returns:
- URI for namespace associated with event (START_ELEMENT or END_ELEMENT only), empty string if none
- Throws:
IllegalStateException- if not at a start or end tag (optional)
-
getPrefix
public String getPrefix()
Get namespace prefix associated with current parse event.- Returns:
- prefix for namespace associated with event (START_ELEMENT or
END_ELEMENT only),
nullif none - Throws:
IllegalStateException- if not at a start or end tag (optional)
-
getAttributeCount
public int getAttributeCount()
Get number of attributes for current START_ELEMENT event. The results are undefined if called when not at a START_ELEMENT event.- Returns:
- number of attributes, or
-1if not at START_ELEMENT - Throws:
IllegalStateException- if not at a start tag (optional)
-
getAttributeName
public String getAttributeName(int index)
Get attribute name for current START_ELEMENT event. The results are undefined if called when not at a START_ELEMENT event.- Parameters:
index- index number of attribute to be returned- Returns:
- name of attribute at position
- Throws:
IllegalStateException- if not at a start tag or invalid index
-
getAttributeNamespace
public String getAttributeNamespace(int index)
Get attribute namespace for current START_ELEMENT event. The results are undefined if called when not at a START_ELEMENT event.- Parameters:
index- index number of attribute to be returned- Returns:
- namespace URI of attribute at position, empty string if none
- Throws:
IllegalStateException- if not at a start tag or invalid index
-
getAttributePrefix
public String getAttributePrefix(int index)
Get attribute namespace prefix for current START_ELEMENT event. The results are undefined if called when not at a START_ELEMENT event.- Parameters:
index- index number of attribute to be returned- Returns:
- prefix for namespace of attribute at position,
nullif none - Throws:
IllegalStateException- if not at a start tag or invalid index
-
getAttributeValue
public String getAttributeValue(int index)
Get attribute value for current START_ELEMENT event. The results are undefined if called when not at a START_ELEMENT event.- Parameters:
index- index number of attribute to be returned- Returns:
- value of attribute at position
- Throws:
IllegalStateException- if not at a start tag or invalid index
-
getNamespaceCount
public int getNamespaceCount()
Get number of namespace declarations for current START_ELEMENT event. The results are undefined if called when not at a START_ELEMENT event.- Returns:
- number of namespace declarations, or
-1if not at START_ELEMENT
-
getNamespaceUri
public String getNamespaceUri(int index)
Get namespace URI for namespace declaration on current START_ELEMENT event. The results are undefined if called when not at a START_ELEMENT event.- Parameters:
index- index number of declaration to be returned- Returns:
- namespace URI for declaration at position
- Throws:
IllegalArgumentException- if invalid index
-
getNamespacePrefix
public String getNamespacePrefix(int index)
Get namespace prefix for namespace declaration on current START_ELEMENT event. The results are undefined if called when not at a START_ELEMENT event.- Parameters:
index- index number of declaration to be returned- Returns:
- namespace prefix for declaration at position,
- Throws:
IllegalArgumentException- if invalid index
-
getNamespaceUri
public String getNamespaceUri(String prefix)
Get namespace URI matching prefix.- Parameters:
prefix- namespace prefix to be matched (nullfor default namespace)- Returns:
- namespace URI for prefix
-
getText
public String getText()
Get text value for current event.- Returns:
- text value for event
-
-