    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class com.ibm.devtools.SIPNoTE.SIPMessage

    java.lang.Object
       |
       +----com.ibm.devtools.SIPNoTE.SIPMessage

public class SIPMessage
extends Object

This class represents a SIP 2.0 message, as described in version 4 of the SIP Internet Draft from the IETF. Not all request methods have been fully implemented. In fact, only REGISTER, UNREGISTER, MESSAGE, and LOCATE have machinery behind them. The rest have only stubs where the implementation should be made.

##

ACK
  Method type
BYE
  Method type
INVITE
  Method type
LOCATE
  Method type
MESSAGE
  Method type
OPTIONS
  Method type
REGISTER
  Method type
REQUEST
  Message type
RESPONSE
  Message type
UNKNOWN
  Unknown message type or method
UNREGISTER
  Method type

##

SIPMessage()

##

addFrom(FromEntity)
  Add a new From: header to this message.
addLocation(SIPurl)
  Add a new Location: header to this message.
addSubscription(String)
  Adds a new Subscribe: header to the message.
addTo(ToEntity[])
  Add a new To: header to this message.
addVia(ViaEntity)
  Adds a new Via: header above the other Via: headers.
getContentType()
  Get the Content-Type associated with the contents of this message.
getLocation()
  Get the contents of any Location: headers which were included in this message.
getMessageBody()
  Get the body of this message.
