示例#1
0
        /**
         * Compares two URL objects whether they refer to the same file. In the
         * comparison included are the URL components protocol, host, port and file.
         *
         * @param url1
         *            the first URL to be compared.
         * @param url2
         *            the second URL to be compared.
         * @return {@code true} if both URLs refer to the same file, {@code false}
         *         otherwise.
         */
        protected bool sameFile(URL url1, URL url2)
        {
            String s1 = url1.getProtocol();
            String s2 = url2.getProtocol();

            if (s1 != s2 && (s1 == null || !s1.equals(s2)))
            {
                return(false);
            }

            s1 = url1.getFile();
            s2 = url2.getFile();
            if (s1 != s2 && (s1 == null || !s1.equals(s2)))
            {
                return(false);
            }
            if (!hostsEqual(url1, url2))
            {
                return(false);
            }
            int p1 = url1.getPort();

            if (p1 == -1)
            {
                p1 = getDefaultPort();
            }
            int p2 = url2.getPort();

            if (p2 == -1)
            {
                p2 = getDefaultPort();
            }
            return(p1 == p2);
        }
示例#2
0
        /**
         * Returns the clear text representation of a given URL using HTTP format.
         *
         * @param url
         *            the URL object to be converted.
         * @return the clear text representation of the specified URL.
         * @see #parseURL
         * @see URL#toExternalForm()
         */
        protected internal String toExternalForm(URL url)
        {
            java.lang.StringBuilder answer = new java.lang.StringBuilder();
            answer.append(url.getProtocol());
            answer.append(':');
            String authority = url.getAuthority();

            if (authority != null && authority.length() > 0)
            {
                answer.append("//"); //$NON-NLS-1$
                answer.append(url.getAuthority());
            }

            String file = url.getFile();
            String refJ = url.getRef();

            if (file != null)
            {
                answer.append(file);
            }
            if (refJ != null)
            {
                answer.append('#');
                answer.append(refJ);
            }
            return(answer.toString());
        }
示例#3
0
        /**
         * Compares two URL objects whether they refer to the same file. In the
         * comparison included are the URL components protocol, host, port and file.
         *
         * @param url1
         *            the first URL to be compared.
         * @param url2
         *            the second URL to be compared.
         * @return {@code true} if both URLs refer to the same file, {@code false}
         *         otherwise.
         */
        protected bool sameFile(URL url1, URL url2)
        {
            String s1 = url1.getProtocol();
            String s2 = url2.getProtocol();
            if (s1 != s2 && (s1 == null || !s1.equals(s2)))
            {
                return false;
            }

            s1 = url1.getFile();
            s2 = url2.getFile();
            if (s1 != s2 && (s1 == null || !s1.equals(s2)))
            {
                return false;
            }
            if (!hostsEqual(url1, url2))
            {
                return false;
            }
            int p1 = url1.getPort();
            if (p1 == -1)
            {
                p1 = getDefaultPort();
            }
            int p2 = url2.getPort();
            if (p2 == -1)
            {
                p2 = getDefaultPort();
            }
            return p1 == p2;
        }
示例#4
0
        /**
         * Returns the clear text representation of a given URL using HTTP format.
         *
         * @param url
         *            the URL object to be converted.
         * @return the clear text representation of the specified URL.
         * @see #parseURL
         * @see URL#toExternalForm()
         */
        protected internal String toExternalForm(URL url)
        {
            java.lang.StringBuilder answer = new java.lang.StringBuilder();
            answer.append(url.getProtocol());
            answer.append(':');
            String authority = url.getAuthority();
            if (authority != null && authority.length() > 0)
            {
                answer.append("//"); //$NON-NLS-1$
                answer.append(url.getAuthority());
            }

            String file = url.getFile();
            String refJ = url.getRef();
            if (file != null)
            {
                answer.append(file);
            }
            if (refJ != null)
            {
                answer.append('#');
                answer.append(refJ);
            }
            return answer.toString();
        }