org.jibx.runtime.impl
Class UnmarshallingContext

java.lang.Object
  extended by org.jibx.runtime.impl.UnmarshallingContext
All Implemented Interfaces:
IUnmarshallingContext

public class UnmarshallingContext
extends java.lang.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

Constructor Summary
UnmarshallingContext()
          Default constructor.
UnmarshallingContext(int nmap, java.lang.String[] umcs, java.lang.String[] nss, java.lang.String[] names, java.lang.String[] idcs, IBindingFactory ifact)
          Constructor.
 
Method Summary
 java.lang.String accumulateText()
          Accumulate text content.
 void addUnmarshalling(int index, java.lang.String ns, java.lang.String name, java.lang.String cname)
          Define unmarshalling for element.
 boolean attributeBoolean(java.lang.String ns, java.lang.String name)
          Get boolean value of attribute from current start tag.
 boolean attributeBoolean(java.lang.String ns, java.lang.String name, boolean dflt)
          Get boolean value of optional attribute from current start tag.
 byte attributeByte(java.lang.String ns, java.lang.String name)
          Get byte value of attribute from current start tag.
 byte attributeByte(java.lang.String ns, java.lang.String name, byte dflt)
          Get byte value of optional attribute from current start tag.
 char attributeChar(java.lang.String ns, java.lang.String name)
          Get char value of attribute from current start tag.
 char attributeChar(java.lang.String ns, java.lang.String name, char dflt)
          Get char value of optional attribute from current start tag.
 java.util.Date attributeDate(java.lang.String ns, java.lang.String name)
          Get java.util.Date value of attribute from current start tag.
 java.util.Date attributeDate(java.lang.String ns, java.lang.String name, java.util.Date dflt)
          Get java.util.Date value of optional attribute from current start tag.
 double attributeDouble(java.lang.String ns, java.lang.String name)
          Get double value of attribute from current start tag.
 double attributeDouble(java.lang.String ns, java.lang.String name, double dflt)
          Get double value of optional attribute from current start tag.
 int attributeEnumeration(java.lang.String ns, java.lang.String name, java.lang.String[] enums, int[] vals)
          Get enumeration attribute value from current start tag.
 int attributeEnumeration(java.lang.String ns, java.lang.String name, java.lang.String[] enums, int[] vals, int dflt)
          Get optional enumeration attribute value from current start tag.
 java.lang.Object attributeExistingIDREF(java.lang.String ns, java.lang.String name, int index)
          Get previously defined object corresponding to IDREF attribute from current start tag.
 float attributeFloat(java.lang.String ns, java.lang.String name)
          Get float value of attribute from current start tag.
 float attributeFloat(java.lang.String ns, java.lang.String name, float dflt)
          Get float value of optional attribute from current start tag.
 java.lang.Object attributeForwardIDREF(java.lang.String ns, java.lang.String name, int index)
          Get object (if defined yet) corresponding to IDREF attribute from current start tag.
 int attributeInt(java.lang.String ns, java.lang.String name)
          Get integer value of attribute from current start tag.
 int attributeInt(java.lang.String ns, java.lang.String name, int dflt)
          Get integer value of optional attribute from current start tag.
 long attributeLong(java.lang.String ns, java.lang.String name)
          Get long value of attribute from current start tag.
 long attributeLong(java.lang.String ns, java.lang.String name, long dflt)
          Get long value of optional attribute from current start tag.
 short attributeShort(java.lang.String ns, java.lang.String name)
          Get short value of attribute from current start tag.
 short attributeShort(java.lang.String ns, java.lang.String name, short dflt)
          Get short value of optional attribute from current start tag.
 java.lang.String attributeText(java.lang.String ns, java.lang.String name)
          Get text value of attribute from current start tag.
 java.lang.String attributeText(java.lang.String ns, java.lang.String name, java.lang.String dflt)
          Get text value of optional attribute from current start tag.