getMessageType()
  Get the type of message this is (request vs.
getMethod()
  Get the method to which this message belongs.
getOriginatorVia()
  Get the first Via: which was added to this message.
getReasonPhrase()
  Get the reason phrase associated with this response.
getRequestURI()
  Get the URL's from the request-line.
getStatusCode()
  Get the status code returned in this message.
getSubscriptions()
  Get the subscription information from all of the Subscribe: headers within this message.
readMessage(InputStream)
  Read a SIP message in from the specified InputStream.
setContentType(String)
  Sets the Content-Type header for this message.
setMessageBody(byte[])
  Sets the data for the message body.
setMessageType(int)
  Sets the type of this message.
setMethod(int)
  Sets the method associated with this message.
setReasonPhrase(String)
  Sets the reason-phrase associated with this response.
setRequestURI(SIPurl[])
  Sets the URI's to which this message should be sent.
setStatusCode(int)
  Sets the status code associated with this response.
writeMessage(OutputStream)
  Write the message out to the specified OutputStream.

##

UNKNOWN

     public static final int UNKNOWN

  Unknown message type or method

REQUEST

     public static final int REQUEST

  Message type

RESPONSE

     public static final int RESPONSE

  Message type

REGISTER

     public static final int REGISTER

  Method type

UNREGISTER

     public static final int UNREGISTER

  Method type

INVITE

     public static final int INVITE

  Method type

ACK

     public static final int ACK

  Method type

OPTIONS

     public static final int OPTIONS

  Method type

BYE

     public static final int BYE

  Method type

MESSAGE

     public static final int MESSAGE

  Method type

LOCATE

     public static final int LOCATE

  Method type

##

SIPMessage

     public SIPMessage()

##

writeMessage

     public void writeMessage(OutputStream out) throws MalformedMessageException

  Write the message out to the specified OutputStream.

  Parameters:
    out - The OutputStream to which the data should be written.
  Throws: MalformedMessageException
    Thrown when the SIP message does not fit within the specifications. This may mean, that required fields have not been set, are set incorrectly, or that something else went wrong.

readMessage

     public void readMessage(InputStream in) throws MalformedMessageException

  Read a SIP message in from the specified InputStream.

  Parameters:
    in - The InputStream from which the message should be read.
  Throws: MalformedMessageException
    Thrown when the SIP message which is read in is not well formed based upon the specification, and we are unable to fill in or fix the required information.

getMessageType

     public int getMessageType()

  Get the type of message this is (request vs. response).

  Returns:
    An integer representing the type of message.

setMessageType

     public void setMessageType(int type)

  Sets the type of this message.

  Parameters:
    type - The type of message this is.

getMethod

     public int getMethod()

  Get the method to which this message belongs.

  Returns:
    An integer representing the method.

setMethod

     public void setMethod(int type)

  Sets the method associated with this message.

  Parameters:
    type - The method which this message represents.

getRequestURI

     public SIPurl[] getRequestURI()

  Get the URL's from the request-line.

  Returns:
    An array of SIP URL's.

setRequestURI

     public void setRequestURI(SIPurl urls[])

  Sets the URI's to which this message should be sent.

  Parameters:
    urls - The array of URL's to be set on the request-line.

getStatusCode

     public int getStatusCode()

  Get the status code returned in this message. (For responses only.)

  Returns:
    An integer representing the status code.

setStatusCode

     public void setStatusCode(int code)

  Sets the status code associated with this response.

  Parameters:
    code - The status code to be sent.

getReasonPhrase

     public String getReasonPhrase()

  Get the reason phrase associated with this response.

  Returns:
    A string containing the returned reason-phrase.

setReasonPhrase

     public void setReasonPhrase(String reason)

  Sets the reason-phrase associated with this response.

  Parameters:
    reason - The reason to be sent.

getOriginatorVia

     public ViaEntity getOriginatorVia() throws MalformedHeaderException

  Get the first Via: which was added to this message. This indicates the originator of the message (we hope.)

  Returns:
    A ViaEntity with the originator information.
  Throws: MalformedHeaderException
    Thrown if the header line is syntactically invalid.

addVia

     public void addVia(ViaEntity via) throws MalformedMessageException

  Adds a new Via: header above the other Via: headers.

  Parameters:
    via - The ViaEntity to be added.
  Throws: MalformedMessageException
    Thrown if the addition of this header causes the message to be syntactically malformed.

getSubscriptions

     public String[] getSubscriptions()

  Get the subscription information from all of the Subscribe: headers within this message.

  Returns:
    An array of strings containing the subscriptions.

addSubscription

     public void addSubscription(String sub) throws MalformedMessageException

  Adds a new Subscribe: header to the message.

  Parameters:
    sub - The instance to be subscribed to.
  Throws: MalformedMessageException
    Thrown if the addition of this header line makes the message malformed.

getLocation

     public SIPurl[] getLocation() throws MalformedMessageException

  Get the contents of any Location: headers which were included in this message.

  Returns:
    An array of SIP URL's containing the location information.
  Throws: MalformedMessageException
    Thrown if the header from which we are trying to fetch the information is malformed.

addLocation

     public void addLocation(SIPurl loc) throws MalformedMessageException

  Add a new Location: header to this message.

  Parameters:
    loc - The SIP URL representing the location to be added.
  Throws: MalformedMessageException
    Thrown if the header which is being added causes the message to be malformed.

addTo

     public void addTo(ToEntity tolist[]) throws MalformedMessageException

  Add a new To: header to this message.

  Parameters:
    to - The ToEntity array containing the addresses to be added.
  Throws: MalformedMessageException
    Thrown if the header which is being added causes the message to be malformed.

addFrom

     public void addFrom(FromEntity from) throws MalformedMessageException

  Add a new From: header to this message.

  Parameters:
    from - The FromEntity representing the address to be added.
  Throws: MalformedMessageException
    Thrown if the header which is being added causes the message to be malformed.

setContentType

     public void setContentType(String type)

  Sets the Content-Type header for this message.

  Parameters:
    type - The string representing the type of content included.

getContentType

     public String getContentType()

  Get the Content-Type associated with the contents of this message.

  Returns:
    The string containing the content-type.

setMessageBody

     public void setMessageBody(byte data[])

  Sets the data for the message body.

  Parameters:
    data - The byte array which contains the data to be sent.

getMessageBody

     public byte[] getMessageBody()

  Get the body of this message.

  Returns:
    A byte array containing the contents of the message body.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index