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


Java UnmarshallerHandler.getResult方法代码示例

本文整理汇总了Java中javax.xml.bind.UnmarshallerHandler.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java UnmarshallerHandler.getResult方法的具体用法?Java UnmarshallerHandler.getResult怎么用?Java UnmarshallerHandler.getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.bind.UnmarshallerHandler的用法示例。


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

示例1: unmarshal

import javax.xml.bind.UnmarshallerHandler; //导入方法依赖的package包/类
protected org.kuali.rice.core.impl.config.property.Config unmarshal(Unmarshaller unmarshaller, InputStream in)
        throws SAXException, ParserConfigurationException, IOException,
        IllegalStateException, JAXBException {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);

    XMLFilter filter = new ConfigNamespaceURIFilter();
    filter.setParent(spf.newSAXParser().getXMLReader());

    UnmarshallerHandler handler = unmarshaller.getUnmarshallerHandler();
    filter.setContentHandler(handler);

    filter.parse(new InputSource(in));

    return (org.kuali.rice.core.impl.config.property.Config) handler.getResult();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:JAXBConfigImpl.java

示例2: unmarshal

import javax.xml.bind.UnmarshallerHandler; //导入方法依赖的package包/类
public final Object unmarshal( Node node ) throws JAXBException {
    try {
        DOMScanner scanner = new DOMScanner();
        UnmarshallerHandler handler = new InterningUnmarshallerHandler( 
            createUnmarshallerHandler(new DOMLocator(scanner)));
        
        if(node instanceof Element)
            scanner.parse((Element)node,handler);
        else
        if(node instanceof Document)
            scanner.parse(((Document)node).getDocumentElement(),handler);
        else
            // no other type of input is supported
            throw new IllegalArgumentException();
        
        return handler.getResult();
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
开发者ID:nhrdl,项目名称:javacash,代码行数:21,代码来源:UnmarshallerImpl.java

示例3: unmarshall

import javax.xml.bind.UnmarshallerHandler; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "resource" })
public T unmarshall(final InputStream inputStream) throws JAXBException, TransformerException {
  final Unmarshaller unmarshaller = this.jaxbContext.createUnmarshaller();
  final UnmarshallerHandler unmarshallerHandler = unmarshaller.getUnmarshallerHandler();
  final Transformer transformer = this.inputTransformerTemplate.newTransformer();
  final SAXResult saxResult = new SAXResult(unmarshallerHandler);
  final StreamSource streamSource = new StreamSource(new NoneClosingInputStream(inputStream));
  transformer.transform(streamSource, saxResult);
  final Object result = unmarshallerHandler.getResult();
  return (T) result;
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:12,代码来源:JaxbTransformer.java

示例4: unmarshal

import javax.xml.bind.UnmarshallerHandler; //导入方法依赖的package包/类
public static Object unmarshal(String path, String contextPath, String namespace)
        throws JAXBException, SAXException, ParserConfigurationException,
        IOException {
    UnmarshallerHandler unmarshallerHandler = JAXBContext
            .newInstance(contextPath).createUnmarshaller()
            .getUnmarshallerHandler();
    XMLFilter xmlFilter = new NamespaceFilter(namespace);
    xmlFilter.setParent(
            SAXParserFactory.newInstance().newSAXParser().getXMLReader());
    xmlFilter.setContentHandler(unmarshallerHandler);
    xmlFilter.parse(new InputSource(Thread.currentThread()
            .getContextClassLoader().getResource(path).getPath()));
    return unmarshallerHandler.getResult();
}
 
开发者ID:sandor-balazs,项目名称:sentiment-analysis,代码行数:15,代码来源:AbstractXmlParser.java

示例5: init

import javax.xml.bind.UnmarshallerHandler; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static synchronized void init(URI uri, Class<?> callingClass) throws XMLSecurityException {
    if (initialized == null || uri != null && !uri.equals(initialized)) {
        try {
            JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
            final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
            SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            Schema schema = schemaFactory.newSchema(
                    ClassLoaderUtils.getResource("schemas/security-config.xsd", Init.class));
            unmarshaller.setSchema(schema);
            final UnmarshallerHandler unmarshallerHandler = unmarshaller.getUnmarshallerHandler();

            SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
            saxParserFactory.setXIncludeAware(false);
            saxParserFactory.setNamespaceAware(true);
            SAXParser saxParser = saxParserFactory.newSAXParser();
            if (uri == null) {
                URL resource = ClassLoaderUtils.getResource("security-config.xml", Init.class);
                if (resource == null) {
                    //kind of chicken-egg problem here
                    I18n.init("en", "US");
                    throw new XMLSecurityConfigurationException("empty", "security-config.xml not found in classpath");
                }
                uri = resource.toURI();
            }
            saxParser.parse(uri.toURL().toExternalForm(), new XIncludeHandler(unmarshallerHandler));
            JAXBElement<ConfigurationType> configurationTypeJAXBElement = (JAXBElement<ConfigurationType>) unmarshallerHandler.getResult();

            ConfigurationProperties.init(configurationTypeJAXBElement.getValue().getProperties(), callingClass);
            SecurityHeaderHandlerMapper.init(configurationTypeJAXBElement.getValue().getSecurityHeaderHandlers(), callingClass);
            JCEAlgorithmMapper.init(configurationTypeJAXBElement.getValue().getJCEAlgorithmMappings());
            TransformerAlgorithmMapper.init(configurationTypeJAXBElement.getValue().getTransformAlgorithms(), callingClass);
            ResourceResolverMapper.init(configurationTypeJAXBElement.getValue().getResourceResolvers(), callingClass);

            I18n.init(ConfigurationProperties.getProperty("DefaultLanguageCode"), ConfigurationProperties.getProperty("DefaultCountryCode"));

        } catch (Exception e) {
            //kind of chicken-egg problem here
            I18n.init("en", "US");
            throw new XMLSecurityConfigurationException(e);
        }
        initialized = uri;
    }
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:45,代码来源:Init.java

示例6: unmarshall

import javax.xml.bind.UnmarshallerHandler; //导入方法依赖的package包/类
protected T unmarshall(File filename, InputSource xml, HashMap<String,String> extra_overrides)
    throws Exception
{
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setXIncludeAware(true);
    spf.setNamespaceAware(true);
    spf.setFeature("http://apache.org/xml/features/xinclude/fixup-base-uris", false);

    StreamSource schemaSource = new StreamSource(this.getClass().getResourceAsStream("/sdrun.xsd"));

    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema = factory.newSchema(schemaSource);
    spf.setSchema(schema);

    NamespaceFiller filter = new NamespaceFiller(this.propertyOverrides(), extra_overrides);
    XMLReader xr = spf.newSAXParser().getXMLReader();
    filter.setParent(xr);

    Unmarshaller u = jc.createUnmarshaller();
    UnmarshallerHandler uh = u.getUnmarshallerHandler();
    u.setSchema(schema);
    u.setEventHandler(new DefaultValidationEventHandler());

    filter.setContentHandler(uh);
    try {
        filter.parse(xml);
    } catch(SAXParseException e) {
        filter.log_error(e);
        throw new XMLUnmarshallingFailure();
    }

    T result = (T) uh.getResult();
    if (result == null || filter.failed())
        throw new XMLUnmarshallingFailure();

    if (filter.conversion_hint)
        log.log(Logging.NOTICE,
                "Use the following command to convert old style files to the new format:\n" +
                "sed '1d; 2i <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\\n<SDRun xmlns:xi=\"http://www.w3.org/2001/XInclude\" xmlns=\"{}\">\n" +
                "s#<(reactionScheme|morphology|stimulation|initialConditions|outputScheme)File>\\s*(\\w+)\\s*</.*>#<xi:include href=\"\\2.xml\" />#' -r -i.bak \"{}\"",
                NEURORD_NS,
                filename != null ? filename : "...");

    return result;
}
 
开发者ID:neurord,项目名称:stochdiff,代码行数:46,代码来源:ModelReader.java


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