Java URI Value Check isAbsoluteURI(String uri)

Here you can find the source of isAbsoluteURI(String uri)

Description

This is the same logic that we have in the runtime, in PageFlowRequestProcessor.

License

Apache License

Declaration

public static boolean isAbsoluteURI(String uri) 

Method Source Code

//package com.java2s;
/*/*from  w w w  . jav  a 2  s. c  om*/
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * $Header:$
 */

public class Main {
    /** 
     * This is the same logic that we have in the runtime, in PageFlowRequestProcessor.  Can't share the code, though.
     */
    public static boolean isAbsoluteURI(String uri) {
        //
        // This method needs to be fast, so it can't use java.net.URI.
        //
        if (uri.length() == 0 || uri.charAt(0) == '/')
            return false;

        for (int i = 0, len = uri.length(); i < len; ++i) {
            char c = uri.charAt(i);

            if (c == ':') {
                return true;
            } else if (c == '/') {
                return false;
            }
        }

        return false;
    }
}

Related

  1. isAbsoluteURI(String path)
  2. isAbsoluteUri(String uriAsString)
  3. isAnyAddress(final URI u)
  4. isAvailable(URI address)
  5. isBagUri(final URI uri)