Search in sources :

Example 1 with SAXLocator

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;
}
Also used : SAXLocator(com.sun.xml.bind.validator.SAXLocator) JAXBException(javax.xml.bind.JAXBException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 2 with SAXLocator

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;
}
Also used : SAXLocator(com.sun.xml.bind.validator.SAXLocator) JAXBException(javax.xml.bind.JAXBException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 3 with SAXLocator

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;
}
Also used : SAXLocator(com.sun.xml.bind.validator.SAXLocator) JAXBException(javax.xml.bind.JAXBException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 4 with SAXLocator

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;
}
Also used : SAXLocator(com.sun.xml.bind.validator.SAXLocator) JAXBException(javax.xml.bind.JAXBException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 5 with SAXLocator

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;
}
Also used : SAXLocator(com.sun.xml.bind.validator.SAXLocator) JAXBException(javax.xml.bind.JAXBException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Aggregations

SAXLocator (com.sun.xml.bind.validator.SAXLocator)5 IOException (java.io.IOException)5 JAXBException (javax.xml.bind.JAXBException)5 SAXException (org.xml.sax.SAXException)5