Search in sources :

Example 1 with ConfigurationException

use of org.jooq.exception.ConfigurationException in project jOOQ by jOOQ.

the class MiniJAXB method marshal.

public static void marshal(XMLAppendable object, Writer out) {
    try {
        XMLBuilder builder = XMLBuilder.formatting();
        XmlRootElement e = object.getClass().getAnnotation(XmlRootElement.class);
        if (e != null) {
            out.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
            builder.append(e.name(), object);
        } else
            builder.append(object);
        builder.appendTo(out);
    } catch (Exception e) {
        throw new ConfigurationException("Cannot print object", e);
    }
}
Also used : XmlRootElement(jakarta.xml.bind.annotation.XmlRootElement) ConfigurationException(org.jooq.exception.ConfigurationException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ConfigurationException(org.jooq.exception.ConfigurationException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) ReflectException(org.jooq.tools.reflect.ReflectException) SAXParseException(org.xml.sax.SAXParseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 2 with ConfigurationException

use of org.jooq.exception.ConfigurationException in project jOOQ by jOOQ.

the class MiniJAXB method unmarshal0.

private static <T extends XMLAppendable> T unmarshal0(InputSource in, Class<T> type) {
    try {
        addDefaultNamespace(in, type);
        Document document = builder(type).parse(in);
        T result = Reflect.on(type).create().get();
        unmarshal0(result, document.getDocumentElement(), new IdentityHashMap<Class<?>, Map<String, Field>>());
        return result;
    } catch (Exception e) {
        throw new ConfigurationException("Error while reading xml", e);
    }
}
Also used : ConfigurationException(org.jooq.exception.ConfigurationException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Document(org.w3c.dom.Document) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) ConfigurationException(org.jooq.exception.ConfigurationException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) ReflectException(org.jooq.tools.reflect.ReflectException) SAXParseException(org.xml.sax.SAXParseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Aggregations

IOException (java.io.IOException)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 ConfigurationException (org.jooq.exception.ConfigurationException)2 ReflectException (org.jooq.tools.reflect.ReflectException)2 SAXException (org.xml.sax.SAXException)2 SAXParseException (org.xml.sax.SAXParseException)2 XmlRootElement (jakarta.xml.bind.annotation.XmlRootElement)1 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 Document (org.w3c.dom.Document)1