use of com.sun.xml.bind.validator.SAXLocator in project OpenAM by OpenRock.
the class UnmarshallerImpl method unmarshal.
protected Object unmarshal(XMLReader reader, InputSource source) throws JAXBException {
SAXLocator locator = new SAXLocator();
SAXUnmarshallerHandler handler = createUnmarshallerHandler(locator);
reader = InterningXMLReader.adapt(reader);
reader.setContentHandler(handler);
// saxErrorHandler will be set by the createUnmarshallerHandler method.
// configure XMLReader so that the error will be sent to it.
// This is essential for the UnmarshallerHandler to be able to abort
// unmarshalling when an error is found.
//
// Note that when this XMLReader is provided by the client code,
// it might be already configured to call a client error handler.
// This will clobber such handler, if any.
//
// Ryan noted that we might want to report errors to such a client
// error handler as well.
reader.setErrorHandler(new ErrorHandlerAdaptor(handler, locator));
try {
reader.parse(source);
} catch (IOException e) {
throw new JAXBException(e);
} catch (SAXException e) {
throw createUnmarshalException(e);
}
Object result = handler.getResult();
// avoid keeping unnecessary references too long to let the GC
// reclaim more memory.
// setting null upsets some parsers, so use a dummy instance instead.
reader.setContentHandler(dummyHandler);
reader.setErrorHandler(dummyHandler);
return result;
}
use of com.sun.xml.bind.validator.SAXLocator in project OpenAM by OpenRock.
the class UnmarshallerImpl method unmarshal.
protected Object unmarshal(XMLReader reader, InputSource source) throws JAXBException {
SAXLocator locator = new SAXLocator();
SAXUnmarshallerHandler handler = createUnmarshallerHandler(locator);
reader = InterningXMLReader.adapt(reader);
reader.setContentHandler(handler);
// saxErrorHandler will be set by the createUnmarshallerHandler method.
// configure XMLReader so that the error will be sent to it.
// This is essential for the UnmarshallerHandler to be able to abort
// unmarshalling when an error is found.
//
// Note that when this XMLReader is provided by the client code,
// it might be already configured to call a client error handler.
// This will clobber such handler, if any.
//
// Ryan noted that we might want to report errors to such a client
// error handler as well.
reader.setErrorHandler(new ErrorHandlerAdaptor(handler, locator));
try {
reader.parse(source);
} catch (IOException e) {
throw new JAXBException(e);
} catch (SAXException e) {
throw createUnmarshalException(e);
}
Object result = handler.getResult();
// avoid keeping unnecessary references too long to let the GC
// reclaim more memory.
// setting null upsets some parsers, so use a dummy instance instead.
reader.setContentHandler(dummyHandler);
reader.setErrorHandler(dummyHandler);
return result;
}
use of com.sun.xml.bind.validator.SAXLocator in project OpenAM by OpenRock.
the class UnmarshallerImpl method unmarshal.
protected Object unmarshal(XMLReader reader, InputSource source) throws JAXBException {
SAXLocator locator = new SAXLocator();
SAXUnmarshallerHandler handler = createUnmarshallerHandler(locator);
reader = InterningXMLReader.adapt(reader);
reader.setContentHandler(handler);
// saxErrorHandler will be set by the createUnmarshallerHandler method.
// configure XMLReader so that the error will be sent to it.
// This is essential for the UnmarshallerHandler to be able to abort
// unmarshalling when an error is found.
//
// Note that when this XMLReader is provided by the client code,
// it might be already configured to call a client error handler.
// This will clobber such handler, if any.
//
// Ryan noted that we might want to report errors to such a client
// error handler as well.
reader.setErrorHandler(new ErrorHandlerAdaptor(handler, locator));
try {
reader.parse(source);
} catch (IOException e) {
throw new JAXBException(e);
} catch (SAXException e) {
throw createUnmarshalException(e);
}
Object result = handler.getResult();
// avoid keeping unnecessary references too long to let the GC
// reclaim more memory.
// setting null upsets some parsers, so use a dummy instance instead.
reader.setContentHandler(dummyHandler);
reader.setErrorHandler(dummyHandler);
return result;
}
use of com.sun.xml.bind.validator.SAXLocator in project OpenAM by OpenRock.
the class UnmarshallerImpl method unmarshal.
protected Object unmarshal(XMLReader reader, InputSource source) throws JAXBException {
SAXLocator locator = new SAXLocator();
SAXUnmarshallerHandler handler = createUnmarshallerHandler(locator);
reader = InterningXMLReader.adapt(reader);
reader.setContentHandler(handler);
// saxErrorHandler will be set by the createUnmarshallerHandler method.
// configure XMLReader so that the error will be sent to it.
// This is essential for the UnmarshallerHandler to be able to abort
// unmarshalling when an error is found.
//
// Note that when this XMLReader is provided by the client code,
// it might be already configured to call a client error handler.
// This will clobber such handler, if any.
//
// Ryan noted that we might want to report errors to such a client
// error handler as well.
reader.setErrorHandler(new ErrorHandlerAdaptor(handler, locator));
try {
reader.parse(source);
} catch (IOException e) {
throw new JAXBException(e);
} catch (SAXException e) {
throw createUnmarshalException(e);
}
Object result = handler.getResult();
// avoid keeping unnecessary references too long to let the GC
// reclaim more memory.
// setting null upsets some parsers, so use a dummy instance instead.
reader.setContentHandler(dummyHandler);
reader.setErrorHandler(dummyHandler);
return result;
}
use of com.sun.xml.bind.validator.SAXLocator in project Payara by payara.
the class UnmarshallerImpl method unmarshal.
protected Object unmarshal(XMLReader reader, InputSource source) throws JAXBException {
SAXLocator locator = new SAXLocator();
SAXUnmarshallerHandler handler = createUnmarshallerHandler(locator);
reader = InterningXMLReader.adapt(reader);
reader.setContentHandler(handler);
// saxErrorHandler will be set by the createUnmarshallerHandler method.
// configure XMLReader so that the error will be sent to it.
// This is essential for the UnmarshallerHandler to be able to abort
// unmarshalling when an error is found.
//
// Note that when this XMLReader is provided by the client code,
// it might be already configured to call a client error handler.
// This will clobber such handler, if any.
//
// Ryan noted that we might want to report errors to such a client
// error handler as well.
reader.setErrorHandler(new ErrorHandlerAdaptor(handler, locator));
try {
reader.parse(source);
} catch (IOException e) {
throw new JAXBException(e);
} catch (SAXException e) {
throw createUnmarshalException(e);
}
Object result = handler.getResult();
// avoid keeping unnecessary references too long to let the GC
// reclaim more memory.
// setting null upsets some parsers, so use a dummy instance instead.
reader.setContentHandler(dummyHandler);
reader.setErrorHandler(dummyHandler);
return result;
}
Aggregations