use of jakarta.xml.bind.util.JAXBResult in project mycore by MyCoRe-Org.
the class MCRXSL2JAXBTransformer method getJAXBObject.
private T getJAXBObject(MCRContent source, XMLReader reader, TransformerHandler transformerHandler) throws JAXBException, IOException, SAXException {
checkContext();
JAXBResult result = new JAXBResult(context);
transformerHandler.setResult(result);
// Parse the source XML, and send the parse events to the
// TransformerHandler.
reader.parse(source.getInputSource());
Object parsedResult = result.getResult();
if (parsedResult instanceof JAXBElement<?>) {
@SuppressWarnings("unchecked") JAXBElement<T> jaxbElement = (JAXBElement<T>) parsedResult;
return jaxbElement.getValue();
}
@SuppressWarnings("unchecked") T jaxbResult = (T) result.getResult();
return jaxbResult;
}
use of jakarta.xml.bind.util.JAXBResult in project metro-jax-ws by eclipse-ee4j.
the class JAXBHeader method readAsJAXB.
public <T> T readAsJAXB(Unmarshaller unmarshaller) throws JAXBException {
try {
JAXBResult r = new JAXBResult(unmarshaller);
// bridge marshals a fragment, so we need to add start/endDocument by ourselves
r.getHandler().startDocument();
bridge.marshal(jaxbObject, r);
r.getHandler().endDocument();
return (T) r.getResult();
} catch (SAXException e) {
throw new JAXBException(e);
}
}
use of jakarta.xml.bind.util.JAXBResult in project metro-jax-ws by eclipse-ee4j.
the class JAXBMessage method readPayloadAsJAXB.
@Override
public <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException {
JAXBResult out = new JAXBResult(unmarshaller);
// since the bridge only produces fragments, we need to fire start/end document.
try {
out.getHandler().startDocument();
if (rawContext != null) {
Marshaller m = rawContext.createMarshaller();
m.setProperty("jaxb.fragment", Boolean.TRUE);
m.marshal(jaxbObject, out);
} else
bridge.marshal(jaxbObject, out);
out.getHandler().endDocument();
} catch (SAXException e) {
throw new JAXBException(e);
}
return (T) out.getResult();
}
use of jakarta.xml.bind.util.JAXBResult in project metro-jax-ws by eclipse-ee4j.
the class EprMarshalUnmarshalTester method testW3CEprMarshalling.
public void testW3CEprMarshalling() throws Exception {
JAXBContext ctx = JAXBContext.newInstance(W3CEndpointReference.class);
JAXBResult res = new JAXBResult(ctx);
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
builder.address("http://example.com");
W3CEndpointReference epr = builder.build();
// You will get the NPE
epr.writeTo(res);
}
use of jakarta.xml.bind.util.JAXBResult in project metro-jax-ws by eclipse-ee4j.
the class EprMarshalUnmarshalTester method testMSEprMarshalling1.
public void testMSEprMarshalling1() throws Exception {
JAXBContext ctx = JAXBContext.newInstance(com.sun.xml.ws.developer.MemberSubmissionEndpointReference.class);
JAXBResult res = new JAXBResult(ctx);
com.sun.xml.ws.developer.MemberSubmissionEndpointReference mepr = new com.sun.xml.ws.developer.MemberSubmissionEndpointReference();
mepr.writeTo(res);
}
Aggregations