static java.lang.String buildNameString(java.lang.String ns, java.lang.String name)
          Build name with optional namespace.
 java.lang.String buildPositionString()
          Build current parse input position description.
 void checkAllowedAttributes(java.lang.String[] nss, java.lang.String[] names)
          Check that only allowed attributes are present on current start tag.
 boolean convertBoolean(java.lang.String text)
          Convert boolean value.
 byte convertByte(java.lang.String text)
          Convert byte value with exception wrapper.
 char convertChar(java.lang.String text)
          Convert char value with exception wrapper.
 java.util.Date convertDate(java.lang.String text)
          Convert java.util.Date value with exception wrapper.
 double convertDouble(java.lang.String text)
          Convert double value with exception wrapper.
 int convertEnum(java.lang.String target, java.lang.String[] enums, int[] vals)
          Find required text value in enumeration.
 int convertEnum(java.lang.String target, java.lang.String[] enums, int[] vals, int dflt)
          Find optional text value in enumeration.
 float convertFloat(java.lang.String text)
          Convert float value with exception wrapper.
 long convertLong(java.lang.String text)
          Convert long value with exception wrapper.
 short convertShort(java.lang.String text)
          Convert short value with exception wrapper.
 int currentEvent()
          Get the current parse event type.
 java.lang.String currentNameString()
          Build current element name, with optional namespace.
 void defineID(java.lang.String id, int index, java.lang.Object obj)
          Define object for ID.
 java.lang.Object findDefinedID(java.lang.String id, int index)
          Find previously defined object corresponding to an ID.
 java.lang.Object findID(java.lang.String id, int index)
          Find the object corresponding to an ID.
 int getActiveNamespaceCount()
          Get count of active namespaces.
 java.lang.String getActiveNamespacePrefix(int index)
          Get prefix for an active namespace.
 java.lang.String getActiveNamespaceUri(int index)
          Get URI for an active namespace.
 int getAttributeCount()
          Get number of attributes for current START_ELEMENT event.
 java.lang.String getAttributeName(int index)
          Get attribute name for current START_ELEMENT event.
 java.lang.String getAttributeNamespace(int index)
          Get attribute namespace for current START_ELEMENT event.
 java.lang.String getAttributePrefix(int index)
          Get attribute namespace prefix for current START_ELEMENT event.
 java.lang.String getAttributeValue(int index)
          Get attribute value for current START_ELEMENT event.
 java.lang.String getDocumentName()
          Return the supplied document name.
 java.lang.String getElementName()
          Returns current element name.
 java.lang.String getElementNamespace()
          Returns current element namespace URI.
 IBindingFactory getFactory()
          Return the binding factory used to create this unmarshaller.
 java.lang.String getInputEncoding()
          Return the input encoding, if known.
 java.lang.String getName()
          Get name associated with current parse event.
 java.lang.String getNamespace()
          Get namespace associated with current parse event.
 int getNamespaceCount()
          Get number of namespace declarations for current START_ELEMENT event.
 java.lang.String getNamespacePrefix(int index)
          Get namespace prefix for namespace declaration on current START_ELEMENT event.
 java.lang.String getNamespaceUri(int index)
          Get namespace URI for namespace declaration on current START_ELEMENT event.
 java.lang.String getNamespaceUri(java.lang.String prefix)
          Get namespace URI matching prefix.
 java.lang.String getPrefix()
          Get namespace prefix associated with current parse event.
 int getStackDepth()
          Get current unmarshalling object stack depth.
 java.lang.Object getStackObject(int depth)
          Get object from unmarshalling stack.
 java.lang.Object getStackTop()
          Get top object on unmarshalling stack.
 java.lang.String getText()
          Get text value for current event.
 IUnmarshaller getUnmarshaller(int index)
          Find the unmarshaller for a particular class index in the current context.
 IUnmarshaller getUnmarshaller(java.lang.String ns, java.lang.String name)
          Find the unmarshaller for a particular element name (including namespace) in the current context.
 java.lang.Object getUserContext()
          Get the user context object.
 boolean hasAnyAttribute(java.lang.String[] nss, java.lang.String[] names)
          Check if any of several attributes is present on current start tag.
 boolean hasAttribute(java.lang.String ns, java.lang.String name)
          Check if attribute is present on current start tag.
 boolean isAt(java.lang.String ns, java.lang.String name)
          Check if next tag is start of element.
 boolean isEnd()
          Check if next tag is an end tag.
 boolean isStart()
          Check if next tag is a start tag.
 int next()
          Advance to next major parse event.
 int nextToken()
          Advance to next parse event.
 byte parseContentByte(java.lang.String ns, java.lang.String tag)
          Parse past end of element, returning byte value of content.
 char parseContentChar(java.lang.String ns, java.lang.String tag)
          Parse past end of element, returning char value of content.
 int parseContentEnumeration(java.lang.String ns, java.lang.String tag, java.lang.String[] enums, int[] vals)
          Parse past end of element, returning enumeration value of content.
 int parseContentInt(java.lang.String ns, java.lang.String tag)
          Parse past end of element, returning integer value of content.
 short parseContentShort(java.lang.String ns, java.lang.String tag)
          Parse past end of element, returning short value of content.
 java.lang.String parseContentText()
          Parse required text content.
 java.lang.String parseContentText(java.lang.String ns, java.lang.String tag)
          Parse past end of element, returning optional text content.
 boolean parseElementBoolean(java.lang.String ns, java.lang.String tag)
          Parse entire element, returning boolean value of content.
 boolean parseElementBoolean(java.lang.String ns, java.lang.String tag, boolean dflt)
          Parse entire element, returning boolean value of optional content.
 byte parseElementByte(java.lang.String ns, java.lang.String tag)
          Parse entire element, returning byte value of content.
 byte parseElementByte(java.lang.String ns, java.lang.String tag, byte dflt)
          Parse entire element, returning byte value of optional content.
 char parseElementChar(java.lang.String ns, java.lang.String tag)
          Parse entire element, returning char value of content.
 char parseElementChar(java.lang.String ns, java.lang.String tag, char dflt)
          Parse entire element, returning char value of optional content.
 java.util.Date parseElementDate(java.lang.String ns, java.lang.String tag)
          Parse past end of element, returning java.util.Date value of content.
 java.util.Date parseElementDate(java.lang.String ns, java.lang.String tag, java.util.Date dflt)
          Parse entire element, returning java.util.Date value of optional content.
 double parseElementDouble(java.lang.String ns, java.lang.String tag)
          Parse past end of element, returning double value of content.
 double parseElementDouble(java.lang.String ns, java.lang.String tag, double dflt)
          Parse entire element, returning double value of optional content.
 int parseElementEnumeration(java.lang.String ns, java.lang.String tag, java.lang.String[] enums, int[] vals, int dflt)
          Parse entire element, returning enumeration value of optional content.
 java.lang.Object parseElementExistingIDREF(java.lang.String ns, java.lang.String tag, int index)
          Parse entire element, returning previously defined object corresponding to content interpreted as IDREF.
 float parseElementFloat(java.lang.String ns, java.lang.String tag)
          Parse past end of element, returning float value of content.
 float parseElementFloat(java.lang.String ns, java.lang.String tag, float dflt)
          Parse entire element, returning float value of optional content.
 java.lang.Object parseElementForwardIDREF(java.lang.String ns, java.lang.String tag, int index)
          Parse entire element, returning object (if defined yet) corresponding to content interpreted as IDREF.
 int parseElementInt(java.lang.String ns, java.lang.String tag)
          Parse entire element, returning integer value of content.
 int parseElementInt(java.lang.String ns, java.lang.String tag, int dflt)
          Parse entire optional element, returning integer value of content.
 long parseElementLong(java.lang.String ns, java.lang.String tag)
          Parse past end of element, returning long value of content.
 long parseElementLong(java.lang.String ns, java.lang.String tag, long dflt)
          Parse entire element, returning long value of optional content.
 short parseElementShort(java.lang.String ns, java.lang.String tag)
          Parse entire element, returning short value of content.
 short parseElementShort(java.lang.String ns, java.lang.String tag, short dflt)
          Parse entire element, returning short value of optional content.
 java.lang.String parseElementText(java.lang.String ns, java.lang.String tag)
          Parse entire element, returning text content.
 java.lang.String parseElementText(java.lang.String ns, java.lang.String tag, java.lang.String dflt)
          Parse entire element, returning optional text content.
 boolean parseIfStartTag(java.lang.String ns, java.lang.String name)
          Parse past start of expected element.
 void parsePastCurrentEndTag(java.lang.String ns, java.lang.String name)
          Parse past current end of element.
 void parsePastElement(java.lang.String ns, java.lang.String tag)
          Parse past element, ignoring all content.
 void parsePastEndTag(java.lang.String ns, java.lang.String name)
          Parse past end of element.
 void parsePastStartTag(java.lang.String ns, java.lang.String name)
          Parse past start of element.
 void parseToStartTag(java.lang.String ns, java.lang.String name)
          Parse to start of element.
 void popObject()
          Pop unmarshalled object from stack.
 void pushObject(java.lang.Object obj)
          Push created object to unmarshalling stack.
 void pushTrackedObject(java.lang.Object obj)
          Push created object to unmarshalling stack with position tracking.
 void registerBackFill(int index, BackFillReference fill)
          Register back fill item for last parsed ID value.
 void registerBackFill(java.lang.String id, int index, BackFillReference fill)
          Register back fill item for undefined ID value.
 void removeUnmarshalling(int index)
          Undefine unmarshalling for element.
 void reset()
          Reset unmarshalling information.
 void setDocument(java.io.InputStream ins, java.lang.String enc)
          Set document to be parsed from stream.
 void setDocument(java.io.InputStream ins, java.lang.String name, java.lang.String enc)
          Set named document to be parsed from stream.
 void setDocument(java.io.InputStream ins, java.lang.String name, java.lang.String enc, boolean nsa)
          Set document to be parsed from stream.
 void setDocument(IXMLReader rdr)
          Set input document parse source directly.
 void setDocument(java.io.Reader rdr)
          Set document to be parsed from reader.
 void setDocument(java.io.Reader rdr, java.lang.String name)
          Set named document to be parsed from reader.
 void setDocument(java.io.Reader rdr, java.lang.String name, boolean nsa)
          Set document to be parsed from reader.
 void setFromContext(UnmarshallingContext parent)
          Initializes the context to use the same parser and document as another unmarshalling context.
 void setUserContext(java.lang.Object obj)
          Set a user context object.
 void skipElement()
          Skip past current element.
 void throwEndTagNameError(java.lang.String ns, java.lang.String name)
          Throw exception for expected element end tag not found.
 void throwException(java.lang.String msg)
          Throw exception with position information.
 void throwException(java.lang.String msg, java.lang.Exception ex)
          Throw exception with position information and nested exception.
 void throwNameException(java.lang.String msg, java.lang.String ns, java.lang.String name)
          Throw exception including a name and position information.
 void throwStartTagException(java.lang.String msg)
          Throw exception with start tag and position information.
 void throwStartTagException(java.lang.String msg, java.lang.Exception ex)
          Throw exception with start tag, position information, and nested exception.
 void throwStartTagNameError(java.lang.String ns, java.lang.String name)
          Throw exception for expected element start tag not found.
 java.lang.String toEnd()
          Parse to end tag.
 java.lang.String toStart()
          Parse to start tag.
 int toTag()
          Parse to start or end tag.
 void trackObject(java.lang.Object obj)
          Set position tracking information for object, if supported.
 java.lang.Object unmarshalDocument(java.io.InputStream ins, java.lang.String enc)
          Unmarshal document from stream to object.
 java.lang.Object unmarshalDocument(java.io.InputStream ins, java.lang.String name, java.lang.String enc)
          Unmarshal named document from stream to object.
 java.lang.Object unmarshalDocument(java.io.Reader rdr)
          Unmarshal document from reader to object.
 java.lang.Object unmarshalDocument(java.io.Reader rdr, java.lang.String name)
          Unmarshal named document from reader to object.
 java.lang.Object unmarshalElement()
          Unmarshal required element.
 java.lang.Object unmarshalElement(java.lang.Class clas)
          Unmarshal required element of specified type.
 java.lang.Object unmarshalOptionalElement()
          Unmarshal optional element.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnmarshallingContext

