MarshallingContext (JiBX Java data binding to XML - Version 1.1.6a)
Date: 2008-06-08

Overview | Package | Class | Deprecated
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jibx.runtime.impl
Class MarshallingContext

    java.lang.Object
      org.jibx.runtime.impl.MarshallingContext

All Implemented Interfaces:
  IMarshallingContext

    public class MarshallingContext

extends java.lang.Object
implements IMarshallingContext

JiBX serializer supplying convenience methods for marshalling. Most of these methods are designed for use in code generated by the binding generator.

Author:
  Dennis M. Sosnoski

Field Summary
`static java.lang.String` | `XML_NAMESPACE` Fixed XML namespace.

Constructor Summary
`MarshallingContext(java.lang.String[] classes, java.lang.String[] mcs, java.lang.String[] uris, IBindingFactory ifact)` Constructor.

Method Summary
`void` | `addMarshalling(int index, java.lang.String name)` Define marshalling for class.
`MarshallingContext` | `attribute(int index, java.lang.String name, int value)` Generate integer attribute.
`MarshallingContext` | `attribute(int index, java.lang.String name, int value, java.lang.String[] table)` Generate enumeration attribute.
`MarshallingContext` | `attribute(int index, java.lang.String name, java.lang.String value)` Generate text attribute.
`java.lang.String` | `buildNameString(int index, java.lang.String name)` Build name with optional namespace.
`MarshallingContext` | `closeStartContent()` Close start tag with content to follow.
`MarshallingContext` | `closeStartEmpty()` Close start tag with no content (empty tag).
`MarshallingContext` | `content(int value)` Add integer content to current element.
`MarshallingContext` | `content(int value, java.lang.String[] table)` Add enumeration content to current element.
`MarshallingContext` | `content(java.lang.String value)` Add text content to current element.
`MarshallingContext` | `element(int index, java.lang.String name, int value)` Generate complete element with integer content.
`MarshallingContext` | `element(int index, java.lang.String name, int value, java.lang.String[] table)` Generate complete element with enumeration content.
`MarshallingContext` | `element(int index, java.lang.String name, java.lang.String value)` Generate complete element with text content.
`void` | `endDocument()` End document.
`MarshallingContext` | `endTag(int index, java.lang.String name)` Generate end tag for element.
`IBindingFactory` | `getFactory()` Return the binding factory used to create this unmarshaller.
`java.util.HashMap` | `getIdMap()` Get shared ID map.
`int` | `getIndent()` Get current nesting indent spaces.
`IMarshaller` | `getMarshaller(int index, java.lang.String name)` Find the marshaller for a particular class index in the current context.
`java.lang.String[]` | `getNamespaces()` Get namespace URIs for mapping.
`int` | `getStackDepth()` Get current marshalling object stack depth.
`java.lang.Object` | `getStackObject(int depth)` Get object from marshalling stack.
`java.lang.Object` | `getStackTop()` Get top object on marshalling stack.
`java.lang.Object` | `getUserContext()` Get the user context object.
`IXMLWriter` | `getXmlWriter()` Get the writer being used for output.
`MarshallingContext` | `marshalCollection(java.util.ArrayList col)` Marshal all items in a collection.
`MarshallingContext` | `marshalCollection(java.util.Collection col)` Marshal all items in a collection.
`MarshallingContext` | `marshalCollection(java.util.Vector col)` Marshal all items in a collection.
`void` | `marshalDocument(java.lang.Object root)` Marshal document from root object without XML declaration.
`void` | `marshalDocument(java.lang.Object root, java.lang.String enc, java.lang.Boolean alone)` Marshal document from root object.
`void` | `marshalDocument(java.lang.Object root, java.lang.String enc, java.lang.Boolean alone, java.io.OutputStream outs)` Marshal document from root object to output stream with encoding.
`void` | `marshalDocument(java.lang.Object root, java.lang.String enc, java.lang.Boolean alone, java.io.Writer outw)` Marshal document from root object to writer.
`void` | `popObject()` Pop marshalled object from stack.
`void` | `pushObject(java.lang.Object obj)` Push created object to marshalling stack.
`void` | `removeMarshalling(int index)` Undefine marshalling for element.
`void` | `reset()` Reset to initial state for reuse.
`void` | `setFromContext(MarshallingContext parent)` Initializes the context to use the same marshalled text destination and parameters as another marshalling context.
`void` | `setIndent(int count)` Set nesting indent spaces.
`void` | `setIndent(int count, java.lang.String newline, char indent)` Set nesting indentation.
`void` | `setOutput(java.io.OutputStream outs, java.lang.String enc)` Set output stream and encoding.
`void` | `setOutput(java.io.OutputStream outs, java.lang.String enc, ICharacterEscaper esc)` Set output stream with encoding and escaper.
`void` | `setOutput(java.io.Writer outw)` Set output writer.
`void` | `setOutput(java.io.Writer outw, ICharacterEscaper esc)` Set output writer and escaper.
`void` | `setUserContext(java.lang.Object obj)` Set a user context object.
`void` | `setXmlWriter(IXMLWriter xwrite)` Set the writer being used for output.
`void` | `startDocument(java.lang.String enc, java.lang.Boolean alone)` Start document.
`void` | `startDocument(java.lang.String enc, java.lang.Boolean alone, java.io.OutputStream outs)` Start document with output stream and encoding.
`void` | `startDocument(java.lang.String enc, java.lang.Boolean alone, java.io.Writer outw)` Start document with writer.
`MarshallingContext` | `startTag(int index, java.lang.String name)` Generate start tag for element without attributes.
`MarshallingContext` | `startTagAttributes(int index, java.lang.String name)` Generate start tag for element with attributes.
`MarshallingContext` | `startTagNamespaces(int index, java.lang.String name, int[] nums, java.lang.String[] prefs)` Generate start tag for element with namespaces.
`MarshallingContext` | `writeCData(java.lang.String text)` Write CDATA text to document.
`MarshallingContext` | `writeContent(java.lang.String text)` Write content value with character entity substitutions.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### XML_NAMESPACE

    public static final java.lang.String XML_NAMESPACE

  Fixed XML namespace.

  See Also:
    Constant Field Values

Constructor Detail

### MarshallingContext

    public MarshallingContext(java.lang.String[] classes,
                              java.lang.String[] mcs,
                              java.lang.String[] uris,
                              IBindingFactory ifact)

  Constructor.

  Parameters:
    `classes` - ordered array of class names included in mapping definition (reference kept, must be constant)
    `mcs` - names of marshaller classes for indexes with fixed marshallers (as opposed to mapping slots, which may be overridden; reference kept, must be constant)
    `uris` - ordered array of URIs for namespaces used in binding (must be constant; the value in position 0 must always be the empty string "", and the value in position 1 must always be the XML namespace "http://www.w3.org/XML/1998/namespace")
    `ifact` - binding factory creating this unmarshaller

Method Detail

### setOutput

    public void setOutput(java.io.OutputStream outs,
                          java.lang.String enc,
                          ICharacterEscaper esc)
                   throws JiBXException

  Set output stream with encoding and escaper. This forces handling of the output stream to use the Java character encoding support with the supplied escaper.

  Specified by:
    `setOutput` in interface `IMarshallingContext`
  Parameters:
    `outs` - stream for document data output
    `enc` - document output encoding, or `null` uses UTF-8 default
    `esc` - escaper for writing characters to stream
  Throws:
    `JiBXException` - if error setting output

### setOutput

    public void setOutput(java.io.OutputStream outs,
                          java.lang.String enc)
                   throws JiBXException

  Set output stream and encoding.

  Specified by:
    `setOutput` in interface `IMarshallingContext`
  Parameters:
    `outs` - stream for document data output
    `enc` - document output encoding, or `null` for default
  Throws:
    `JiBXException` - if error creating setting output

### setOutput

    public void setOutput(java.io.Writer outw,
                          ICharacterEscaper esc)

  Set output writer and escaper.

  Specified by:
    `setOutput` in interface `IMarshallingContext`
  Parameters:
    `outw` - writer for document data output
    `esc` - escaper for writing characters

### setOutput

    public void setOutput(java.io.Writer outw)

  Set output writer.

  Specified by:
    `setOutput` in interface `IMarshallingContext`
  Parameters:
    `outw` - writer for document data output

### getXmlWriter

    public IXMLWriter getXmlWriter()

  Get the writer being used for output.

  Specified by:
    `getXmlWriter` in interface `IMarshallingContext`
  Returns:
    XML writer used for output

### setXmlWriter

    public void setXmlWriter(IXMLWriter xwrite)

  Set the writer being used for output.

  Specified by:
    `setXmlWriter` in interface `IMarshallingContext`
  Parameters:
    `xwrite` - XML writer used for output

### getIndent

    public int getIndent()

  Get current nesting indent spaces. This returns the number of spaces used to show indenting, if used.

  Specified by:
    `getIndent` in interface `IMarshallingContext`
  Returns:
    number of spaces indented per level, or negative if indentation disabled

### setIndent

    public void setIndent(int count)

  Set nesting indent spaces. This is advisory only, and implementations of this interface are free to ignore it. The intent is to indicate that the generated output should use indenting to illustrate element nesting.

  Specified by:
    `setIndent` in interface `IMarshallingContext`
  Parameters:
    `count` - number of spaces to indent per level, or disable indentation if negative

### setIndent

    public void setIndent(int count,
                          java.lang.String newline,
                          char indent)

  Set nesting indentation. This is advisory only, and implementations of this interface are free to ignore it. The intent is to indicate that the generated output should use indenting to illustrate element nesting.

  Specified by:
    `setIndent` in interface `IMarshallingContext`
  Parameters:
    `count` - number of character to indent per level, or disable indentation if negative (zero means new line only)
    `newline` - sequence of characters used for a line ending (`null` means use the single character '\n')
    `indent` - whitespace character used for indentation

### setFromContext

    public void setFromContext(MarshallingContext parent)
                        throws java.io.IOException

  Initializes the context to use the same marshalled text destination and parameters as another marshalling context. This method is designed for use when an initial context needs to create and invoke a secondary context (generally from a different binding) in the course of an marshalling operation. Note that once the secondary context has been used it's generally necessary to do a `XMLWriterBase.flush()` operation on the writer used by the that context before resuming output on the parent.

  Parameters:
    `parent` - context supplying target for marshalled document text
  Throws:
    `java.io.IOException` - on error writing output

### reset

    public void reset()

  Reset to initial state for reuse. The context is serially reusable, as long as this method is called to clear any retained state information between uses. It is automatically called when output is set.

  Specified by:
    `reset` in interface `IMarshallingContext`

### getFactory

    public IBindingFactory getFactory()

  Return the binding factory used to create this unmarshaller.

  Returns:
    binding factory

### getNamespaces

    public java.lang.String[] getNamespaces()

  Get namespace URIs for mapping. This gets the full ordered array of namespaces known in the binding used for this marshalling, where the index number of each namespace URI is the namespace index used to lookup the prefix when marshalling a name in that namespace. The returned array must not be modified.

  Returns:
    array of namespaces

### startDocument

    public void startDocument(java.lang.String enc,
                              java.lang.Boolean alone)
                       throws JiBXException

  Start document. This can only be validly called immediately following one of the set output methods; otherwise the output document will be corrupt.

  Specified by:
    `startDocument` in interface `IMarshallingContext`
  Parameters:
    `enc` - document encoding, `null` if not specified
    `alone` - standalone document flag, `null` if not specified
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### startDocument

    public void startDocument(java.lang.String enc,
                              java.lang.Boolean alone,
                              java.io.OutputStream outs)
                       throws JiBXException

  Start document with output stream and encoding. The effect is the same as from first setting the output stream and encoding, then making the call to start document.

  Specified by:
    `startDocument` in interface `IMarshallingContext`
  Parameters:
    `enc` - document encoding, `null` if not specified
    `alone` - standalone document flag, `null` if not specified
    `outs` - stream for document data output
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### startDocument

    public void startDocument(java.lang.String enc,
                              java.lang.Boolean alone,
                              java.io.Writer outw)
                       throws JiBXException

  Start document with writer. The effect is the same as from first setting the writer, then making the call to start document.

  Specified by:
    `startDocument` in interface `IMarshallingContext`
  Parameters:
    `enc` - document encoding, `null` if not specified
    `alone` - standalone document flag, `null` if not specified
    `outw` - writer for document data output
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### endDocument

    public void endDocument()
                     throws JiBXException

  End document. Finishes all output and closes the document. Note that if this is called with an imcomplete marshalling the result will not be well-formed XML.

  Specified by:
    `endDocument` in interface `IMarshallingContext`
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### buildNameString

    public java.lang.String buildNameString(int index,
                                            java.lang.String name)

  Build name with optional namespace. Just returns the appropriate name format.

  Parameters:
    `index` - namespace URI index number
    `name` - local name part of name
  Returns:
    formatted name string

