javax.xml.bind.helpers

Class AbstractUnmarshallerImpl

public abstract class AbstractUnmarshallerImpl extends Object implements Unmarshaller

This is an abstract default implementation of an Unmarshaller. Subclasses only need to implement getUnmarshallerHandler, unmarshal, and AbstractUnmarshallerImpl.

Since: JAXB1.0

Author: JSR-31

Constructor Summary
AbstractUnmarshallerImpl()

Creates a new instance of AbstractUnmarshallerImpl.

Method Summary
protected UnmarshalExceptioncreateUnmarshalException(SAXException pException)

Helper method to concert a org.xml.sax.SAXException into an UnmarshalException.

ValidationEventHandlergetEventHandler()
ObjectgetProperty(String pName)

Always throws a PropertyException, because the default implementation does not support any properties.

protected XMLReadergetXMLReader()

Creates a configured org.xml.sax.XMLReader.

booleanisValidating()
voidsetEventHandler(ValidationEventHandler pHandler)
voidsetProperty(String pName, Object pValue)

Always throws a PropertyException, because the default implementation does not support any properties.

voidsetValidating(boolean pValidating)
Objectunmarshal(Source pSource)
protected abstract Objectunmarshal(XMLReader pReader, InputSource pSource)

Unmarshals an object by using the given instance of org.xml.sax.XMLReader to parse the XML document read from the byte or character stream given by the org.xml.sax.InputSource pSource.

The implementation should call the method org.xml.sax.XMLReader#setErrorHandler(org.xml.sax.ErrorHandler) in order to pass errors provided by the SAX parser to the ValidationEventHandler provided by the client.

Objectunmarshal(InputSource pSource)
Objectunmarshal(URL pURL)
Objectunmarshal(File pFile)
Objectunmarshal(InputStream pSource)

Constructor Detail

AbstractUnmarshallerImpl

public AbstractUnmarshallerImpl()

Creates a new instance of AbstractUnmarshallerImpl.

Method Detail

createUnmarshalException

protected UnmarshalException createUnmarshalException(SAXException pException)

Helper method to concert a org.xml.sax.SAXException into an UnmarshalException.

Parameters: pException If the parameter contains a nested instance of UnmarshalException, throws that instance. Otherwise wraps the parameter in a new UnmarshalException and throws that.

getEventHandler

public ValidationEventHandler getEventHandler()

getProperty

public Object getProperty(String pName)

Always throws a PropertyException, because the default implementation does not support any properties. If you want to change this, override the class.

Throws: IllegalArgumentException The property name was null. PropertyException The name was not null. :-)

getXMLReader

protected XMLReader getXMLReader()

Creates a configured org.xml.sax.XMLReader. Unmarshaller is not re-entrant, so we will use a single instance of org.xml.sax.XMLReader.

Throws: JAXBException Encapsulates a javax.xml.parsers.ParserConfigurationException

isValidating

public boolean isValidating()

setEventHandler

public void setEventHandler(ValidationEventHandler pHandler)

setProperty

public void setProperty(String pName, Object pValue)

Always throws a PropertyException, because the default implementation does not support any properties. If you want to change this, override the class.

Throws: IllegalArgumentException The property name was null. PropertyException The name was not null. :-)

setValidating

public void setValidating(boolean pValidating)

unmarshal

public Object unmarshal(Source pSource)

unmarshal

protected abstract Object unmarshal(XMLReader pReader, InputSource pSource)

Unmarshals an object by using the given instance of org.xml.sax.XMLReader to parse the XML document read from the byte or character stream given by the org.xml.sax.InputSource pSource.

The implementation should call the method org.xml.sax.XMLReader#setErrorHandler(org.xml.sax.ErrorHandler) in order to pass errors provided by the SAX parser to the ValidationEventHandler provided by the client.

Throws: JAXBException An error occurred while unmarshalling the JAXB object.

unmarshal

public final Object unmarshal(InputSource pSource)

unmarshal

public final Object unmarshal(URL pURL)

unmarshal

public final Object unmarshal(File pFile)

unmarshal

public final Object unmarshal(InputStream pSource)