当前位置: 首页>>代码示例>>Java>>正文


Java URI.getQueryString方法代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:74,代码来源:XIncludeHandler.java


注:本文中的com.sun.org.apache.xerces.internal.util.URI.getQueryString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。