### startTag

    public MarshallingContext startTag(int index,
                                       java.lang.String name)
                                throws JiBXException

  Generate start tag for element without attributes.

  Parameters:
    `index` - namespace URI index number
    `name` - element name
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### startTagAttributes

    public MarshallingContext startTagAttributes(int index,
                                                 java.lang.String name)
                                          throws JiBXException

  Generate start tag for element with attributes. This only opens the start tag, allowing attributes to be added immediately following this call.

  Parameters:
    `index` - namespace URI index number
    `name` - element name
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### attribute

    public MarshallingContext attribute(int index,
                                        java.lang.String name,
                                        java.lang.String value)
                                 throws JiBXException

  Generate text attribute. This can only be used following an open start tag with attributes.

  Parameters:
    `index` - namespace URI index number
    `name` - attribute name
    `value` - text value for attribute (cannot be `null`)
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### attribute

    public MarshallingContext attribute(int index,
                                        java.lang.String name,
                                        int value)
                                 throws JiBXException

  Generate integer attribute. This can only be used following an open start tag.

  Parameters:
    `index` - namespace URI index number
    `name` - attribute name
    `value` - integer value for attribute
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### attribute

    public MarshallingContext attribute(int index,
                                        java.lang.String name,
                                        int value,
                                        java.lang.String[] table)
                                 throws JiBXException

  Generate enumeration attribute. The actual text to be written is obtained by indexing into the supplied array of values. This can only be used following an open start tag.

  Parameters:
    `index` - namespace URI index number
    `name` - attribute name
    `value` - integer enumeration value (zero-based)
    `table` - text values in enumeration
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### closeStartContent

    public MarshallingContext closeStartContent()
                                         throws JiBXException

  Close start tag with content to follow.

  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### closeStartEmpty

    public MarshallingContext closeStartEmpty()
                                       throws JiBXException

  Close start tag with no content (empty tag).

  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### content

    public MarshallingContext content(java.lang.String value)
                               throws JiBXException

  Add text content to current element.

  Parameters:
    `value` - text element content
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### content

    public MarshallingContext content(int value)
                               throws JiBXException

  Add integer content to current element.

  Parameters:
    `value` - integer element content
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### content

    public MarshallingContext content(int value,
                                      java.lang.String[] table)
                               throws JiBXException

  Add enumeration content to current element. The actual text to be written is obtained by indexing into the supplied array of values.

  Parameters:
    `value` - integer enumeration value (zero-based)
    `table` - text values in enumeration
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### endTag

    public MarshallingContext endTag(int index,
                                     java.lang.String name)
                              throws JiBXException

  Generate end tag for element.

  Parameters:
    `index` - namespace URI index number
    `name` - element name
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### element

    public MarshallingContext element(int index,
                                      java.lang.String name,
                                      java.lang.String value)
                               throws JiBXException

  Generate complete element with text content.

  Parameters:
    `index` - namespace URI index number
    `name` - element name
    `value` - text element content
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### element

    public MarshallingContext element(int index,
                                      java.lang.String name,
                                      int value)
                               throws JiBXException

  Generate complete element with integer content.

  Parameters:
    `index` - namespace URI index number
    `name` - element name
    `value` - integer element content
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### element

    public MarshallingContext element(int index,
                                      java.lang.String name,
                                      int value,
                                      java.lang.String[] table)
                               throws JiBXException

  Generate complete element with enumeration content. The actual text to be written is obtained by indexing into the supplied array of values.

  Parameters:
    `index` - namespace URI index number
    `name` - element name
    `value` - integer enumeration value (zero-based)
    `table` - text values in enumeration
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### writeCData

    public MarshallingContext writeCData(java.lang.String text)
                                  throws java.io.IOException

  Write CDATA text to document.

  Parameters:
    `text` - content value text
  Returns:
    this context (to allow chained calls)
  Throws:
    `java.io.IOException` - on error writing to document

