⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uri.java

📁 Light in the box 抓取程序。 使用HttpClient
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     *     * @param scheme the scheme string     * @param host the host string     * @param path the path string     * @param fragment the fragment string     * @throws URIException If the new URI cannot be created.     * @see #getDefaultProtocolCharset     */    public URI(String scheme, String host, String path, String fragment)        throws URIException {        this(scheme, host, path, null, fragment);    }    /**     * Construct a general URI with the given relative URI string.     *     * @param base the base URI     * @param relative the relative URI string     * @throws URIException If the new URI cannot be created.     *      * @deprecated Use #URI(URI, String, boolean)     */    public URI(URI base, String relative) throws URIException {        this(base, new URI(relative));    }    /**     * Construct a general URI with the given relative URI string.     *     * @param base the base URI     * @param relative the relative URI string     * @param escaped <tt>true</tt> if URI character sequence is in escaped form.      *                <tt>false</tt> otherwise.     *       * @throws URIException If the new URI cannot be created.     *      * @since 3.0     */    public URI(URI base, String relative, boolean escaped) throws URIException {        this(base, new URI(relative, escaped));    }    /**     * Construct a general URI with the given relative URI.     * <p><blockquote><pre>     *   URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]     *   relativeURI   = ( net_path | abs_path | rel_path ) [ "?" query ]     * </pre></blockquote><p>     * Resolving Relative References to Absolute Form.     *     * <strong>Examples of Resolving Relative URI References</strong>     *     * Within an object with a well-defined base URI of     * <p><blockquote><pre>     *   http://a/b/c/d;p?q     * </pre></blockquote><p>     * the relative URI would be resolved as follows:     *     * Normal Examples     *     * <p><blockquote><pre>     *   g:h           =  g:h     *   g             =  http://a/b/c/g     *   ./g           =  http://a/b/c/g     *   g/            =  http://a/b/c/g/     *   /g            =  http://a/g     *   //g           =  http://g     *   ?y            =  http://a/b/c/?y     *   g?y           =  http://a/b/c/g?y     *   #s            =  (current document)#s     *   g#s           =  http://a/b/c/g#s     *   g?y#s         =  http://a/b/c/g?y#s     *   ;x            =  http://a/b/c/;x     *   g;x           =  http://a/b/c/g;x     *   g;x?y#s       =  http://a/b/c/g;x?y#s     *   .             =  http://a/b/c/     *   ./            =  http://a/b/c/     *   ..            =  http://a/b/     *   ../           =  http://a/b/     *   ../g          =  http://a/b/g     *   ../..         =  http://a/     *   ../../        =  http://a/      *   ../../g       =  http://a/g     * </pre></blockquote><p>     *     * Some URI schemes do not allow a hierarchical syntax matching the     * <hier_part> syntax, and thus cannot use relative references.     *     * @param base the base URI     * @param relative the relative URI     * @throws URIException If the new URI cannot be created.     */    public URI(URI base, URI relative) throws URIException {        if (base._scheme == null) {            throw new URIException(URIException.PARSING, "base URI required");        }        if (base._scheme != null) {            this._scheme = base._scheme;            this._authority = base._authority;            this._is_net_path = base._is_net_path;         }        if (base._is_opaque_part || relative._is_opaque_part) {            this._scheme = base._scheme;            this._is_opaque_part = base._is_opaque_part                 || relative._is_opaque_part;            this._opaque = relative._opaque;            this._fragment = relative._fragment;            this.setURI();            return;        }        boolean schemesEqual = Arrays.equals(base._scheme,relative._scheme);        if (relative._scheme != null                 && (!schemesEqual  || relative._authority != null)) {            this._scheme = relative._scheme;            this._is_net_path = relative._is_net_path;            this._authority = relative._authority;            if (relative._is_server) {                this._is_server = relative._is_server;                this._userinfo = relative._userinfo;                this._host = relative._host;                this._port = relative._port;            } else if (relative._is_reg_name) {                this._is_reg_name = relative._is_reg_name;            }            this._is_abs_path = relative._is_abs_path;            this._is_rel_path = relative._is_rel_path;            this._path = relative._path;        } else if (base._authority != null && relative._scheme == null) {            this._is_net_path = base._is_net_path;            this._authority = base._authority;            if (base._is_server) {                this._is_server = base._is_server;                this._userinfo = base._userinfo;                this._host = base._host;                this._port = base._port;            } else if (base._is_reg_name) {                this._is_reg_name = base._is_reg_name;            }        }        if (relative._authority != null) {            this._is_net_path = relative._is_net_path;            this._authority = relative._authority;            if (relative._is_server) {                this._is_server = relative._is_server;                this._userinfo = relative._userinfo;                this._host = relative._host;                this._port = relative._port;            } else if (relative._is_reg_name) {                this._is_reg_name = relative._is_reg_name;            }            this._is_abs_path = relative._is_abs_path;            this._is_rel_path = relative._is_rel_path;            this._path = relative._path;        }        // resolve the path and query if necessary        if (relative._authority == null             && (relative._scheme == null || schemesEqual)) {            if ((relative._path == null || relative._path.length == 0)                && relative._query == null) {                // handle a reference to the current document, see RFC 2396                 // section 5.2 step 2                this._path = base._path;                this._query = base._query;            } else {                this._path = resolvePath(base._path, relative._path);            }        }        // base._query removed        if (relative._query != null) {            this._query = relative._query;        }        // base._fragment removed        if (relative._fragment != null) {            this._fragment = relative._fragment;        }        this.setURI();        // reparse the newly built URI, this will ensure that all flags are set correctly.        // TODO there must be a better way to do this        parseUriReference(new String(_uri), true);    }    // --------------------------------------------------- Instance Variables    /** Version ID for serialization */    static final long serialVersionUID = 604752400577948726L;    /**     * Cache the hash code for this URI.     */    protected int hash = 0;    /**     * This Uniform Resource Identifier (URI).     * The URI is always in an "escaped" form, since escaping or unescaping     * a completed URI might change its semantics.       */    protected char[] _uri = null;    /**     * The charset of the protocol used by this URI instance.     */    protected String protocolCharset = null;    /**     * The default charset of the protocol.  RFC 2277, 2396     */    protected static String defaultProtocolCharset = "UTF-8";    /**     * The default charset of the document.  RFC 2277, 2396     * The platform's charset is used for the document by default.     */    protected static String defaultDocumentCharset = null;    protected static String defaultDocumentCharsetByLocale = null;    protected static String defaultDocumentCharsetByPlatform = null;    // Static initializer for defaultDocumentCharset    static {        Locale locale = Locale.getDefault();        // in order to support backward compatiblity        if (locale != null) {            defaultDocumentCharsetByLocale =                LocaleToCharsetMap.getCharset(locale);            // set the default document charset            defaultDocumentCharset = defaultDocumentCharsetByLocale;        }        // in order to support platform encoding        try {            defaultDocumentCharsetByPlatform = System.getProperty("file.encoding");        } catch (SecurityException ignore) {        }        if (defaultDocumentCharset == null) {            // set the default document charset            defaultDocumentCharset = defaultDocumentCharsetByPlatform;        }    }    /**     * The scheme.     */    protected char[] _scheme = null;    /**     * The opaque.     */    protected char[] _opaque = null;    /**     * The authority.     */    protected char[] _authority = null;    /**     * The userinfo.     */    protected char[] _userinfo = null;    /**     * The host.     */    protected char[] _host = null;    /**     * The port.     */    protected int _port = -1;    /**     * The path.     */    protected char[] _path = null;    /**     * The query.     */    protected char[] _query = null;    /**     * The fragment.     */    protected char[] _fragment = null;    /**     * The root path.     */    protected static final char[] rootPath = { '/' };    // ---------------------- Generous characters for each component validation    /**     * The percent "%" character always has the reserved purpose of being the     * escape indicator, it must be escaped as "%25" in order to be used as     * data within a URI.     */    protected static final BitSet percent = new BitSet(256);    // Static initializer for percent    static {        percent.set('%');    }    /**     * BitSet for digit.     * <p><blockquote><pre>     * digit    = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |     *            "8" | "9"     * </pre></blockquote><p>     */    protected static final BitSet digit = new BitSet(256);    // Static initializer for digit    static {        for (int i = '0'; i <= '9'; i++) {            digit.set(i);        }    }    /**     * BitSet for alpha.     * <p><blockquote><pre>     * alpha         = lowalpha | upalpha     * </pre></blockquote><p>     */    protected static final BitSet alpha = new BitSet(256);    // Static initializer for alpha    static {        for (int i = 'a'; i <= 'z'; i++) {            alpha.set(i);        }        for (int i = 'A'; i <= 'Z'; i++) {            alpha.set(i);        }    }    /**     * BitSet for alphanum (join of alpha &amp; digit).     * <p><blockquote><pre>     *  alphanum      = alpha | digit     * </pre></blockquote><p>     */    protected static final BitSet alphanum = new BitSet(256);    // Static initializer for alphanum    static {        alphanum.or(alpha);        alphanum.or(digit);    }    /**     * BitSet for hex.     * <p><blockquote><pre>     * hex           = digit | "A" | "B" | "C" | "D" | "E" | "F" |     *                         "a" | "b" | "c" | "d" | "e" | "f"     * </pre></blockquote><p>     */    protected static final BitSet hex = new BitSet(256);    // Static initializer for hex    static {        hex.or(digit);        for (int i = 'a'; i <= 'f'; i++) {            hex.set(i);        }        for (int i = 'A'; i <= 'F'; i++) {            hex.set(i);        }    }    /**     * BitSet for escaped.     * <p><blockquote><pre>     * escaped       = "%" hex hex     * </pre></blockquote><p>     */    protected static final BitSet escaped = new BitSet(256);    // Static initializer for escaped    static {        escaped.or(percent);        escaped.or(hex);    }    /**     * BitSet for mark.     * <p><blockquote><pre>     * mark          = "-" | "_" | "." | "!" | "~" | "*" | "'" |     *                 "(" | ")"     * </pre></blockquote><p>     */    protected static final BitSet mark = new BitSet(256);    // Static initializer for mark    static {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -