org.apache.ws.jaxme.impl
Class JMUnmarshallerImpl

java.lang.Object
  extended by org.apache.ws.jaxme.impl.JMControllerImpl
      extended by org.apache.ws.jaxme.impl.JMUnmarshallerImpl
All Implemented Interfaces:
Unmarshaller, JMUnmarshaller

public class JMUnmarshallerImpl
extends JMControllerImpl
implements JMUnmarshaller

JaxMe's Unmarshaller implementation.


Field Summary
 
Fields inherited from class org.apache.ws.jaxme.impl.JMControllerImpl
eventHandler, JAXME_DATATYPE_CONVERTER, JAXME_FORMAT_DATE, JAXME_FORMAT_DATETIME, JAXME_FORMAT_TIME, JAXME_PRIVATE
 
Constructor Summary
JMUnmarshallerImpl()
           
 
Method Summary
 UnmarshallerHandler getUnmarshallerHandler()
          Returns a SAX 2 ContentHandler, which is able to parse a SAX event stream and convert it into a JAXB object.
 boolean isValidating()
          Sets whether the Unmarshaller is validating the objects that it reads.
 void setValidating(boolean pValidating)
          Sets whether the Unmarshaller is validating the objects that it reads.
 java.lang.Object unmarshal(java.io.File pFile)
          This method takes opens the given file pFile for input.
 java.lang.Object unmarshal(org.xml.sax.InputSource pSource)
          The Unmarshaller reads the byte stream or character stream referred by the InputSource and converts it into an equivalent JAXB object.
 java.lang.Object unmarshal(java.io.InputStream pStream)
          The Unmarshaller reads the given byte stream and converts it into an equivalent JAXB object.
 java.lang.Object unmarshal(org.w3c.dom.Node pNode)
          The Unmarshaller converts the given node into an equivalent JAXB object.
 java.lang.Object unmarshal(javax.xml.transform.Source pSource)
          The Unmarshaller reads the XML representation from the given Source and converts it into an equivalent JAXB object.
 java.lang.Object unmarshal(java.net.URL pURL)
          This method takes connects to the given pURL and opens a byte stream for input.
 
Methods inherited from class org.apache.ws.jaxme.impl.JMControllerImpl
getDatatypeConverter, getDateFormat, getDateTimeFormat, getEventHandler, getJAXBContextImpl, getProperty, getTimeFormat, setDatatypeConverter, setDateFormat, setDateTimeFormat, setEventHandler, setJAXBContextImpl, setProperty, setTimeFormat
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.ws.jaxme.JMUnmarshaller
getDatatypeConverter, getJAXBContextImpl, setJAXBContextImpl
 
Methods inherited from interface javax.xml.bind.Unmarshaller
getEventHandler, getProperty, setEventHandler, setProperty
 

Constructor Detail

JMUnmarshallerImpl

public JMUnmarshallerImpl()
Method Detail

isValidating

public boolean isValidating()
Description copied from interface: Unmarshaller

Sets whether the Unmarshaller is validating the objects that it reads. The default is false.

Specified by:
isValidating in interface Unmarshaller
Returns:
True, if the Unmarshaller is validating the objects that it reads, false otherwise.
See Also:
Unmarshaller.setValidating(boolean)

setValidating

public void setValidating(boolean pValidating)
Description copied from interface: Unmarshaller

Sets whether the Unmarshaller is validating the objects that it reads. The default is false.

Note: A validating unmarshaller will rarely use a validating SAX parser by default! It does so, because the SAX parsers validation and the Unmarshallers builtin validation would most probably validate the same things, resulting in no additional safety at the cost of wasting performance. Second, a SAX parser is not always in use. For example, you do not need a parser when converting a DOM Node. If you insist in a validating XML parser, then you should create your own XMLReader and use the method Unmarshaller.unmarshal(javax.xml.transform.Source).

Specified by:
setValidating in interface Unmarshaller
Parameters:
pValidating - Whether the Unmarshaller should validate or not.

unmarshal

public java.lang.Object unmarshal(java.net.URL pURL)
                           throws JAXBException
Description copied from interface: Unmarshaller

This method takes connects to the given pURL and opens a byte stream for input. The Unmarshaller reads the byte stream and converts it into an equivalent JAXB object.

Specified by:
unmarshal in interface Unmarshaller
Parameters:
pURL - The URL being read.
Returns:
The JAXB object read from the URL.
Throws:
JAXBException - An unexpected problem (for example an IOException) occurred.
UnmarshalException - The JAXB object is invalid or could not be read from the byte stream for similar reasons.

