use of javax.xml.bind.UnmarshallerHandler in project OpenAM by OpenRock.
the class UnmarshallerImpl method unmarshal.
public final Object unmarshal(Node node) throws JAXBException {
try {
DOMScanner scanner = new DOMScanner();
UnmarshallerHandler handler = new InterningUnmarshallerHandler(createUnmarshallerHandler(new DOMLocator(scanner)));
if (node instanceof Element)
scanner.parse((Element) node, handler);
else if (node instanceof Document)
scanner.parse(((Document) node).getDocumentElement(), handler);
else
// no other type of input is supported
throw new IllegalArgumentException();
return handler.getResult();
} catch (SAXException e) {
throw createUnmarshalException(e);
}
}
use of javax.xml.bind.UnmarshallerHandler in project OpenAM by OpenRock.
the class UnmarshallerImpl method unmarshal.
public final Object unmarshal(Node node) throws JAXBException {
try {
DOMScanner scanner = new DOMScanner();
UnmarshallerHandler handler = new InterningUnmarshallerHandler(createUnmarshallerHandler(new DOMLocator(scanner)));
if (node instanceof Element)
scanner.parse((Element) node, handler);
else if (node instanceof Document)
scanner.parse(((Document) node).getDocumentElement(), handler);
else
// no other type of input is supported
throw new IllegalArgumentException();
return handler.getResult();
} catch (SAXException e) {
throw createUnmarshalException(e);
}
}
use of javax.xml.bind.UnmarshallerHandler in project tomee by apache.
the class JaxbPersistenceFactory method getPersistence.
public static <T> T getPersistence(final Class<T> clazz, final InputStream persistenceDescriptor) throws Exception {
final JAXBContext jc = clazz.getClassLoader() == JaxbPersistenceFactory.class.getClassLoader() ? JaxbJavaee.getContext(clazz) : JAXBContextFactory.newInstance(clazz);
final Unmarshaller u = jc.createUnmarshaller();
final UnmarshallerHandler uh = u.getUnmarshallerHandler();
// create a new XML parser
final SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
final SAXParser parser = factory.newSAXParser();
final XMLReader xmlReader = parser.getXMLReader();
// Create a filter to intercept events
final PersistenceFilter xmlFilter = new PersistenceFilter(xmlReader);
// Be sure the filter has the JAXB content handler set (or it wont work)
xmlFilter.setContentHandler(uh);
final SAXSource source = new SAXSource(xmlFilter, new InputSource(persistenceDescriptor));
return (T) u.unmarshal(source);
}
use of javax.xml.bind.UnmarshallerHandler in project OpenAM by OpenRock.
the class UnmarshallerImpl method unmarshal.
public final Object unmarshal(Node node) throws JAXBException {
try {
DOMScanner scanner = new DOMScanner();
UnmarshallerHandler handler = new InterningUnmarshallerHandler(createUnmarshallerHandler(new DOMLocator(scanner)));
if (node instanceof Element)
scanner.parse((Element) node, handler);
else if (node instanceof Document)
scanner.parse(((Document) node).getDocumentElement(), handler);
else
// no other type of input is supported
throw new IllegalArgumentException();
return handler.getResult();
} catch (SAXException e) {
throw createUnmarshalException(e);
}
}
use of javax.xml.bind.UnmarshallerHandler in project OpenAM by OpenRock.
the class UnmarshallerImpl method unmarshal.
public final Object unmarshal(Node node) throws JAXBException {
try {
DOMScanner scanner = new DOMScanner();
UnmarshallerHandler handler = new InterningUnmarshallerHandler(createUnmarshallerHandler(new DOMLocator(scanner)));
if (node instanceof Element)
scanner.parse((Element) node, handler);
else if (node instanceof Document)
scanner.parse(((Document) node).getDocumentElement(), handler);
else
// no other type of input is supported
throw new IllegalArgumentException();
return handler.getResult();
} catch (SAXException e) {
throw createUnmarshalException(e);
}
}
Aggregations