javax.xml.bind.util.JAXBResult Java Examples
The following examples show how to use
javax.xml.bind.util.JAXBResult.
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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #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: 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 #12
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 #13
Source File: ExternalMetadataReader.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static JavaWsdlMappingType transformAndRead(Source src, boolean disableXmlSecurity) throws TransformerException, JAXBException { Source xsl = new StreamSource(Util.class.getResourceAsStream(TRANSLATE_NAMESPACES_XSL)); JAXBResult result = new JAXBResult(jaxbContext(disableXmlSecurity)); TransformerFactory tf = XmlUtil.newTransformerFactory(!disableXmlSecurity); Transformer transformer = tf.newTemplates(xsl).newTransformer(); transformer.transform(src, result); return getJavaWsdlMapping(result.getResult()); }
Example #14
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 #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: ExternalMetadataReader.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static JavaWsdlMappingType transformAndRead(Source src, boolean disableXmlSecurity) throws TransformerException, JAXBException { Source xsl = new StreamSource(Util.class.getResourceAsStream(TRANSLATE_NAMESPACES_XSL)); JAXBResult result = new JAXBResult(jaxbContext(disableXmlSecurity)); TransformerFactory tf = XmlUtil.newTransformerFactory(!disableXmlSecurity); Transformer transformer = tf.newTemplates(xsl).newTransformer(); transformer.transform(src, result); return getJavaWsdlMapping(result.getResult()); }
Example #17
Source File: ExternalMetadataReader.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static JavaWsdlMappingType transformAndRead(Source src, boolean disableXmlSecurity) throws TransformerException, JAXBException { Source xsl = new StreamSource(Util.class.getResourceAsStream(TRANSLATE_NAMESPACES_XSL)); JAXBResult result = new JAXBResult(jaxbContext(disableXmlSecurity)); TransformerFactory tf = XmlUtil.newTransformerFactory(!disableXmlSecurity); Transformer transformer = tf.newTemplates(xsl).newTransformer(); transformer.transform(src, result); return getJavaWsdlMapping(result.getResult()); }
Example #18
Source File: ExternalMetadataReader.java From hottub with GNU General Public License v2.0 | 5 votes |
public static JavaWsdlMappingType transformAndRead(Source src, boolean disableXmlSecurity) throws TransformerException, JAXBException { Source xsl = new StreamSource(Util.class.getResourceAsStream(TRANSLATE_NAMESPACES_XSL)); JAXBResult result = new JAXBResult(jaxbContext(disableXmlSecurity)); TransformerFactory tf = XmlUtil.newTransformerFactory(!disableXmlSecurity); Transformer transformer = tf.newTemplates(xsl).newTransformer(); transformer.transform(src, result); return getJavaWsdlMapping(result.getResult()); }
Example #19
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 #20
Source File: JDBCSQLXML.java From evosql with Apache License 2.0 | 5 votes |
/** * Retrieves a new Result for setting the XML value designated by this * SQLXML instance. * * @param resultClass The class of the result, or null. * @throws java.sql.SQLException if there is an error processing the XML * value or the state is not writable * @return for setting the XML value designated by this SQLXML instance. */ protected <T extends Result>T createResult( Class<T> resultClass) throws SQLException { checkWritable(); setWritable(false); setReadable(true); if (JAXBResult.class.isAssignableFrom(resultClass)) { // Must go first presently, since JAXBResult extends SAXResult // (purely as an implementation detail) and it's not possible // to instantiate a valid JAXBResult with a Zero-Args // constructor(or any subclass thereof, due to the finality of // its private UnmarshallerHandler) // FALL THROUGH... will throw an exception } else if ((resultClass == null) || StreamResult.class.isAssignableFrom(resultClass)) { return createStreamResult(resultClass); } else if (DOMResult.class.isAssignableFrom(resultClass)) { return createDOMResult(resultClass); } else if (SAXResult.class.isAssignableFrom(resultClass)) { return createSAXResult(resultClass); } else if (StAXResult.class.isAssignableFrom(resultClass)) { return createStAXResult(resultClass); } throw JDBCUtil.invalidArgument("resultClass: " + resultClass); }
Example #21
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 #22
Source File: ExternalMetadataReader.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static JavaWsdlMappingType transformAndRead(Source src, boolean disableXmlSecurity) throws TransformerException, JAXBException { Source xsl = new StreamSource(Util.class.getResourceAsStream(TRANSLATE_NAMESPACES_XSL)); JAXBResult result = new JAXBResult(jaxbContext(disableXmlSecurity)); TransformerFactory tf = XmlUtil.newTransformerFactory(!disableXmlSecurity); Transformer transformer = tf.newTemplates(xsl).newTransformer(); transformer.transform(src, result); return getJavaWsdlMapping(result.getResult()); }
Example #23
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 #24
Source File: ExternalMetadataReader.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static JavaWsdlMappingType transformAndRead(Source src, boolean disableXmlSecurity) throws TransformerException, JAXBException { Source xsl = new StreamSource(Util.class.getResourceAsStream(TRANSLATE_NAMESPACES_XSL)); JAXBResult result = new JAXBResult(jaxbContext(disableXmlSecurity)); TransformerFactory tf = XmlUtil.newTransformerFactory(!disableXmlSecurity); Transformer transformer = tf.newTemplates(xsl).newTransformer(); transformer.transform(src, result); return getJavaWsdlMapping(result.getResult()); }
Example #25
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 #26
Source File: ExternalMetadataReader.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static JavaWsdlMappingType transformAndRead(Source src, boolean disableXmlSecurity) throws TransformerException, JAXBException { Source xsl = new StreamSource(Util.class.getResourceAsStream(TRANSLATE_NAMESPACES_XSL)); JAXBResult result = new JAXBResult(jaxbContext(disableXmlSecurity)); TransformerFactory tf = XmlUtil.newTransformerFactory(!disableXmlSecurity); Transformer transformer = tf.newTemplates(xsl).newTransformer(); transformer.transform(src, result); return getJavaWsdlMapping(result.getResult()); }
Example #27
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 #28
Source File: ExternalMetadataReader.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static JavaWsdlMappingType transformAndRead(Source src, boolean disableXmlSecurity) throws TransformerException, JAXBException { Source xsl = new StreamSource(Util.class.getResourceAsStream(TRANSLATE_NAMESPACES_XSL)); JAXBResult result = new JAXBResult(jaxbContext(disableXmlSecurity)); TransformerFactory tf = XmlUtil.newTransformerFactory(!disableXmlSecurity); Transformer transformer = tf.newTemplates(xsl).newTransformer(); transformer.transform(src, result); return getJavaWsdlMapping(result.getResult()); }
Example #29
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); } }