JAXB
v0.21

javax.xml.bind
Class MarshallableObject

java.lang.Object
  |
  +--javax.xml.bind.ValidatableObject
        |
        +--javax.xml.bind.MarshallableObject
Direct Known Subclasses:
MarshallableRootElement, PCData

public abstract class MarshallableObject
extends ValidatableObject

Abstract base class for objects that can be marshalled and unmarshalled. The methods in this class, in conjunction with those in the Marshaller, Dispatcher, and Unmarshaller classes, define the processes of marshalling content trees into XML documents and vice-versa.

This class does not implement the Element interface because some schema-derived classes will be marshallable but will not be element classes.

Both marshalling and unmarshalling are optional operations because in some applications only one or the other operation is of interest. If a particular operation is not supported then an UnsupportedOperationException is thrown when the corresponding method is invoked.

Version:
1.9, 01/05/31
See Also:
Dispatcher, Marshaller, Unmarshaller, Validator

Constructor Summary
protected MarshallableObject()
          Initializes a new marshallable object.
 
Method Summary
 void marshal(Marshaller m)
          Marshals the content of this object, and its children, using the given marshaller (optional operation).
abstract  void unmarshal(Unmarshaller u)
          Unmarshals an element or some character data into this object, converting data as necessary, checking type constraints and local structural constraints, and recording the information required to check global structural constraints.
 
Methods inherited from class javax.xml.bind.ValidatableObject
invalidate, validate, validate, validateThis
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarshallableObject

protected MarshallableObject()
Initializes a new marshallable object.
Method Detail

marshal

public void marshal(Marshaller m)
             throws IOException
Marshals the content of this object, and its children, using the given marshaller (optional operation). Requires that the object be valid.

This method must use the given marshaller's XMLWriter to write the content of this object, and it must invoke the given marshaller's marshal(MarshallableObject) method to marshal any children.

As defined in this class, this method throws an UnsupportedOperationException; it should be overridden only by schema-derived classes. This method should only be invoked by the marshalling process; its behavior when invoked in any other manner is unspecified.

Parameters:
m - The marshaller to be used
Throws:
IOException - If an I/O error occurs
UnsupportedOperationException - If this object does not support marshalling

unmarshal

public abstract void unmarshal(Unmarshaller u)
                        throws UnmarshalException
Unmarshals an element or some character data into this object, converting data as necessary, checking type constraints and local structural constraints, and recording the information required to check global structural constraints.

This method must use the given unmarshaller's XMLScanner to parse the elements and attributes represented by this object. It must recursively invoke the given unmarshaller's unmarshal() and unmarshal(Class) methods to unmarshal any subelements. Finally, it must invoke the reference(String, Validator.Patcher) method of the marshaller's validator in order to arrange for the target of each identifier reference to be installed once the reference is resolved.

As defined in this class, this method throws an UnsupportedOperationException; it should be overridden only by schema-derived classes. This method should only be invoked by the unmarshalling process; its behavior when invoked in any other manner is unspecified.

Parameters:
u - The unmarshaller to be used
Throws:
ScanIOException - If an I/O error occurs
ScanException - If the source document is not well-formed
InvalidContentException - If the unmarshaller's scanner is not initially positioned at an appropriate start tag or at some character data, according to whether this object is to represent an element or character data, respectively; or if this object is to represent an element and the element's content specification as described in the source schema is violated
ValidationException - If a type or structural constraint is violated by the input document

JAXB
v0.21


Comments to: jaxb-comments@java.sun.com
More information at: http://java.sun.com/xml/jaxb

Copyright © 2001 by Sun Microsystems, Inc., 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.