Java Utililty Methods URI Value Check

List of utility methods to do URI Value Check

Description

The list of methods to do URI Value Check are organized into topic(s).

Method

booleanisAbsoluteURI(String path)
is Absolute URI
return URI.create(path).isAbsolute();
booleanisAbsoluteURI(String uri)
This is the same logic that we have in the runtime, in PageFlowRequestProcessor.
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;
...
booleanisAbsoluteUri(String uriAsString)
Determines whether a string is an absolute URI.
boolean result;
try {
    URI uri = urlToUri(uriAsString);
    result = uri.isAbsolute();
} catch (Exception e) {
    result = false;
return result;
...
booleanisAnyAddress(final URI u)
is Any Address
return u.getHost() == null && (u.getAuthority().equals("*") || u.getAuthority().startsWith("*:"));
booleanisAvailable(URI address)
is Available
try {
    InetAddress addr = InetAddress.getByName(address.getHost());
    int port = address.getPort();
    if (port == -1) { 
        return false;
    SocketAddress sockaddr = new InetSocketAddress(addr, port);
    Socket sock = new Socket();
...
booleanisBagUri(final URI uri)
Returns true if the scheme for uri is equal to bag , otherwise it returns false.
if (uri == null) {
    return false;
return BAG_URI_SCHEME.equals(uri.getScheme());
booleanisBase(URI base, URI uri)
is Base
String path = uri.getRawPath();
if (path == null || "/".equals(path)) {
    return true;
if (base != null) {
    URI rel = base.relativize(uri);
    if (rel.getRawPath() == null || rel.getRawPath().length() <= 0 || rel.equals(uri)) {
        return true;
...
booleanisDefaultPort(URI uri)
Returns true if the specified URI uses a standard port (i.e.
String scheme = uri.getScheme().toLowerCase();
int port = uri.getPort();
return port <= 0 || (port == 80 && scheme.equals("http")) || (port == 443 && scheme.equals("https"));
booleanisDirectory(URI orig)
If there is a directory at the other end of this URI return true.
if (!orig.getScheme().equals(PROTOCOL_FILE)) {
    return false;
return new File(orig.getPath()).isDirectory();
booleanisExtensionUri(final URI uri)
is Extension Uri
return uri.toString().startsWith(EXT_URI_PREFIX);