public UnmarshallingContext(int nmap,
                            java.lang.String[] umcs,
                            java.lang.String[] nss,
                            java.lang.String[] names,
                            java.lang.String[] idcs,
                            IBindingFactory ifact)
Constructor. Builds the actual parser and initializes internal data structures.

Parameters:
nmap - number of mapping definitions included
umcs - 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 definitions
names - names for elements of classes with global definitions
idcs - array of class names with IDs (null if 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 java.lang.String buildNameString(java.lang.String ns,
                                               java.lang.String name)
Build name with optional namespace. Just returns the appropriate name format.

Parameters:
ns - namespace URI of name
name - local name part of name
Returns:
formatted name string

currentNameString

public java.lang.String currentNameString()
Build current element name, with optional namespace.

Returns:
formatted name string

buildPositionString

public java.lang.String buildPositionString()
Build current parse input position description.

Returns:
text description of current parse position

throwStartTagNameError

public void throwStartTagNameError(java.lang.String ns,
                                   java.lang.String name)
                            throws JiBXException
Throw exception for expected element start tag not found.

Parameters:
ns - namespace URI of name
name - local name part of name
Throws:
JiBXException - always thrown

throwEndTagNameError

public void throwEndTagNameError(java.lang.String ns,
                                 java.lang.String name)
                          throws JiBXException
Throw exception for expected element end tag not found.

Parameters:
ns - namespace URI of name
name - local name part of name
Throws:
JiBXException - always thrown

throwNameException

public void throwNameException(java.lang.String msg,
                               java.lang.String ns,
                               java.lang.String name)
                        throws JiBXException
Throw exception including a name and position information.

Parameters:
msg - leading message text
ns - namespace URI of name
name - local name part of name
Throws:
JiBXException - always thrown

setDocument

public void setDocument(java.io.InputStream ins,
                        java.lang.String name,
                        java.lang.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 data
name - document name (null if unknown)
enc - document input encoding, or null if to be determined by parser
nsa - enable namespace processing for parser flag
Throws:
JiBXException - if error creating parser

setDocument

public void setDocument(java.io.InputStream ins,
                        java.lang.String enc)
                 throws JiBXException
Set document to be parsed from stream.

Specified by:
setDocument in interface IUnmarshallingContext
Parameters:
ins - stream supplying document data
enc - document input encoding, or null if to be determined by parser
Throws:
JiBXException - if error creating parser

setDocument

public void setDocument(java.io.Reader rdr,
                        java.lang.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 data
name - document name (null if unknown)
nsa - enable namespace processing for parser flag
Throws:
JiBXException - if error creating parser

setDocument

public void setDocument(java.io.Reader rdr)
                 throws JiBXException
Set document to be parsed from reader.

Specified by:
setDocument in interface IUnmarshallingContext
Parameters:
rdr - reader supplying document data
Throws:
JiBXException - if error creating parser

setDocument

public void setDocument(java.io.InputStream ins,
                        java.lang.String name,
                        java.lang.String enc)
                 throws JiBXException
Set named document to be parsed from stream.

Specified by:
setDocument in interface IUnmarshallingContext
Parameters:
ins - stream supplying document data
name - document name
enc - document input encoding, or null if to be determined by parser
Throws:
JiBXException - if error creating parser

setDocument

public void setDocument(java.io.Reader rdr,
                        java.lang.String name)
                 throws JiBXException
Set named document to be parsed from reader.

Specified by:
setDocument in interface IUnmarshallingContext
Parameters:
rdr - reader supplying document data
name - 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:
reset in interface IUnmarshallingContext

toStart

public java.lang.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 java.lang.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 JiBXException
Parse 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(java.lang.String ns,
                    java.lang.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:
isAt in interface IUnmarshallingContext
Parameters:
ns - namespace URI for expected element (may be null or the empty string for the empty namespace)
name - element name expected
Returns:
true if at start of element with supplied name, false if not
Throws:
JiBXException - on any error (possibly wrapping other exception)

hasAttribute

public boolean hasAttribute(java.lang.String ns,
                            java.lang.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 be null or the empty string for the empty namespace)
name - attribute name expected
Returns:
true if named attribute is present, false if not
Throws:
JiBXException - on any error (possibly wrapping other exception)

hasAnyAttribute

public boolean hasAnyAttribute(java.lang.String[] nss,
                               java.lang.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 be null or the empty string for the empty namespace)
names - attribute names expected
Returns:
true if at least one of the named attributes is present, false if not
Throws:
JiBXException - on any error (possibly wrapping other exception)

checkAllowedAttributes

public void checkAllowedAttributes(java.lang.String[] nss,
                                   java.lang.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 be null or 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(java.lang.String ns,
                            java.lang.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 be null or the empty string for the empty namespace)
name - element name expected
Throws:
JiBXException - on any error (possibly wrapping other exception)

parsePastStartTag

public void parsePastStartTag(java.lang.String ns,
                              java.lang.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 be null or the empty string for the empty namespace)
name - element name expected
Throws:
JiBXException - on any error (possibly wrapping other exception)

parseIfStartTag

public boolean parseIfStartTag(java.lang.String ns,
                               java.lang.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 be null or the empty string for the empty namespace)
name - element name expected
Returns:
true if start tag found, false if not
Throws:
JiBXException - on any error (possibly wrapping other exception)

parsePastCurrentEndTag

public void parsePastCurrentEndTag(java.lang.String ns,
                                   java.lang.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 be null or the empty string for the empty namespace)
name - element name expected
Throws:
JiBXException - on any error (possibly wrapping other exception)

parsePastEndTag

public void parsePastEndTag(java.lang.String ns,
                            java.lang.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 be null or 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 JiBXException
Check 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:
isStart in interface IUnmarshallingContext
Returns:
true if at start of element, false if at end
Throws:
JiBXException - on any error (possibly wrapping other exception)

isEnd

public boolean isEnd()
              throws JiBXException
Check 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:
isEnd in interface IUnmarshallingContext
Returns:
true if at end of element, false if at start
Throws:
JiBXException - on any error (possibly wrapping other exception)

accumulateText

public java.lang.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 java.lang.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 java.lang.String parseContentText(java.lang.String ns,
                                         java.lang.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 be null or 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(java.lang.String ns,
                           java.lang.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 be null or 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 java.lang.String parseElementText(java.lang.String ns,
                                         java.lang.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 be null or 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 java.lang.String parseElementText(java.lang.String ns,
                                         java.lang.String tag,
                                         java.lang.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 be null or the empty string for the empty namespace)
tag - element name expected
dflt - default text value
Returns:
content text from element
Throws:
JiBXException - on any error (possible wrapping other exception)

attributeText

public java.lang.String attributeText(java.lang.String ns,
                                      java.lang.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 be null or the empty string for the empty namespace)
name - attribute name expected
Returns:
attribute value text
Throws:
JiBXException - if attribute not present

attributeText

public java.lang.String attributeText(java.lang.String ns,
                                      java.lang.String name,
                                      java.lang.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 be null or the empty string for the empty namespace)
name - attribute name expected
dflt - value to be returned if attribute is not present
Returns:
attribute value text

findID

public java.lang.Object findID(java.lang.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 text
index - expected reference type index
Returns:
object corresponding to IDREF, or null if not yet defined
Throws:
JiBXException - on any error

findDefinedID

public java.lang.Object findDefinedID(java.lang.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 text
index - expected reference type index
Returns:
object corresponding to IDREF
Throws:
JiBXException - on any error

parseElementForwardIDREF

public java.lang.Object parseElementForwardIDREF(java.lang.String ns,
                                                 java.lang.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 be null or the empty string for the empty namespace)
tag - attribute name expected
index - expected reference type index
Returns:
object corresponding to IDREF, or null if not yet defined
Throws:
JiBXException - on any error (possibly wrapping other exception)

attributeForwardIDREF

public java.lang.Object attributeForwardIDREF(java.lang.String ns,
                                              java.lang.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 be null or the empty string for the empty namespace)
name - attribute name expected
index - expected reference type index
Returns:
object corresponding to IDREF, or null if not yet defined
Throws:
JiBXException - if attribute not present, or ID mapped to a different type of object than expected

parseElementExistingIDREF

public java.lang.Object parseElementExistingIDREF(java.lang.String ns,
                                                  java.lang.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 be null or the empty string for the empty namespace)
tag - attribute name expected
index - 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 java.lang.Object attributeExistingIDREF(java.lang.String ns,
                                               java.lang.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 be null or the empty string for the empty namespace)
name - attribute name expected
index - 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(java.lang.String ns,
                        java.lang.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 be null or 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(java.lang.String ns,
                        java.lang.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 be null or the empty string for the empty namespace)
name - attribute name expected
dflt - 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(java.lang.String ns,
                           java.lang.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 be null or 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(java.lang.String ns,
                           java.lang.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 be null or the empty string for the empty namespace)
tag - element name expected
dflt - default value
Returns:
content text from element
Throws:
JiBXException - on any error (possibly wrapping other exception)

convertEnum

public int convertEnum(java.lang.String target,
                       java.lang.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 enumeration
enums - ordered array of texts included in enumeration
vals - array of values to be returned for corresponding text match positions (position returned directly if this is null)
Returns:
enumeration value for target text
Throws:
JiBXException - if target text not found in enumeration

convertEnum

public int convertEnum(java.lang.String target,
                       java.lang.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 is null.

Parameters:
target - text to be found in enumeration (may be null)
enums - ordered array of texts included in enumeration
vals - array of values to be returned for corresponding text match positions (position returned directly if this is null)
dflt - default value returned if target text is null
Returns:
enumeration value for target text
Throws:
JiBXException - if target text not found in enumeration

attributeEnumeration

public int attributeEnumeration(java.lang.String ns,
                                java.lang.String name,
                                java.lang.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.