unmarshal

public java.lang.Object unmarshal(java.io.File pFile)
                           throws JAXBException
Description copied from interface: Unmarshaller

This method takes opens the given file pFile for input. The Unmarshaller reads the byte stream contained in the file and converts it into an equivalent JAXB object.

Specified by:
unmarshal in interface Unmarshaller
Parameters:
pFile - The file being read.
Returns:
The JAXB object read from the file.
Throws:
JAXBException - An unexpected problem (for example an IOException) occurred.
UnmarshalException - The JAXB object is invalid or could not be read from the byte stream for similar reasons.

unmarshal

public java.lang.Object unmarshal(java.io.InputStream pStream)
                           throws JAXBException
Description copied from interface: Unmarshaller

The Unmarshaller reads the given byte stream and converts it into an equivalent JAXB object.

Specified by:
unmarshal in interface Unmarshaller
Parameters:
pStream - The stream being read.
Returns:
The JAXB object read from the byte stream.
Throws:
JAXBException - An unexpected problem (for example an IOException) occurred.
UnmarshalException - The JAXB object is invalid or could not be read from the byte stream for similar reasons.

unmarshal

public java.lang.Object unmarshal(org.xml.sax.InputSource pSource)
                           throws JAXBException
Description copied from interface: Unmarshaller

The Unmarshaller reads the byte stream or character stream referred by the InputSource and converts it into an equivalent JAXB object.

Specified by:
unmarshal in interface Unmarshaller
Parameters:
pSource - The InputSource referring to a byte or character stream. It is recommended, that the system ID is set. This may be required, if the XML in the stream refers to external entities.
Returns:
The JAXB object read from the byte or character stream.
Throws:
JAXBException - An unexpected problem (for example an IOException) occurred.
UnmarshalException - The JAXB object is invalid or could not be read from the byte stream for similar reasons.

unmarshal

public java.lang.Object unmarshal(org.w3c.dom.Node pNode)
                           throws JAXBException
Description copied from interface: Unmarshaller

The Unmarshaller converts the given node into an equivalent JAXB object.

Specified by:
unmarshal in interface Unmarshaller
Parameters:
pNode - The node to convert. The JAXB provider must support documents and elements. Other node types may not work (document fragments) or cannot work (attributes, text nodes, and so on).
Returns:
The JAXB object read from the DOM node.
Throws:
JAXBException - An unexpected problem occurred.
UnmarshalException - The JAXB object is invalid or could not be read for similar reasons.

unmarshal

public java.lang.Object unmarshal(javax.xml.transform.Source pSource)
                           throws JAXBException
Description copied from interface: Unmarshaller

The Unmarshaller reads the XML representation from the given Source and converts it into an equivalent JAXB object.

The JAXB provider must support at least SAXSource, DOMSource, and StreamSource. A possible implementation could validate whether the argument is actually an instance of these subinterfaces. If so, it might simply act like Unmarshaller.getUnmarshallerHandler(), Unmarshaller.unmarshal(org.w3c.dom.Node), Unmarshaller.unmarshal(java.io.InputStream), or Unmarshaller.unmarshal(org.xml.sax.InputSource), respectively.

Note: If you are not using the standard JAXP mechanism for obtaining an XMLReader, then you might create your own SAX parser and invoke the pSource arguments SAXSource.setXMLReader(org.xml.sax.XMLReader). The JAXB provider will detect and use your SAX parser.

Specified by:
unmarshal in interface Unmarshaller
Parameters:
pSource - The Source being read.
Returns:
The JAXB object read from the DOM node.
Throws:
JAXBException - An unexpected problem occurred.
UnmarshalException - The JAXB object is invalid or could not be read for similar reasons.

getUnmarshallerHandler

public UnmarshallerHandler getUnmarshallerHandler()
Description copied from interface: Unmarshaller

Returns a SAX 2 ContentHandler, which is able to parse a SAX event stream and convert it into a JAXB object. This is particularly useful in a stack of SAX handlers. (Think of Apache Cocoon.)

Note: The JAXB provider may choose to return the same handler again, if the method is invoked more than once. In other words, if you need to have multiple handlers (for example, because you have multiple threads), then you should create multiple Unmarshallers.

Specified by:
getUnmarshallerHandler in interface Unmarshaller