本文整理汇总了Java中com.sun.org.apache.xerces.internal.util.URI.getQueryString方法的典型用法代码示例。如果您正苦于以下问题:Java URI.getQueryString方法的具体用法?Java URI.getQueryString怎么用?Java URI.getQueryString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xerces.internal.util.URI
的用法示例。
在下文中一共展示了URI.getQueryString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRelativeBaseURI
import com.sun.org.apache.xerces.internal.util.URI; //导入方法依赖的package包/类
/**
* Returns a URI, relative to the include parent's base URI, of the current
* [base URI]. For instance, if the current [base URI] was "dir1/dir2/file.xml"
* and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
* @return the relative URI
*/
protected String getRelativeBaseURI() throws MalformedURIException {
int includeParentDepth = getIncludeParentDepth();
String relativeURI = this.getRelativeURI(includeParentDepth);
if (isRootDocument()) {
return relativeURI;
}
else {
if (relativeURI.equals("")) {
relativeURI = fCurrentBaseURI.getLiteralSystemId();
}
if (includeParentDepth == 0) {
if (fParentRelativeURI == null) {
fParentRelativeURI =
fParentXIncludeHandler.getRelativeBaseURI();
}
if (fParentRelativeURI.equals("")) {
return relativeURI;
}
URI base = new URI(fParentRelativeURI, true);
URI uri = new URI(base, relativeURI);
/** Check whether the scheme components are equal. */
final String baseScheme = base.getScheme();
final String literalScheme = uri.getScheme();
if (!Objects.equals(baseScheme, literalScheme)) {
return relativeURI;
}
/** Check whether the authority components are equal. */
final String baseAuthority = base.getAuthority();
final String literalAuthority = uri.getAuthority();
if (!Objects.equals(baseAuthority, literalAuthority)) {
return uri.getSchemeSpecificPart();
}
/**
* The scheme and authority components are equal,
* return the path and the possible query and/or
* fragment which follow.
*/
final String literalPath = uri.getPath();
final String literalQuery = uri.getQueryString();
final String literalFragment = uri.getFragment();
if (literalQuery != null || literalFragment != null) {
final StringBuilder buffer = new StringBuilder();
if (literalPath != null) {
buffer.append(literalPath);
}
if (literalQuery != null) {
buffer.append('?');
buffer.append(literalQuery);
}
if (literalFragment != null) {
buffer.append('#');
buffer.append(literalFragment);
}
return buffer.toString();
}
return literalPath;
}
else {
return relativeURI;
}
}
}