FileDocCategorySizeDatePackage
RequestLine.javaAPI DocphoneME MR2 API (J2ME)6189Wed May 02 18:00:42 BST 2007gov.nist.siplite.header

RequestLine

public class RequestLine extends GenericObject
RequestLine of SIP Request.

Fields Summary
protected URI
uri
Uri field. Note that this can be a SIP URI or a generic URI like tel URI.
protected String
method
Method field.
protected String
sipVersion
SipVersion field
public static Class
clazz
Class handle.
Constructors Summary
public RequestLine()
Default constructor.

        clazz = new RequestLine().getClass();
    
        sipVersion = "SIP/2.0";
    
public RequestLine(URI requestURI, String method)
Constructor given the request URI and the method.

param
requestURI the request URI
param
method the operation to perform

        this.uri = requestURI;
        this.method = method;
        this.sipVersion = "SIP/2.0";
    
Methods Summary
public java.lang.Objectclone()
Clone this request.

return
copt of the current object

        RequestLine retval = new RequestLine();
        if (this.uri != null)
            retval.uri = (URI) this.uri.clone();
        if (this.method != null)
            retval.method = new String(this.method);
        if (this.sipVersion != null)
            retval.sipVersion = new String(this.sipVersion);
        return (Object) retval;
    
public java.lang.Stringencode()
Encodes the request line as a String.

return
requestLine encoded as a string.

        StringBuffer encoding = new StringBuffer();
        if (method != null) {
            encoding.append(method);
            encoding.append(Separators.SP);
        }
        if (uri != null) {
            encoding.append(uri.encode());
            encoding.append(Separators.SP);
        }
        encoding .append(sipVersion + Separators.NEWLINE);
        return encoding.toString();
    
public booleanequals(java.lang.Object other)
Compare for equality.

param
other object to compare with. We assume that all fields are set.
return
true if the object matches

        boolean retval;
        if (! other.getClass().equals(this.getClass())) {
            return false;
        }
        RequestLine that = (RequestLine) other;
        try {
            retval = this.method.equals(that.method)
            && this.uri.equals(that.uri)
            && this.sipVersion.equals(that.sipVersion);
        } catch (NullPointerException ex) {
            retval = false;
        }
        return retval;
        
        
    
public java.lang.StringgetMethod()
Get the Method

return
method string.

        return method;
    
public java.lang.StringgetSipVersion()
Get the SIP version.

return
String

        return sipVersion;
    
public URIgetUri()
Gets the Request-URI.

return
the request URI

        return uri;
    
public java.lang.StringgetVersionMajor()
Get the major verrsion number.

return
String major version number

        if (sipVersion == null)
            return null;
        String major = null;
        boolean slash = false;
        for (int i = 0; i < sipVersion.length(); i++) {
            if (sipVersion.charAt(i) == '.") break;
            if (slash) {
                if (major == null)
                    major = "" + sipVersion.charAt(i);
                else major += sipVersion.charAt(i);
            }
            if (sipVersion.charAt(i) == '/") slash = true;
        }
        return major;
    
public java.lang.StringgetVersionMinor()
Get the minor version number.

return
String minor version number

        if (sipVersion == null)
            return null;
        String minor = null;
        boolean dot = false;
        for (int i = 0; i < sipVersion.length(); i++) {
            if (dot) {
                if (minor == null)
                    minor = "" + sipVersion.charAt(i);
                else minor += sipVersion.charAt(i);
            }
            if (sipVersion.charAt(i) == '.") dot = true;
        }
        return minor;
    
public voidsetMethod(java.lang.String method)
Set the method member

param
method String to set

        this.method = method;
    
public voidsetSIPVersion(java.lang.String sipVersion)
Set the SIP version.

param
sipVersion -- the SIP version to set.

        this.sipVersion = sipVersion;
    
public voidsetSipVersion(java.lang.String s)
Set the sipVersion member

param
s String to set

        sipVersion = s;
    
public voidsetUri(URI uri)
Set the uri member.

param
uri URI to set.

        this.uri = uri;