### writeContent

    public MarshallingContext writeContent(java.lang.String text)
                                    throws java.io.IOException

  Write content value with character entity substitutions.

  Parameters:
    `text` - content value text
  Returns:
    this context (to allow chained calls)
  Throws:
    `java.io.IOException` - on error writing to document

### marshalCollection

    public MarshallingContext marshalCollection(java.util.Collection col)
                                         throws JiBXException

  Marshal all items in a collection. This variation is for generic collections.

  Parameters:
    `col` - collection of items to be marshalled
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### marshalCollection

    public MarshallingContext marshalCollection(java.util.ArrayList col)
                                         throws JiBXException

  Marshal all items in a collection. This variation is for ArrayList collections.

  Parameters:
    `col` - collection of items to be marshalled
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### marshalCollection

    public MarshallingContext marshalCollection(java.util.Vector col)
                                         throws JiBXException

  Marshal all items in a collection. This variation is for Vector collections.

  Parameters:
    `col` - collection of items to be marshalled
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### addMarshalling

    public void addMarshalling(int index,
                               java.lang.String name)

  Define marshalling for class. Adds the marshalling definition using fixed indexes for each class, allowing direct lookup of the marshaller when multiple versions are defined.

  Parameters:
    `index` - class index for marshalling definition
    `name` - marshaller class name handling

### removeMarshalling

    public void removeMarshalling(int index)

  Undefine marshalling for element. Removes the marshalling definition for a particular class index.

  Parameters:
    `index` - class index for marshalling definition

### startTagNamespaces

    public MarshallingContext startTagNamespaces(int index,
                                                 java.lang.String name,
                                                 int[] nums,
                                                 java.lang.String[] prefs)
                                          throws JiBXException

  Generate start tag for element with namespaces. This creates the actual start tag, along with any necessary namespace declarations. Previously active namespace declarations are not duplicated. The tag is left incomplete, allowing other attributes to be added. TODO: Handle nested default namespaces declarations, prefixes for outers

  Parameters:
    `index` - namespace URI index number
    `name` - element name
    `nums` - array of namespace indexes defined by this element (must be constant, reference is kept until end of element)
    `prefs` - array of namespace prefixes mapped by this element (no `null` values, use "" for default namespace declaration)
  Returns:
    this context (to allow chained calls)
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### getMarshaller

    public IMarshaller getMarshaller(int index,
                                     java.lang.String name)
                              throws JiBXException

  Find the marshaller for a particular class index in the current context. TODO: Eliminate the string passing, since it's not a common enough problem to be worth checking (and with abstract mappings can be really difficult to set properly)

  Specified by:
    `getMarshaller` in interface `IMarshallingContext`
  Parameters:
    `index` - class index for marshalling definition
    `name` - fully qualified name of class to be marshalled (used only for validation)
  Returns:
    marshalling handler for class
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### marshalDocument

    public void marshalDocument(java.lang.Object root)
                         throws JiBXException

  Marshal document from root object without XML declaration. This can only be validly called immediately following one of the set output methods; otherwise the output document will be corrupt. The effect of this method is the same as the sequence of a call to marshal the root object using this context followed by a call to `endDocument()`.

  Specified by:
    `marshalDocument` in interface `IMarshallingContext`
  Parameters:
    `root` - object at root of structure to be marshalled, which must have a top-level mapping in the binding
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### marshalDocument

    public void marshalDocument(java.lang.Object root,
                                java.lang.String enc,
                                java.lang.Boolean alone)
                         throws JiBXException

  Marshal document from root object. This can only be validly called immediately following one of the set output methods; otherwise the output document will be corrupt. The effect of this method is the same as the sequence of a call to `startDocument(java.lang.String, java.lang.Boolean)`, a call to marshal the root object using this context, and finally a call to `endDocument()`.

  Specified by:
    `marshalDocument` in interface `IMarshallingContext`
  Parameters:
    `root` - object at root of structure to be marshalled, which must have a top-level mapping in the binding
    `enc` - document encoding, `null` if not specified
    `alone` - standalone document flag, `null` if not specified
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### marshalDocument

    public void marshalDocument(java.lang.Object root,
                                java.lang.String enc,
                                java.lang.Boolean alone,
                                java.io.OutputStream outs)
                         throws JiBXException

  Marshal document from root object to output stream with encoding. The effect of this method is the same as the sequence of a call to `startDocument(java.lang.String, java.lang.Boolean)`, a call to marshal the root object using this context, and finally a call to `endDocument()`.

  Specified by:
    `marshalDocument` in interface `IMarshallingContext`
  Parameters:
    `root` - object at root of structure to be marshalled, which must have a top-level mapping in the binding
    `enc` - document encoding, `null` if not specified
    `alone` - standalone document flag, `null` if not specified
    `outs` - stream for document data output
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### marshalDocument

    public void marshalDocument(java.lang.Object root,
                                java.lang.String enc,
                                java.lang.Boolean alone,
                                java.io.Writer outw)
                         throws JiBXException

  Marshal document from root object to writer. The effect of this method is the same as the sequence of a call to `startDocument(java.lang.String, java.lang.Boolean)`, a call to marshal the root object using this context, and finally a call to `endDocument()`.

  Specified by:
    `marshalDocument` in interface `IMarshallingContext`
  Parameters:
    `root` - object at root of structure to be marshalled, which must have a top-level mapping in the binding
    `enc` - document encoding, `null` if not specified
    `alone` - standalone document flag, `null` if not specified
    `outw` - writer for document data output
  Throws:
    `JiBXException` - on any error (possibly wrapping other exception)

### getIdMap

    public java.util.HashMap getIdMap()

  Get shared ID map. The ID map returned is not used directly by the marshalling code, but is provided to support user extensions.

  Returns:
    ID map

### setUserContext

    public void setUserContext(java.lang.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 the `reset()` method, so to make use of this you need to first call the appropriate version of the `setOutput()` method, then this method, and finally one of the `marshalDocument` methods which uses the previously-set output (not the ones which take a stream or writer as parameter, since they call `setOutput()` themselves).

  Specified by:
    `setUserContext` in interface `IMarshallingContext`
  Parameters:
    `obj` - user context object, or `null` if clearing existing context object
  See Also:
    `getUserContext()`

### getUserContext

    public java.lang.Object getUserContext()

  Get the user context object.

  Specified by:
    `getUserContext` in interface `IMarshallingContext`
  Returns:
    user context object, or `null` if no context object set
  See Also:
    `setUserContext(Object)`

### pushObject

    public void pushObject(java.lang.Object obj)

  Push created object to marshalling stack. This must be called before beginning the marshalling of the object. It is only called for objects with structure, not for those converted directly to and from text.

  Specified by:
    `pushObject` in interface `IMarshallingContext`
  Parameters:
    `obj` - object being marshalled

### popObject

    public void popObject()
                   throws JiBXException

  Pop marshalled object from stack.

  Specified by:
    `popObject` in interface `IMarshallingContext`
  Throws:
    `JiBXException` - if no object on stack

### getStackDepth

    public int getStackDepth()

  Get current marshalling object stack depth. This allows tracking nested calls to marshal one object while in the process of marshalling another object. The bottom item on the stack is always the root object being marshalled.

  Specified by:
    `getStackDepth` in interface `IMarshallingContext`
  Returns:
    number of objects in marshalling stack

### getStackObject

    public java.lang.Object getStackObject(int depth)

  Get object from marshalling stack. This stack allows tracking nested calls to marshal one object while in the process of marshalling another object. The bottom item on the stack is always the root object being marshalled.

  Specified by:
    `getStackObject` in interface `IMarshallingContext`
  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 marshalling stack

### getStackTop

    public java.lang.Object getStackTop()

  Get top object on marshalling stack. This is safe to call even when no objects are on the stack.

  Specified by:
    `getStackTop` in interface `IMarshallingContext`
  Returns:
    object from marshalling stack, or `null` if none

Overview | Package | Class | Deprecated
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Project Web Site |