Overview | Package | Class | Tree | Deprecated | Index | Help
| JAXB v1.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.xml.bind.helpers
Class AbstractMarshallerImpl

    java.lang.Object
      |
      +--javax.xml.bind.helpers.AbstractMarshallerImpl

All Implemented Interfaces:
  Marshaller

public abstract class AbstractMarshallerImpl
extends java.lang.Object
implements Marshaller

Partial default `Marshaller` implementation.

This class provides a partial default implementation for the `Marshaller` interface.

The only method that a JAXB Provider has to implement is `marshal(Object, javax.xml.transform.Result)`.

Since:
  JAXB1.0
Version:
  $Revision: 1.1 $ $Date: 2008/11/03 06:51:07 $
Author:
  - Kohsuke Kawaguchi, Sun Microsystems, Inc.
See Also:
  `Marshaller`

Field Summary

Fields inherited from interface javax.xml.bind.Marshaller
`JAXB_ENCODING, JAXB_FORMATTED_OUTPUT, JAXB_NO_NAMESPACE_SCHEMA_LOCATION, JAXB_SCHEMA_LOCATION`

Constructor Summary
`AbstractMarshallerImpl()`

Method Summary
`protected java.lang.String` | `getEncoding()` Convenience method for getting the current output encoding.
`ValidationEventHandler` | `getEventHandler()` Return the current event handler or the default event handler if one hasn't been set.
`protected java.lang.String` | `getJavaEncoding(java.lang.String encoding)` Gets the corresponding Java encoding name from an IANA name.
`org.w3c.dom.Node` | `getNode(java.lang.Object obj)` By default, the getNode method is unsupported and throw an `UnsupportedOperationException`.
`protected java.lang.String` | `getNoNSSchemaLocation()` Convenience method for getting the current noNamespaceSchemaLocation.
`java.lang.Object` | `getProperty(java.lang.String name)` Default implementation of the getProperty method handles the four defined properties in Marshaller.
`protected java.lang.String` | `getSchemaLocation()` Convenience method for getting the current schemaLocation.
`protected boolean` | `isFormattedOutput()` Convenience method for getting the formatted output flag.
`void` | `marshal(java.lang.Object obj, org.xml.sax.ContentHandler handler)` Marshal the content tree rooted at obj into SAX2 events.
`void` | `marshal(java.lang.Object obj, org.w3c.dom.Node node)` Marshal the content tree rooted at obj into a DOM tree.
`void` | `marshal(java.lang.Object obj, java.io.OutputStream os)` Marshal the content tree rooted at obj into an output stream.
`void` | `marshal(java.lang.Object obj, java.io.Writer w)` Marshal the content tree rooted at obj into a Writer.
`protected void` | `setEncoding(java.lang.String encoding)` Convenience method for setting the output encoding.
`void` | `setEventHandler(ValidationEventHandler handler)` Allow an application to register a validation event handler.
`protected void` | `setFormattedOutput(boolean v)` Convenience method for setting the formatted output flag.
`protected void` | `setNoNSSchemaLocation(java.lang.String location)` Convenience method for setting the noNamespaceSchemaLocation.
`void` | `setProperty(java.lang.String name, java.lang.Object value)` Default implementation of the setProperty method handles the four defined properties in Marshaller.
`protected void` | `setSchemaLocation(java.lang.String location)` Convenience method for setting the schemaLocation.

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

Methods inherited from interface javax.xml.bind.Marshaller
`marshal`

Constructor Detail

### AbstractMarshallerImpl

    public AbstractMarshallerImpl()

Method Detail

### marshal

    public final void marshal(java.lang.Object obj,
                              java.io.OutputStream os)
                       throws JAXBException

  Description copied from interface: `Marshaller`
  Marshal the content tree rooted at obj into an output stream.

  Specified by:
    `marshal` in interface `Marshaller`
  Parameters:
    `obj` - The content tree to be marshalled.
    `os` - XML will be added to this stream.
  Throws:
    `JAXBException` - If any unexpected problem occurs during the marshalling.

### marshal

    public final void marshal(java.lang.Object obj,
                              java.io.Writer w)
                       throws JAXBException

  Description copied from interface: `Marshaller`
  Marshal the content tree rooted at obj into a Writer.

  Specified by:
    `marshal` in interface `Marshaller`
  Parameters:
    `obj` - The content tree to be marshalled.
    `w` - XML will be sent to this writer.
  Throws:
    `JAXBException` - If any unexpected problem occurs during the marshalling.

### marshal

    public final void marshal(java.lang.Object obj,
                              org.xml.sax.ContentHandler handler)
                       throws JAXBException

  Description copied from interface: `Marshaller`
  Marshal the content tree rooted at obj into SAX2 events.

  Specified by:
    `marshal` in interface `Marshaller`
  Parameters:
    `obj` - The content tree to be marshalled.
    `handler` - XML will be sent to this handler as SAX2 events.
  Throws:
    `JAXBException` - If any unexpected problem occurs during the marshalling.

