Example usage for org.apache.commons.httpclient URI allowed_authority

List of usage examples for org.apache.commons.httpclient URI allowed_authority

Introduction

In this page you can find the example usage for org.apache.commons.httpclient URI allowed_authority.

Prototype

BitSet allowed_authority

To view the source code for org.apache.commons.httpclient URI allowed_authority.

Click Source Link

Document

Those characters that are allowed for the authority component.

Usage

From source file:org.apache.airavata.gfac.bes.utils.URIUtils.java

public static String encodeAuthority(String uri) throws URIException {
    int start = uri.indexOf("//");
    if (start == -1)
        return uri;
    start++;// w  ww .  ja va 2s .co m
    int end = uri.indexOf("/", start + 1);
    if (end == -1)
        end = uri.indexOf("?", start + 1);
    if (end == -1)
        end = uri.indexOf("#", start + 1);
    if (end == -1)
        end = uri.length();
    String before = uri.substring(0, start + 1);
    String authority = uri.substring(start + 1, end);
    String after = uri.substring(end);
    authority = URIUtil.encode(authority, URI.allowed_authority);

    return before + authority + after;
}