Search in sources :

Example 1 with JavaException

use of php.runtime.ext.java.JavaException in project jphp by jphp-compiler.

the class WrapXmlProcessor method __construct.

@Signature
public void __construct(final Environment env) throws ParserConfigurationException, TransformerConfigurationException {
    transformerFactory = TransformerFactory.newInstance();
    transformer = transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    builderFactory = DocumentBuilderFactory.newInstance();
    builder = builderFactory.newDocumentBuilder();
    builder.setErrorHandler(new ErrorHandler() {

        @Override
        public void warning(SAXParseException exception) throws SAXException {
            if (onWarning != null) {
                onWarning.callAny(new JavaException(env, exception));
            }
        }

        @Override
        public void error(SAXParseException exception) throws SAXException {
            if (onError != null) {
                onError.callAny(new JavaException(env, exception));
            }
        }

        @Override
        public void fatalError(SAXParseException exception) throws SAXException {
            if (onFatalError != null) {
                onFatalError.callAny(new JavaException(env, exception));
            } else {
                throw exception;
            }
        }
    });
}
Also used : ErrorHandler(org.xml.sax.ErrorHandler) JavaException(php.runtime.ext.java.JavaException) SAXParseException(org.xml.sax.SAXParseException) SAXException(org.xml.sax.SAXException) Signature(php.runtime.annotation.Reflection.Signature)

Aggregations

ErrorHandler (org.xml.sax.ErrorHandler)1 SAXException (org.xml.sax.SAXException)1 SAXParseException (org.xml.sax.SAXParseException)1 Signature (php.runtime.annotation.Reflection.Signature)1 JavaException (php.runtime.ext.java.JavaException)1