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


Java LSInput.setByteStream方法代码示例

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


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

示例1: testLSInputParsingByteStream

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
@Test
public void testLSInputParsingByteStream() throws Exception {
    DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
    LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    LSInput src = impl.createLSInput();

    try (InputStream is = new FileInputStream(ASTROCAT)) {
        src.setByteStream(is);
        assertNotNull(src.getByteStream());
        // set certified accessor methods
        boolean origCertified = src.getCertifiedText();
        src.setCertifiedText(true);
        assertTrue(src.getCertifiedText());
        src.setCertifiedText(origCertified); // set back to orig

        src.setSystemId(filenameToURL(ASTROCAT));

        Document doc = domParser.parse(src);
        Element result = doc.getDocumentElement();
        assertEquals(result.getTagName(), "stardb");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:DocumentLSTest.java

示例2: parse

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
public Document parse(InputStream in)
  throws SAXException, IOException
{
  LSInput input = ls.createLSInput();
  input.setByteStream(in);
  try
    {
      return parser.parse(input);
    }
  catch (LSException e)
    {
      Throwable e2 = e.getCause();
      if (e2 instanceof IOException)
        throw (IOException) e2;
      else
        throw e;
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:19,代码来源:DomDocumentBuilder.java

示例3: loadContext

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
private void loadContext(final Collection<String> routes) {
    try {
        DOMImplementationRegistry reg = DOMImplementationRegistry.newInstance();
        DOMImplementationLS domImpl = (DOMImplementationLS) reg.getDOMImplementation("LS");
        LSParser parser = domImpl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);

        JAXBContext jaxbContext = JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        List<RouteDefinition> routeDefs = new ArrayList<>();
        for (String route : routes) {
            try (InputStream input = IOUtils.toInputStream(route, StandardCharsets.UTF_8)) {
                LSInput lsinput = domImpl.createLSInput();
                lsinput.setByteStream(input);

                Node routeElement = parser.parse(lsinput).getDocumentElement();
                routeDefs.add(unmarshaller.unmarshal(routeElement, RouteDefinition.class).getValue());
            }
        }
        camelContext.addRouteDefinitions(routeDefs);
    } catch (Exception e) {
        LOG.error("While loading Camel context {}", e);
        throw new CamelException(e);
    }
}
 
开发者ID:apache,项目名称:syncope,代码行数:25,代码来源:SyncopeCamelContext.java

示例4: resolveResource

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
	
	try {
		InputStream inputStream = new URL(new URL(baseURI), systemId).openStream();
		
		LSInput retval = new DefaultLSInput();
		retval.setByteStream(inputStream);
		retval.setBaseURI(baseURI);
		retval.setSystemId(systemId);
		retval.setPublicId(publicId);
		
		return retval;
	} catch(IOException e) {
		return null;
	}
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:18,代码来源:DefaultLSResourceResolver.java

示例5: getXmlSource

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
private LSInput getXmlSource(String xml1) {
    LSInput src = implLS.createLSInput();
    try {
        if (xml1.endsWith(".xml"))
            src.setByteStream(this.getClass().getResourceAsStream(XML_FILE_INTERNAL_DTD));
        else
            src.setStringData(xml1);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Exception occured: " + e.getMessage());
    }
    return src;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:Bug6290947.java

示例6: createLSInputEncoding

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
private LSInput createLSInputEncoding() {
    LSInput src = implLS.createLSInput();
    Assert.assertFalse(src == null, "Could not create LSInput from DOMImplementationLS");

    try {
        src.setByteStream(new ByteArrayInputStream(encodingXML.getBytes("UTF-16")));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        Assert.fail("Exception occured: " + e.getMessage());
    }
    return src;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:Bug6355326.java

示例7: parse

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
public static Document parse(InputStream stream)
{
	DOMImplementationLS impl = (DOMImplementationLS)REGISTRY.getDOMImplementation("LS");
	LSParser builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
	LSInput input=impl.createLSInput();
	input.setByteStream(stream);
	Document document = builder.parse(input);

	LinkedList<Pair<Node, Node>> removed=new LinkedList<>();
	removeBlankText(document, removed);
	for(Pair<Node, Node> r: removed) r.get0().removeChild(r.get1());
	
	return document;
}
 
开发者ID:cycentum,项目名称:birdsong-recognition,代码行数:15,代码来源:XmlUtils.java

示例8: resolveResource

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI)
{
    LOGGER.debug("==== Resolving '" + type + "' '" + namespaceURI + "' '" + publicId + "' '" + systemId + "' '" +
            baseURI + "'");
    LSInput lsInput = domImplementationLS.createLSInput();
    InputStream is = getXSDStream(systemId);
    if(is==null)return null;                
    lsInput.setByteStream(is);
    lsInput.setSystemId(systemId);
    lsInput.setBaseURI(baseURI);
    lsInput.setPublicId(publicId);
    LOGGER.debug("==== Resolved ====");
    return lsInput;            
}
 
开发者ID:ArticulatedSocialAgentsPlatform,项目名称:HmiCore,代码行数:15,代码来源:XSDValidationTest.java

示例9: resolveResource

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId,
		String systemId, String baseURI) {
	LSInput input = new DOMInputImpl();
	String resoureUrl = nmap.get(systemId);
	if (resoureUrl != null) {
		InputStream resourceAsStream = this.getClass().getResourceAsStream(resoureUrl);
		input.setByteStream(resourceAsStream);
		return input;
	}
	return null;
}
 
开发者ID:SferaLabsLLC,项目名称:imf-validation-tool,代码行数:13,代码来源:ImfResourceResolver.java

示例10: resolveResource

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
public LSInput resolveResource( String type, String namespaceURI, String publicId, String systemId, String baseURI )
{
    String resourceName = local.getProperty( systemId );
    if( resourceName == null )
    {
        System.out.println( "type: " + type );
        System.out.println( "namespaceURI: " + namespaceURI );
        System.out.println( "publicId: " + publicId );
        System.out.println( "systemId: " + systemId );
        System.out.println( "baseURI: " + baseURI );
        return null;
    }

    InputStream resource = getClass().getClassLoader().getResourceAsStream( resourceName );
    LSInput input;
    try
    {
        input = getLSInput();
    }
    catch( Exception e )
    {
        throw new UnsupportedOperationException( "Internal problem. Please report to [email protected] mailing list.", e  );
    }
    input.setBaseURI( baseURI );
    input.setByteStream( resource );
    input.setPublicId( publicId );
    input.setSystemId( systemId );
    return input;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:30,代码来源:QuikitResolver.java

示例11: resolveResource

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
 * @see org.w3c.dom.ls.LSResourceResolver#resolveResource(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
 */
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    if (!type.equals(XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
        return null;
    }
    LOG.error(type);
    LOG.error(namespaceURI);
    LOG.error(publicId);
    LOG.error(systemId);
    LOG.error(baseURI);
    String path = resolveSystemId(systemId);
    if (path == null) {
        return null;
    }
    LOG.debug("Looking up resource '" + path + "' for system id '" + systemId + "'");
    InputStream is = getClass().getClassLoader().getResourceAsStream(path);
    if (is == null) {
        String message = "Unable to find schema (" + path + ") for: " + systemId;
        LOG.error(message);
        throw new RuntimeException/*SAXException*/(message);
    }
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        DOMImplementation domImpl = builder.getDOMImplementation();
        DOMImplementationLS dils = (DOMImplementationLS) domImpl;
        LSInput input = dils.createLSInput();
        input.setByteStream(is);
        return input;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:36,代码来源:ClassLoaderLSResourceResolver.java

示例12: resolveResource

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    String location = URL_MAP.get(systemId);
    if (location == null) {
        throw new IllegalStateException("Unable to find mapping for:" + systemId);
    }
    InputStream is = this.getClass().getResourceAsStream(location);
    LSInput input = dls.createLSInput();
    input.setByteStream(is);
    input.setPublicId(publicId);
    input.setSystemId(systemId);
    return input;
}
 
开发者ID:proarc,项目名称:proarc,代码行数:14,代码来源:MetsLSResolver.java

示例13: resolveResource

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId,
        String baseURI) {
    LSInput lsInput = impl.createLSInput();
    InputStream is = getClass().getResourceAsStream("/" + systemId);
    if (is == null)
        return null;
    lsInput.setByteStream(is);
    return lsInput;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:10,代码来源:XMLUtils.java

示例14: parse

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
public void parse(final InputStream is) throws SAXException {
	Preconditions.checkNotNull(LOADER, "The parser could not be initialised");

	final LSInput input = new DOMInputImpl();
	input.setByteStream(is);

	model = LOADER.load(input);
}
 
开发者ID:dswarm,项目名称:dswarm-xsd2jsonschema,代码行数:9,代码来源:JsonSchemaParser.java

示例15: parse

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
@Override
public Element parse(final InputStream input) {
    try {
        final DOMImplementationRegistry reg = DOMImplementationRegistry.newInstance();
        final DOMImplementationLS impl = (DOMImplementationLS) reg.getDOMImplementation("LS");
        final LSParser parser = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);

        final LSInput lsinput = impl.createLSInput();
        lsinput.setByteStream(input);

        return parser.parse(lsinput).getDocumentElement();
    } catch (Exception e) {
        throw new IllegalArgumentException("Could not parse DOM", e);
    }
}
 
开发者ID:ashank,项目名称:Office-365-SDK-for-Android,代码行数:16,代码来源:DefaultDOMParserImpl.java


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