本文整理汇总了Java中org.w3c.dom.ls.LSInput.getByteStream方法的典型用法代码示例。如果您正苦于以下问题:Java LSInput.getByteStream方法的具体用法?Java LSInput.getByteStream怎么用?Java LSInput.getByteStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.ls.LSInput
的用法示例。
在下文中一共展示了LSInput.getByteStream方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveEntity
import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
* Resolves the given resource and adapts the <code>LSInput</code>
* returned into an <code>InputSource</code>.
*/
public InputSource resolveEntity(String name, String publicId,
String baseURI, String systemId) throws SAXException, IOException {
if (fEntityResolver != null) {
LSInput lsInput = fEntityResolver.resolveResource(XML_TYPE, null, publicId, systemId, baseURI);
if (lsInput != null) {
final String pubId = lsInput.getPublicId();
final String sysId = lsInput.getSystemId();
final String baseSystemId = lsInput.getBaseURI();
final Reader charStream = lsInput.getCharacterStream();
final InputStream byteStream = lsInput.getByteStream();
final String data = lsInput.getStringData();
final String encoding = lsInput.getEncoding();
/**
* An LSParser looks at inputs specified in LSInput in
* the following order: characterStream, byteStream,
* stringData, systemId, publicId. For consistency
* with the DOM Level 3 Load and Save Recommendation
* use the same lookup order here.
*/
InputSource inputSource = new InputSource();
inputSource.setPublicId(pubId);
inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(systemId, baseSystemId) : systemId);
if (charStream != null) {
inputSource.setCharacterStream(charStream);
}
else if (byteStream != null) {
inputSource.setByteStream(byteStream);
}
else if (data != null && data.length() != 0) {
inputSource.setCharacterStream(new StringReader(data));
}
inputSource.setEncoding(encoding);
return inputSource;
}
}
return null;
}
示例2: resolveEntity
import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
* Resolves the given resource and adapts the <code>LSInput</code>
* returned into an <code>InputSource</code>.
*/
public InputSource resolveEntity(String name, String publicId,
String baseURI, String systemId) throws SAXException, IOException {
if (fEntityResolver != null) {
LSInput lsInput = fEntityResolver.resolveResource(XML_TYPE, null, publicId, systemId, baseURI);
if (lsInput != null) {
final String pubId = lsInput.getPublicId();
final String sysId = lsInput.getSystemId();
final String baseSystemId = lsInput.getBaseURI();
final Reader charStream = lsInput.getCharacterStream();
final InputStream byteStream = lsInput.getByteStream();
final String data = lsInput.getStringData();
final String encoding = lsInput.getEncoding();
/**
* An LSParser looks at inputs specified in LSInput in
* the following order: characterStream, byteStream,
* stringData, systemId, publicId. For consistency
* with the DOM Level 3 Load and Save Recommendation
* use the same lookup order here.
*/
InputSource inputSource = new InputSource();
inputSource.setPublicId(pubId);
inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(sysId, baseSystemId) : sysId);
if (charStream != null) {
inputSource.setCharacterStream(charStream);
}
else if (byteStream != null) {
inputSource.setByteStream(byteStream);
}
else if (data != null && data.length() != 0) {
inputSource.setCharacterStream(new StringReader(data));
}
inputSource.setEncoding(encoding);
return inputSource;
}
}
return null;
}
示例3: dom2xmlInputSource
import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
XMLInputSource dom2xmlInputSource(LSInput is) {
// need to wrap the LSInput with an XMLInputSource
XMLInputSource xis = null;
/**
* An LSParser looks at inputs specified in LSInput in
* the following order: characterStream, byteStream,
* stringData, systemId, publicId. For consistency
* have the same behaviour for XSLoader.
*/
// check whether there is a Reader
// according to DOM, we need to treat such reader as "UTF-16".
if (is.getCharacterStream() != null) {
xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
is.getBaseURI(), is.getCharacterStream(),
"UTF-16");
}
// check whether there is an InputStream
else if (is.getByteStream() != null) {
xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
is.getBaseURI(), is.getByteStream(),
is.getEncoding());
}
// if there is a string data, use a StringReader
// according to DOM, we need to treat such data as "UTF-16".
else if (is.getStringData() != null && is.getStringData().length() != 0) {
xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
is.getBaseURI(), new StringReader(is.getStringData()),
"UTF-16");
}
// otherwise, just use the public/system/base Ids
else {
xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
is.getBaseURI());
}
return xis;
}
示例4: testResolveResource
import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
@Test
public void testResolveResource() throws Exception {
MetsLSResolver resolver = MetsLSResolver.getInstance();
LSInput input = resolver.resolveResource(null, null, null, "http://www.openarchives.org/OAI/2.0/oai_dc.xsd", null);
assertNotNull(input);
InputStream stream = input.getByteStream();
assertNotNull(stream);
stream.close();
}
示例5: resolveEntity
import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
* Resolves the given resource and adapts the <code>LSInput</code>
* returned into an <code>InputSource</code>.
*/
public InputSource resolveEntity(String name, String publicId,
String baseURI, String systemId) throws SAXException, IOException {
if (fEntityResolver != null) {
LSInput lsInput = fEntityResolver.resolveResource(XML_TYPE, null, publicId, systemId, baseURI);
if (lsInput != null) {
final String pubId = lsInput.getPublicId();
final String sysId = lsInput.getSystemId();
final String baseSystemId = lsInput.getBaseURI();
final Reader charStream = lsInput.getCharacterStream();
final InputStream byteStream = lsInput.getByteStream();
final String data = lsInput.getStringData();
final String encoding = lsInput.getEncoding();
/**
* An LSParser looks at inputs specified in LSInput in
* the following order: characterStream, byteStream,
* stringData, systemId, publicId. For consistency
* with the DOM Level 3 Load and Save Recommendation
* use the same lookup order here.
*/
InputSource inputSource = new InputSource();
inputSource.setPublicId(pubId);
inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(sysId, baseSystemId) : sysId);
if (charStream != null) {
inputSource.setCharacterStream(charStream);
}
else if (byteStream != null) {
inputSource.setByteStream(byteStream);
}
else if (data != null && data.length() != 0) {
inputSource.setCharacterStream(new StringReader(data));
}
inputSource.setEncoding(encoding);
return inputSource;
}
}
return null;
}
示例6: resolveEntity
import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
* Resolves an external parsed entity. If the entity cannot be
* resolved, this method should return null.
*
* @param resourceIdentifier description of the resource to be revsoved
* @throws XNIException Thrown on general error.
* @throws IOException Thrown if resolved entity stream cannot be
* opened or some other i/o error occurs.
*/
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
throws XNIException, IOException {
// resolve entity using DOM entity resolver
if (fEntityResolver != null) {
// For entity resolution the type of the resource would be XML TYPE
// DOM L3 LS spec mention only the XML 1.0 recommendation right now
LSInput inputSource =
resourceIdentifier == null
? fEntityResolver.resolveResource(
null,
null,
null,
null,
null)
: fEntityResolver.resolveResource(
getType(resourceIdentifier),
resourceIdentifier.getNamespace(),
resourceIdentifier.getPublicId(),
resourceIdentifier.getLiteralSystemId(),
resourceIdentifier.getBaseSystemId());
if (inputSource != null) {
String publicId = inputSource.getPublicId();
String systemId = inputSource.getSystemId();
String baseSystemId = inputSource.getBaseURI();
InputStream byteStream = inputSource.getByteStream();
Reader charStream = inputSource.getCharacterStream();
String encoding = inputSource.getEncoding();
String data = inputSource.getStringData();
/**
* An LSParser looks at inputs specified in LSInput in
* the following order: characterStream, byteStream,
* stringData, systemId, publicId.
*/
XMLInputSource xmlInputSource =
new XMLInputSource(publicId, systemId, baseSystemId);
if (charStream != null) {
xmlInputSource.setCharacterStream(charStream);
}
else if (byteStream != null) {
xmlInputSource.setByteStream((InputStream) byteStream);
}
else if (data != null && data.length() != 0) {
xmlInputSource.setCharacterStream(new StringReader(data));
}
xmlInputSource.setEncoding(encoding);
return xmlInputSource;
}
}
// unable to resolve entity
return null;
}
示例7: resolveEntity
import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
* Resolves an external parsed entity. If the entity cannot be
* resolved, this method should return null.
*
* @param resourceIdentifier description of the resource to be revsoved
* @throws XNIException Thrown on general error.
* @throws IOException Thrown if resolved entity stream cannot be
* opened or some other i/o error occurs.
*/
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
throws XNIException, IOException {
// resolve entity using DOM entity resolver
if (fEntityResolver != null) {
// For entity resolution the type of the resource would be XML TYPE
// DOM L3 LS spec mention only the XML 1.0 recommendation right now
LSInput inputSource =
resourceIdentifier == null
? fEntityResolver.resolveResource(
null,
null,
null,
null,
null)
: fEntityResolver.resolveResource(
getType(resourceIdentifier),
resourceIdentifier.getNamespace(),
resourceIdentifier.getPublicId(),
resourceIdentifier.getLiteralSystemId(),
resourceIdentifier.getBaseSystemId());
if (inputSource != null) {
String publicId = inputSource.getPublicId();
String systemId = inputSource.getSystemId();
String baseSystemId = inputSource.getBaseURI();
InputStream byteStream = inputSource.getByteStream();
Reader charStream = inputSource.getCharacterStream();
String encoding = inputSource.getEncoding();
String data = inputSource.getStringData();
/**
* An LSParser looks at inputs specified in LSInput in
* the following order: characterStream, byteStream,
* stringData, systemId, publicId.
*/
XMLInputSource xmlInputSource =
new XMLInputSource(publicId, systemId, baseSystemId, true);
if (charStream != null) {
xmlInputSource.setCharacterStream(charStream);
}
else if (byteStream != null) {
xmlInputSource.setByteStream((InputStream) byteStream);
}
else if (data != null && data.length() != 0) {
xmlInputSource.setCharacterStream(new StringReader(data));
}
xmlInputSource.setEncoding(encoding);
return xmlInputSource;
}
}
// unable to resolve entity
return null;
}
示例8: dom2xmlInputSource
import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
* NON-DOM: convert LSInput to XNIInputSource
*
* @param is
* @return
*/
XMLInputSource dom2xmlInputSource (LSInput is) {
// need to wrap the LSInput with an XMLInputSource
XMLInputSource xis = null;
// check whether there is a Reader
// according to DOM, we need to treat such reader as "UTF-16".
if (is.getCharacterStream () != null) {
xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
is.getBaseURI (), is.getCharacterStream (),
"UTF-16");
}
// check whether there is an InputStream
else if (is.getByteStream () != null) {
xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
is.getBaseURI (), is.getByteStream (),
is.getEncoding ());
}
// if there is a string data, use a StringReader
// according to DOM, we need to treat such data as "UTF-16".
else if (is.getStringData () != null && is.getStringData().length() > 0) {
xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
is.getBaseURI (), new StringReader (is.getStringData ()),
"UTF-16");
}
// otherwise, just use the public/system/base Ids
else if ((is.getSystemId() != null && is.getSystemId().length() > 0) ||
(is.getPublicId() != null && is.getPublicId().length() > 0)) {
xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
is.getBaseURI ());
}
else {
// all inputs are null
if (fErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl();
error.fType = "no-input-specified";
error.fMessage = "no-input-specified";
error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
fErrorHandler.getErrorHandler().handleError(error);
}
throw new LSException(LSException.PARSE_ERR, "no-input-specified");
}
return xis;
}
示例9: createResolver
import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
public static Resolver createResolver(final LSResourceResolver resourceResolver) {
return new AbstractResolver() {
public void resolve(Identifier id, Input input) throws IOException, ResolverException {
if (input.isResolved())
return;
String base = id.getBase();
String publicId = null;
String type = null;
if (id instanceof ExternalIdentifier) {
publicId = ((ExternalIdentifier)id).getPublicId();
type = XML_TYPE;
}
else if (id instanceof XMLDocumentIdentifier)
type = ((XMLDocumentIdentifier)id).getNamespaceUri();
if (type == null) {
String mediaType = id.getMediaType();
if (mediaType.indexOf('*') < 0)
type = IANA_MEDIA_TYPE_URI + mediaType;
}
String targetNamespace = null;
if (id instanceof TargetNamespaceIdentifier)
targetNamespace = ((TargetNamespaceIdentifier)id).getTargetNamespace();
LSInput lsInput = resourceResolver.resolveResource(type, targetNamespace, publicId, id.getUriReference(), base);
if (lsInput == null)
return;
input.setEncoding(lsInput.getEncoding());
input.setUri(lsInput.getSystemId());
final Reader characterStream = lsInput.getCharacterStream();
if (characterStream != null) {
input.setCharacterStream(characterStream);
return;
}
final InputStream byteStream = lsInput.getByteStream();
if (byteStream != null) {
input.setByteStream(byteStream);
return;
}
final String stringData = lsInput.getStringData();
if (stringData != null) {
input.setCharacterStream(new StringReader(stringData));
return;
}
// we don't support redirecting to a public ID
}
};
}
示例10: resolveEntity
import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
* Resolves an external parsed entity. If the entity cannot be
* resolved, this method should return null.
*
* @param resourceIdentifier description of the resource to be revsoved
* @throws XNIException Thrown on general error.
* @throws IOException Thrown if resolved entity stream cannot be
* opened or some other i/o error occurs.
*/
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
throws XNIException, IOException {
// resolve entity using DOM entity resolver
if (fEntityResolver != null) {
// For entity resolution the type of the resource would be XML TYPE
// DOM L3 LS spec mention only the XML 1.0 recommendation right now
LSInput inputSource =
resourceIdentifier == null
? fEntityResolver.resolveResource(
null,
null,
null,
null,
null)
: fEntityResolver.resolveResource(
getType(resourceIdentifier),
resourceIdentifier.getNamespace(),
resourceIdentifier.getPublicId(),
resourceIdentifier.getLiteralSystemId(),
resourceIdentifier.getBaseSystemId());
if (inputSource != null) {
String publicId = inputSource.getPublicId();
String systemId = inputSource.getSystemId();
String baseSystemId = inputSource.getBaseURI();
InputStream byteStream = inputSource.getByteStream();
Reader charStream = inputSource.getCharacterStream();
String encoding = inputSource.getEncoding();
String data = inputSource.getStringData();
/**
* An LSParser looks at inputs specified in LSInput in
* the following order: characterStream, byteStream,
* stringData, systemId, publicId.
*/
XMLInputSource xmlInputSource =
new XMLInputSource(publicId, systemId, baseSystemId);
if (charStream != null) {
xmlInputSource.setCharacterStream(charStream);
}
else if (byteStream != null) {
xmlInputSource.setByteStream((InputStream) byteStream);
}
else if (data != null && data.length() != 0) {
xmlInputSource.setCharacterStream(new StringReader(data));
}
xmlInputSource.setEncoding(encoding);
return xmlInputSource;
}
}
// unable to resolve entity
return null;
}