当前位置: 首页>>代码示例>>Java>>正文


Java JAXBResult类代码示例

本文整理汇总了Java中javax.xml.bind.util.JAXBResult的典型用法代码示例。如果您正苦于以下问题:Java JAXBResult类的具体用法?Java JAXBResult怎么用?Java JAXBResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JAXBResult类属于javax.xml.bind.util包,在下文中一共展示了JAXBResult类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createResult

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
/**
 * 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 implmentation 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);
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:38,代码来源:JDBCSQLXML.java

示例2: readPayloadAsJAXB

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
@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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:JAXBMessage.java

示例3: getJAXBObject

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
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;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:19,代码来源:MCRXSL2JAXBTransformer.java

示例4: transformTtmlDocument

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
/**
 * Does TTML document transformation to another TTML document.
 *
 * @param tt          source TTML document root element
 * @param transformer transformer
 * @return TTML document after transformation
 */
public static TtEltype transformTtmlDocument(TtEltype tt, Transformer transformer) {
    JAXBElement<TtEltype> ttJaxb = new ObjectFactory().createTt(tt);
    try {
        JAXBContext jaxbc = createTtmlJaxbContext();
        JAXBSource source = new JAXBSource(jaxbc, ttJaxb);
        JAXBResult result = new JAXBResult(jaxbc);

        // transform
        transformer.transform(source, result);

        return (TtEltype) ((JAXBElement<TtEltype>) result.getResult()).getValue();
    } catch (JAXBException | TransformerException e) {
        throw new ConvertException(e);
    }
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:23,代码来源:TtmlUtils.java

示例5: write

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:proarc,项目名称:proarc,代码行数:20,代码来源:DcStreamEditor.java

示例6: createResult

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:38,代码来源:JDBCSQLXML.java

示例7: createResult

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
/**
 * 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 implmentation 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 Util.invalidArgument("resultClass: " + resultClass);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:38,代码来源:JDBCSQLXML.java

示例8: readAsJAXB

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:JAXBHeader.java

示例9: transformAndRead

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
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());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:ExternalMetadataReader.java

示例10: transformToObject

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
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;
}
 
开发者ID:Transkribus,项目名称:TranskribusCore,代码行数:10,代码来源:JaxbUtils.java

示例11: xsltTransform

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
private static JAXBResult xsltTransform(Unmarshaller unmarshaller,
		Document document) throws JAXBException, TransformerException,
		TransformerConfigurationException,
		TransformerFactoryConfigurationError {
	JAXBResult result = new JAXBResult(unmarshaller);
	StreamSource source = new StreamSource(
			GpxUnmarshaller.class
					.getResourceAsStream("/data/gpx/xsl/gpx10to11.xsl"));
	TransformerFactory.newInstance().newTransformer(source)
			.transform(new DOMSource(document), result);
	return result;
}
 
开发者ID:pfichtner,项目名称:jrunalyzer,代码行数:13,代码来源:GpxUnmarshaller.java

示例12: readPayloadAsJAXB

import javax.xml.bind.util.JAXBResult; //导入依赖的package包/类
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();
        bridge.marshal(jaxbObject,out);
        out.getHandler().endDocument();
    } catch (SAXException e) {
        throw new JAXBException(e);
    }
    return (T)out.getResult();
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:13,代码来源:JAXBMessage.java


注:本文中的javax.xml.bind.util.JAXBResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。