com.fasterxml.jackson.xml.util.StaxUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-xml-databind Show documentation
Show all versions of jackson-xml-databind Show documentation
Extension for Jackson (http://jackson.codehaus.org) to offer
alternative support for serializing POJOs as XML and deserializing XML as pojos.
Support implemented on top of Stax API (javax.xml.stream), by implementing core Jackson Streaming API types like JsonGenerator, JsonParser and JsonFactory.
Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMapper).
package com.fasterxml.jackson.xml.util;
import java.io.IOException;
import javax.xml.stream.*;
public class StaxUtil
{
/**
* Adapter method used when only IOExceptions are declared to be thrown, but
* a {@link XMLStreamException} was caught.
*
* Note: dummy type variable is used for convenience, to allow caller to claim
* that this method returns result of any necessary type.
*/
public static T throwXmlAsIOException(XMLStreamException e) throws IOException
{
Throwable t = e;
while (t.getCause() != null) {
t = t.getCause();
}
if (t instanceof Error) throw (Error) t;
if (t instanceof RuntimeException) throw (RuntimeException) t;
throw new IOException(t);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy