com.sun.xml.bind.v2.runtime
Class Coordinator

java.lang.Object
  extended by com.sun.xml.bind.v2.runtime.Coordinator
All Implemented Interfaces:
ValidationEventHandler, ErrorHandler
Direct Known Subclasses:
UnmarshallingContext, XMLSerializer

public abstract class Coordinator
extends Object
implements ErrorHandler, ValidationEventHandler

Object that coordinates the marshalling/unmarshalling.

This class takes care of the logic that allows code to obtain UnmarshallingContext and XMLSerializer instances during the unmarshalling/marshalling.

This is done by using a ThreadLocal. Therefore one unmarshalling/marshalling episode has to be done from the beginning till end by the same thread. (Note that the same Coordinator can be then used by a different thread for an entirely different episode.) This class also maintains the user-configured instances of XmlAdapters.

This class implements ErrorHandler and propages erros to this object as the ValidationEventHandler, which will be implemented in a derived class.

Author:
Kohsuke Kawaguchi

Constructor Summary
Coordinator()
           
 
Method Summary
static Coordinator _getInstance()
           
<T extends XmlAdapter>
boolean
containsAdapter(Class<T> type)
           
 void error(SAXParseException exception)
           
 void fatalError(SAXParseException exception)
           
<T extends XmlAdapter>
T
getAdapter(Class<T> key)
          Gets the instance of the adapter.
protected abstract  ValidationEventLocator getLocation()
          Gets the current location.
protected  void popCoordinator()
          Called whenever an execution flow exits the realm of this Coordinator.
protected  void pushCoordinator()
          Called whenever an execution flow enters the realm of this Coordinator.
 XmlAdapter putAdapter(Class<? extends XmlAdapter> c, XmlAdapter a)
           
 void warning(SAXParseException exception)
           
 
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.ValidationEventHandler
handleEvent
 

Constructor Detail

Coordinator

public Coordinator()
Method Detail

putAdapter

public final XmlAdapter putAdapter(Class<? extends XmlAdapter> c,
                                   XmlAdapter a)

getAdapter

public final <T extends XmlAdapter> T getAdapter(Class<T> key)
Gets the instance of the adapter.

Returns:
always non-null.

containsAdapter

public <T extends XmlAdapter> boolean containsAdapter(Class<T> type)

pushCoordinator

protected final void pushCoordinator()
Called whenever an execution flow enters the realm of this Coordinator.


popCoordinator

protected final void popCoordinator()
Called whenever an execution flow exits the realm of this Coordinator.


_getInstance

public static Coordinator _getInstance()

getLocation

protected abstract ValidationEventLocator getLocation()
Gets the current location. Used for reporting the error source location.


error

public final void error(SAXParseException exception)
                 throws SAXException
Specified by:
error in interface ErrorHandler
Throws:
SAXException

warning

public final void warning(SAXParseException exception)
                   throws SAXException
Specified by:
warning in interface ErrorHandler
Throws:
SAXException

fatalError

public final void fatalError(SAXParseException exception)
                      throws SAXException
Specified by:
fatalError in interface ErrorHandler
Throws:
SAXException


Copyright © 2014 Oracle Corporation. All Rights Reserved.