Java Code Examples for javax.xml.bind.util.JAXBResult#getResult()
The following examples show how to use
javax.xml.bind.util.JAXBResult#getResult() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXBMessage.java From hottub with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 2
Source File: DcStreamEditor.java From proarc with GNU General Public License v3.0 | 6 votes |
@Deprecated public void write(DigitalObjectHandler handler, ModsDefinition mods, String model, long timestamp, String message) throws DigitalObjectException { try { JAXBSource jaxbSource = new JAXBSource(ModsUtils.defaultMarshaller(false), new cz.cas.lib.proarc.mods.ObjectFactory().createMods(mods)); // DO NOT include schemaLocation. Fedora validator does not accept it. Transformer t = DcUtils.modsTransformer(model); EditorResult result = editor.createResult(); JAXBResult jaxbResult = new JAXBResult(DcUtils.defaultUnmarshaller()); t.transform(jaxbSource, jaxbResult); JAXBElement<OaiDcType> elm = (JAXBElement<OaiDcType>) jaxbResult.getResult(); OaiDcType dc = elm.getValue(); addDigitalObjectMetadata(handler, dc); DcUtils.marshal(result, dc, false); editor.write(result, timestamp, message); } catch (TransformerException | JAXBException ex) { throw new DigitalObjectException(object.getPid(), ex); } }
Example 3
Source File: JAXBMessage.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 4
Source File: MCRXSL2JAXBTransformer.java From mycore with GNU General Public License v3.0 | 6 votes |
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; }
Example 5
Source File: JAXBMessage.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 6
Source File: JAXBMessage.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 7
Source File: JAXBMessage.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 8
Source File: JAXBMessage.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 9
Source File: JAXBMessage.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 10
Source File: JAXBMessage.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 11
Source File: JAXBHeader.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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); } }
Example 12
Source File: JAXBHeader.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); } }
Example 13
Source File: JAXBHeader.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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); } }
Example 14
Source File: JAXBHeader.java From hottub with GNU General Public License v2.0 | 5 votes |
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); } }
Example 15
Source File: JAXBHeader.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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); } }
Example 16
Source File: JAXBHeader.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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); } }
Example 17
Source File: JaxbUtils.java From TranskribusCore with GNU General Public License v3.0 | 5 votes |
public static <T> T transformToObject(File file, final String xslID, Class<T> targetClass, Class<?>... nestedClasses) throws TransformerException, SAXException, IOException, ParserConfigurationException, JAXBException{ JAXBContext jc = createJAXBContext(merge(targetClass, nestedClasses)); JAXBResult result = new JAXBResult(jc); XslTransformer.transform(file, xslID, result); // obtain the unmarshalled content tree @SuppressWarnings("unchecked") T object = (T) result.getResult(); return object; }
Example 18
Source File: JaxbUtils.java From TranskribusCore with GNU General Public License v3.0 | 5 votes |
public static <T> T transformToObject(File file, final String xslID, Map<String, Object> xslParams, Class<T> targetClass, Class<?>... nestedClasses) throws TransformerException, SAXException, IOException, ParserConfigurationException, JAXBException{ JAXBContext jc = createJAXBContext(merge(targetClass, nestedClasses)); JAXBResult result = new JAXBResult(jc); XslTransformer.transform(file, xslID, result, xslParams); // obtain the unmarshalled content tree @SuppressWarnings("unchecked") T object = (T) result.getResult(); return object; }
Example 19
Source File: JAXBHeader.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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); } }
Example 20
Source File: JAXBHeader.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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); } }