| org.jibx.runtime.IMarshallingContext
All known Subclasses: org.jibx.runtime.impl.MarshallingContext,
IMarshallingContext | public interface IMarshallingContext (Code) | | User interface for serializer to XML. This provides methods used to set up
and control the marshalling process, as well as access to the marshalling
object stack while marshalling.
author: Dennis M. Sosnoski |
Method Summary | |
void | endDocument() End document. | int | getIndent() Get current nesting indent spaces. | public IMarshaller | getMarshaller(int index, String name) Find the marshaller for a particular class index
in the current context. | public int | getStackDepth() Get current marshalling object stack depth. | public Object | getStackObject(int depth) Get object from marshalling stack. | public Object | getStackTop() Get top object on marshalling stack. | public Object | getUserContext() Get the user context object. | IXMLWriter | getXmlWriter() Get the writer being used for output. | public void | marshalDocument(Object root) Marshal document from root object without XML declaration. | public void | marshalDocument(Object root, String enc, Boolean alone) Marshal document from root object. | public void | marshalDocument(Object root, String enc, Boolean alone, OutputStream outs) Marshal document from root object to output stream with encoding. | public void | marshalDocument(Object root, String enc, Boolean alone, Writer outw) Marshal document from root object to writer. | public void | popObject() Pop marshalled object from stack. | public void | pushObject(Object obj) Push created object to marshalling stack. | void | reset() Reset to initial state for reuse. | void | setIndent(int count) Set nesting indent spaces. | public void | setIndent(int count, String newline, char indent) Set nesting indentation. | void | setOutput(OutputStream outs, String enc, ICharacterEscaper esc) Set output stream with encoding and escaper. | void | setOutput(OutputStream outs, String enc) Set output stream and encoding. | void | setOutput(Writer outw, ICharacterEscaper esc) Set output writer and escaper. | void | setOutput(Writer outw) Set output writer. | public void | setUserContext(Object obj) Set a user context object. | void | setXmlWriter(IXMLWriter xwrite) Set the writer being used for output. | void | startDocument(String enc, Boolean alone) Start document, writing the XML declaration. | void | startDocument(String enc, Boolean alone, OutputStream outs) Start document with output stream and encoding. | void | startDocument(String enc, Boolean alone, Writer outw) Start document with writer. |
endDocument | void endDocument() throws JiBXException(Code) | | 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.
throws: JiBXException - on any error (possibly wrapping other exception) |
getIndent | int getIndent()(Code) | | Get current nesting indent spaces. This returns the number of spaces used
to show indenting, if used.
number of spaces indented per level, or negative if indentationdisabled |
getMarshaller | public IMarshaller getMarshaller(int index, String name) throws JiBXException(Code) | | Find the marshaller for a particular class index
in the current context.
Parameters: index - class index for marshalling definition Parameters: name - fully qualified name of class to be marshalled (used onlyfor validation) marshalling handler for class throws: JiBXException - on any error (possibly wrapping other exception) |
getStackDepth | public int getStackDepth()(Code) | | 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
of the marshalling.
number of objects in marshalling stack |
getStackObject | public Object getStackObject(int depth)(Code) | | 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
of the marshalling.
Parameters: depth - object depth in stack to be retrieved (must be in the rangeof zero to the current depth minus one). object from marshalling stack |
getStackTop | public Object getStackTop()(Code) | | Get top object on marshalling stack. This is safe to call even when no
objects are on the stack.
object from marshalling stack, or null if none |
getXmlWriter | IXMLWriter getXmlWriter()(Code) | | Get the writer being used for output.
XML writer used for output |
marshalDocument | public void marshalDocument(Object root) throws JiBXException(Code) | | 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
IMarshallingContext.endDocument .
Parameters: root - object at root of structure to be marshalled, which must havea top-level mapping in the binding throws: JiBXException - on any error (possibly wrapping other exception) |
marshalDocument | public void marshalDocument(Object root, String enc, Boolean alone) throws JiBXException(Code) | | 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
IMarshallingContext.startDocument , a call to marshal the root
object using this context, and finally a call to
IMarshallingContext.endDocument .
Parameters: root - object at root of structure to be marshalled, which must havea top-level mapping in the binding Parameters: enc - document encoding, null uses UTF-8 default Parameters: alone - standalone document flag, null if notspecified throws: JiBXException - on any error (possibly wrapping other exception) |
marshalDocument | public void marshalDocument(Object root, String enc, Boolean alone, OutputStream outs) throws JiBXException(Code) | | 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
IMarshallingContext.startDocument , a call to marshal the root object using this context,
and finally a call to
IMarshallingContext.endDocument .
Parameters: root - object at root of structure to be marshalled, which must havea top-level mapping in the binding Parameters: enc - document encoding, null uses UTF-8 default Parameters: alone - standalone document flag, null if notspecified Parameters: outs - stream for document data output throws: JiBXException - on any error (possibly wrapping other exception) |
marshalDocument | public void marshalDocument(Object root, String enc, Boolean alone, Writer outw) throws JiBXException(Code) | | Marshal document from root object to writer. The effect of this method
is the same as the sequence of a call to
IMarshallingContext.startDocument , a call
to marshal the root object using this context, and finally a call to
IMarshallingContext.endDocument .
Parameters: root - object at root of structure to be marshalled, which must havea top-level mapping in the binding Parameters: enc - document encoding, null uses UTF-8 default Parameters: alone - standalone document flag, null if notspecified Parameters: outw - writer for document data output throws: JiBXException - on any error (possibly wrapping other exception) |
pushObject | public void pushObject(Object obj)(Code) | | 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.
Parameters: obj - object being marshalled |
reset | void reset()(Code) | | 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.
|
setIndent | void setIndent(int count)(Code) | | 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.
Parameters: count - number of spaces to indent per level, or disableindentation if negative |
setIndent | public void setIndent(int count, String newline, char indent)(Code) | | 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.
Parameters: count - number of character to indent per level, or disableindentation if negative (zero means new line only) Parameters: newline - sequence of characters used for a line ending(null means use the single character '\n') Parameters: indent - whitespace character used for indentation |
setOutput | void setOutput(OutputStream outs, String enc, ICharacterEscaper esc) throws JiBXException(Code) | | 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.
Parameters: outs - stream for document data output Parameters: enc - document output encoding, or null uses UTF-8default Parameters: esc - escaper for writing characters to stream throws: JiBXException - if error setting output |
setOutput | void setOutput(OutputStream outs, String enc) throws JiBXException(Code) | | Set output stream and encoding.
Parameters: outs - stream for document data output Parameters: enc - document output encoding, or null uses UTF-8default throws: JiBXException - if error setting output |
setOutput | void setOutput(Writer outw, ICharacterEscaper esc)(Code) | | Set output writer and escaper.
Parameters: outw - writer for document data output Parameters: esc - escaper for writing characters |
setOutput | void setOutput(Writer outw)(Code) | | Set output writer. This assumes the standard UTF-8 encoding.
Parameters: outw - writer for document data output |
setUserContext | public void setUserContext(Object obj)(Code) | | 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
IMarshallingContext.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).
Parameters: obj - user context object, or null if clearing existingcontext object See Also: IMarshallingContext.getUserContext() |
setXmlWriter | void setXmlWriter(IXMLWriter xwrite)(Code) | | Set the writer being used for output.
Parameters: xwrite - XML writer used for output |
startDocument | void startDocument(String enc, Boolean alone) throws JiBXException(Code) | | Start document, writing the XML declaration. This can only be validly
called immediately following one of the set output methods; otherwise the
output document will be corrupt.
Parameters: enc - document encoding, null uses UTF-8 default Parameters: alone - standalone document flag, null if notspecified throws: JiBXException - on any error (possibly wrapping other exception) |
startDocument | void startDocument(String enc, Boolean alone, OutputStream outs) throws JiBXException(Code) | | 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.
Parameters: enc - document encoding, null uses UTF-8 default Parameters: alone - standalone document flag, null if notspecified Parameters: outs - stream for document data output throws: JiBXException - on any error (possibly wrapping other exception) |
startDocument | void startDocument(String enc, Boolean alone, Writer outw) throws JiBXException(Code) | | Start document with writer. The effect is the same as from first
setting the writer, then making the call to start document.
Parameters: enc - document encoding, null uses UTF-8 default Parameters: alone - standalone document flag, null if notspecified Parameters: outw - writer for document data output throws: JiBXException - on any error (possibly wrapping other exception) |
|
|