本文整理汇总了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");
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}