org.lastbamboo.common.sip.stack.message
Class SipMessageUtils

java.lang.Object
  extended by org.lastbamboo.common.sip.stack.message.SipMessageUtils

public class SipMessageUtils
extends Object

Collection of utility methods for handling SIP messages.


Method Summary
static Map<String,SipHeader> convertHeaders(Map<String,List<String>> headers)
           
static int extractContentLength(Map<String,SipHeader> headers)
           
static String extractCSeqMethod(SipHeader cseq)
           
static int extractCSeqNumber(SipMessage message)
           
static Map<String,String> extractHeaderParams(String headerValue)
           
static String extractName(String nameValue)
           
static InetSocketAddress extractNextHopFromVia(SipMessage message)
          Utility method for extracting the host and port information from the topmost Via header in a SIP message.
static InetAddress extractSentByFromVia(SipHeaderValue via)
          Extracts the sent-by host from a Via header.
static URI extractUri(SipHeader header)
          Extracts the URI from a header value.
static URI extractUriFromRequestLine(SipMessage request)
          Extracts the URI from the request line of a SIP message.
static String extractValue(String nameValue)
           
static String toParamString(Map paramsMap)
          Creates a paramater string from the specified map of parameter names and values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toParamString

public static String toParamString(Map paramsMap)
Creates a paramater string from the specified map of parameter names and values.

Parameters:
paramsMap - A map of parameter names to values.
Returns:
The parameter names and values as a string.

extractName

public static String extractName(String nameValue)
                          throws IOException
Throws:
IOException

extractValue

public static String extractValue(String nameValue)
                           throws IOException
Throws:
IOException

convertHeaders

public static Map<String,SipHeader> convertHeaders(Map<String,List<String>> headers)

extractHeaderParams

public static Map<String,String> extractHeaderParams(String headerValue)
                                              throws IOException
Throws:
IOException

extractCSeqMethod

public static String extractCSeqMethod(SipHeader cseq)

extractUri

public static URI extractUri(SipHeader header)
Extracts the URI from a header value. This method assumes the URI is within an opening "<" and a closing ">".

Parameters:
header - The header.
Returns:
A new URI from the header.

extractCSeqNumber

public static int extractCSeqNumber(SipMessage message)

extractUriFromRequestLine

public static URI extractUriFromRequestLine(SipMessage request)
                                     throws IOException
Extracts the URI from the request line of a SIP message. The request line must meet the form specified in RFC 3261, as in:

Request-Line = Method SP Request-URI SP SIP-Version CRLF

Parameters:
request - The SIP request.
Returns:
The request URI from the request line.
Throws:
IOException - If the request line does not match the expected syntax.

extractSentByFromVia

public static InetAddress extractSentByFromVia(SipHeaderValue via)
                                        throws UnknownHostException
Extracts the sent-by host from a Via header.

Parameters:
via - The Via header to extract the sent-by host from.
Returns:
The address for the host.
Throws:
UnknownHostException - If there's an error readin the host in the expected format.

extractNextHopFromVia

public static InetSocketAddress extractNextHopFromVia(SipMessage message)
                                               throws IOException
Utility method for extracting the host and port information from the topmost Via header in a SIP message.

Parameters:
message - The SIP message to extract the host and port from.
Returns:
The host and port indicated in the topmost Via.
Throws:
IOException - If there's an unexpected error reading the data.

extractContentLength

public static int extractContentLength(Map<String,SipHeader> headers)


Copyright © 2013 LittleShoot. All Rights Reserved.