當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。