### marshal

    public final void marshal(java.lang.Object obj,
                              org.w3c.dom.Node node)
                       throws JAXBException

  Description copied from interface: `Marshaller`
  Marshal the content tree rooted at obj into a DOM tree.

  Specified by:
    `marshal` in interface `Marshaller`
  Parameters:
    `obj` - The content tree to be marshalled.
    `node` - DOM nodes will be added as children of this node. This parameter must be a Node that accepts children (`Document`, `DocumentFragment`, or `Element`)
  Throws:
    `JAXBException` - If any unexpected problem occurs during the marshalling.

### getNode

    public org.w3c.dom.Node getNode(java.lang.Object obj)
                             throws JAXBException

  By default, the getNode method is unsupported and throw an `UnsupportedOperationException`. Implementations that choose to support this method must override this method.

  Specified by:
    `getNode` in interface `Marshaller`
  Parameters:
    `obj` - - JAXB Java representation of XML content
  Returns:
    the DOM tree view of the contentTree
  Throws:
    `JAXBException` - If any unexpected problem occurs

### getEncoding

    protected java.lang.String getEncoding()

  Convenience method for getting the current output encoding.

  Returns:
    the current encoding or "UTF-8" if it hasn't been set.

### setEncoding

    protected void setEncoding(java.lang.String encoding)

  Convenience method for setting the output encoding.

  Parameters:
    `encoding` - a valid encoding as specified in the Marshaller class documentation

### getSchemaLocation

    protected java.lang.String getSchemaLocation()

  Convenience method for getting the current schemaLocation.

  Returns:
    the current schemaLocation or null if it hasn't been set

### setSchemaLocation

    protected void setSchemaLocation(java.lang.String location)

  Convenience method for setting the schemaLocation.

  Parameters:
    `location` - the schemaLocation value

### getNoNSSchemaLocation

    protected java.lang.String getNoNSSchemaLocation()

  Convenience method for getting the current noNamespaceSchemaLocation.

  Returns:
    the current noNamespaceSchemaLocation or null if it hasn't been set

### setNoNSSchemaLocation

    protected void setNoNSSchemaLocation(java.lang.String location)

  Convenience method for setting the noNamespaceSchemaLocation.

  Parameters:
    `location` - the noNamespaceSchemaLocation value

### isFormattedOutput

    protected boolean isFormattedOutput()

  Convenience method for getting the formatted output flag.

  Returns:
    the current value of the formatted output flag or false if it hasn't been set.

### setFormattedOutput

    protected void setFormattedOutput(boolean v)

  Convenience method for setting the formatted output flag.

  Parameters:
    `v` - value of the formatted output flag.

### getJavaEncoding

    protected java.lang.String getJavaEncoding(java.lang.String encoding)
                                        throws java.io.UnsupportedEncodingException

  Gets the corresponding Java encoding name from an IANA name. This method is a helper method for the derived class to convert encoding names.

  Throws:
    `java.io.UnsupportedEncodingException` - If this implementation couldn't find the Java encoding name.

### setProperty

    public void setProperty(java.lang.String name,
                            java.lang.Object value)
                     throws PropertyException

  Default implementation of the setProperty method handles the four defined properties in Marshaller. If a provider needs to handle additional properties, it should override this method in a derived class.

  Specified by:
    `setProperty` in interface `Marshaller`
  Parameters:
    `name` - the name of the property to be set. This value can either be specified using one of the constant fields or a user supplied string.
    `value` - the value of the property to be set
  Throws:
    `PropertyException` - when there is an error processing the given property or value

### getProperty

    public java.lang.Object getProperty(java.lang.String name)
                                 throws PropertyException

  Default implementation of the getProperty method handles the four defined properties in Marshaller. If a provider needs to support additional provider specific properties, it should override this method in a derived class.

  Specified by:
    `getProperty` in interface `Marshaller`
  Parameters:
    `name` - the name of the property to retrieve
  Returns:
    the value of the requested property
  Throws:
    `PropertyException` - when there is an error retrieving the given property or value property name

### getEventHandler

    public ValidationEventHandler getEventHandler()
                                           throws JAXBException

  Description copied from interface: `Marshaller`
  Return the current event handler or the default event handler if one hasn't been set.

  Specified by:
    `getEventHandler` in interface `Marshaller`
  Returns:
    the current ValidationEventHandler or the default event handler if it hasn't been set
  Throws:
    `JAXBException` - if an error was encountered while getting the current event handler
  See Also:
    `Marshaller.getEventHandler()`

### setEventHandler

    public void setEventHandler(ValidationEventHandler handler)
                         throws JAXBException

  Description copied from interface: `Marshaller`
  Allow an application to register a validation event handler.

  The validation event handler will be called by the JAXB Provider if any validation errors are encountered during calls to any of the marshal API's. If the client application does not register a validation event handler before invoking one of the marshal methods, then validation events will be handled by the default event handler which will terminate the marshal operation after the first error or fatal error is encountered.

  Calling this method with a null parameter will cause the Marshaller to revert back to the default vefault event handler.

  Specified by:
    `setEventHandler` in interface `Marshaller`
  Parameters:
    `handler` - the validation event handler
  Throws:
    `JAXBException` - if an error was encountered while setting the event handler
  See Also:
    `Marshaller.setEventHandler(ValidationEventHandler)`

Overview | Package | Class | Tree | Deprecated | Index | Help
| JAXB v1.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Comments to: jaxb-spec-comments@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.