FileDocCategorySizeDatePackage
URI.javaAPI DocphoneME MR2 API (J2ME)6362Wed May 02 18:00:42 BST 2007gov.nist.siplite.address

URI

public class URI extends GenericObject
Implementation of the URI class. This code is in the public domain.

Fields Summary
public static final String
POSTDIAL
POST Dial method label text.
public static final String
PHONE_CONTEXT_TAG
Phone context parameter label text.
public static final String
ISUB
ISDN subaddress parameter label text.
public static final String
PROVIDER_TAG
Provider parameter label text.
public static final String
USER
User name parameter label text.
public static final String
TRANSPORT
Transport type parameter label text.
public static final String
METHOD
Method name parameter label text.
public static final String
TTL
Time to live parameter label text.
public static final String
MADDR
Mail address parameter label text.
public static final String
LR
LR parameter label text.
protected String
uriString
Imbedded URI.
protected String
scheme
Current URI scheme.
Constructors Summary
protected URI()
Constuctor.


          
      
public URI(String uriString)
Constructor given the URI string.

param
uriString The imbedded URI string.
throws
URISyntaxException When there is a syntaz error in the imbedded URI.

        try {
            this.uriString = uriString;
            int colPos = uriString.indexOf(":");

            if (colPos == -1) { // no ":"
                throw new ParseException("URI, no separator after scheme", 0);
            }

            // Don't check the scheme's name, because according
            // to the RFC 3261, p. 224 it may be almost any token,
            // not only 'sip' and 'sips'.

            // rfc3261: when symbol '@' is present in URI, user part
            // can't be empty
            String uriCutScheme = uriString.substring(colPos + 1);
            int symAtPos = uriCutScheme.indexOf("@");

            if (symAtPos == 0) { // first symbol is '@'
                throw new ParseException("URI, no user part", 0);
            }
        } catch (Throwable e) {
            throw new ParseException("URI, Bad URI format", 0);
        }
    
Methods Summary
public java.lang.Objectclone()
Overrides the base clone method.

return
The Cloned strucutre,

        try {
            return new URI(this.uriString);
        } catch (ParseException ex) {
            throw new RuntimeException(ex.getMessage() + this.uriString);
        }
    
public java.lang.Stringencode()
Encode the URI.

return
The encoded URI

        return uriString;
    
public java.lang.StringgetPlainURI()
Returns the URI part of the address (without parameters) i.e. scheme:user@host:port.

return
URI part of the address

        return encode();
    
public java.lang.StringgetScheme()
Returns the value of the "scheme" of this URI, for example "sip", "sips" or "tel".

return
the scheme paramter of the URI

        return scheme;
    
public booleanisSipURI()
This method determines if this is a URI with a scheme of "sip" or "sips".

return
true if the scheme is "sip" or "sips", false otherwise.

        return this instanceof SipURI;

    
public booleanisTelURL()
This method determines if this is a URI with a scheme of "tel"

return
true if the scheme is "tel", false otherwise.

          return this instanceof TelURL;
    
public voidsetScheme(java.lang.String sch)
Sets the value of the "scheme" of this URI, for example "sip", "sips" or "tel". Ref. RFC 3261, p. 224: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )

param
sch the scheme of this URI
throws
IllegalArgumentException if the scheme is invalid

        final String errMsg = "Invalid scheme format";
        char ch;

        // Check if the scheme is valid
        if (sch == null || !StringTokenizer.isAlpha(sch.charAt(0))) {
            throw new IllegalArgumentException(errMsg);
        }

        for (int i = 1; i < sch.length(); i++) {
            ch = sch.charAt(i);

            if (!StringTokenizer.isAlpha(ch) && !StringTokenizer.isDigit(ch) &&
                    (ch != '+") && (ch != '-") && (ch != '.")) {
                throw new IllegalArgumentException(errMsg);
            }
        }

        scheme = sch;
    
public java.lang.StringtoString()
Encodes this URI.

return
The encoded URI

        return this.encode();