本文整理汇总了Java中com.thaiopensource.resolver.Identifier类的典型用法代码示例。如果您正苦于以下问题:Java Identifier类的具体用法?Java Identifier怎么用?Java Identifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Identifier类属于com.thaiopensource.resolver包,在下文中一共展示了Identifier类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import com.thaiopensource.resolver.Identifier; //导入依赖的package包/类
public SAXSource resolve(Identifier id) throws SAXException, IOException {
SAXInput input = new SAXInput();
try {
resolver.resolve(id, input);
if (!input.isResolved())
input.setUri(BasicResolver.resolveUri(id));
InputSource inputSource = SAX.createInputSource(id, input);
XMLReader xr = input.getXMLReader();
if (xr == null)
xr = createXMLReader();
return new SAXSource(xr, inputSource);
}
catch (ResolverException e) {
throw SAX.toSAXException(e);
}
}
示例2: createResolver
import com.thaiopensource.resolver.Identifier; //导入依赖的package包/类
public static Resolver createResolver(final URIResolver uriResolver) {
return new AbstractResolver() {
public void resolve(Identifier id, Input input) throws IOException, ResolverException {
if (input.isResolved())
return;
Source source;
try {
source = uriResolver.resolve(id.getUriReference(), id.getBase());
}
catch (TransformerException e) {
throw toResolverException(e);
}
if (source == null)
return;
if (source instanceof SAXSource) {
setInput(input, (SAXSource)source);
return;
}
InputSource in = SAXSource.sourceToInputSource(source);
if (in != null) {
SAX.setInput(input, in);
return;
}
// XXX handle StAXSource
throw new ResolverException("URIResolver returned unsupported subclass of Source");
}
};
}
示例3: resolve
import com.thaiopensource.resolver.Identifier; //导入依赖的package包/类
public void resolve(Identifier id, Input input) throws IOException, ResolverException {
if (input.isResolved())
return;
String publicId;
String entityName = null;
if (id instanceof ExternalIdentifier) {
publicId = ((ExternalIdentifier)id).getPublicId();
if (id instanceof ExternalEntityIdentifier)
entityName = ((ExternalEntityIdentifier)id).getEntityName();
else if (id instanceof ExternalDTDSubsetIdentifier)
entityName = "[dtd]";
}
else {
if (!promiscuous)
return;
publicId = null;
}
try {
InputSource inputSource;
if (entityName != null && entityResolver2 != null)
inputSource = entityResolver2.resolveEntity(entityName,
publicId,
id.getBase(),
id.getUriReference());
else
inputSource = entityResolver.resolveEntity(publicId, getSystemId(id));
if (inputSource != null)
setInput(input, inputSource);
}
catch (SAXException e) {
throw toResolverException(e);
}
}
示例4: getSystemId
import com.thaiopensource.resolver.Identifier; //导入依赖的package包/类
static String getSystemId(Identifier id) {
try {
return BasicResolver.resolveUri(id);
}
catch (ResolverException e) { }
return id.getUriReference();
}
示例5: createInputSource
import com.thaiopensource.resolver.Identifier; //导入依赖的package包/类
static InputSource createInputSource(Identifier id, Input input) {
InputSource inputSource = createInputSource(input);
if (id instanceof ExternalIdentifier)
inputSource.setPublicId(((ExternalIdentifier)id).getPublicId());
if (inputSource.getSystemId() == null)
inputSource.setSystemId(getSystemId(id));
return inputSource;
}
示例6: resolve
import com.thaiopensource.resolver.Identifier; //导入依赖的package包/类
public void resolve(Identifier id, Input input) throws
IOException,
ResolverException
{
if (!input.isResolved())
{
input.setUri(resolveUri(id));
}
}
示例7: createResolver
import com.thaiopensource.resolver.Identifier; //导入依赖的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
}
};
}
示例8: resolve
import com.thaiopensource.resolver.Identifier; //导入依赖的package包/类
public void resolve(Identifier id, Input input) {
URI baseUri = parseUri(id.getBase());
URI resolved = baseUri.resolve(id.getUriReference());
input.setUri(resolved.toString());
input.setByteStream(uriToResource(resolved));
}