NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

gov.nist.javax.sip.header
Class SIPHeaderList

java.lang.Object
  extended bygov.nist.core.GenericObject
      extended bygov.nist.javax.sip.header.SIPObject
          extended bygov.nist.javax.sip.header.SIPHeader
              extended bygov.nist.javax.sip.header.SIPHeaderList
All Implemented Interfaces:
Cloneable, Collection, Header, List, Serializable, SIPHeaderNames
Direct Known Subclasses:
AcceptEncodingList, AcceptLanguageList, AcceptList, AlertInfoList, AllowEventsList, AllowList, AssociatedURIList, AuthenticationInfoList, AuthorizationList, CallInfoList, ContactList, ContentEncodingList, ContentLanguageList, ErrorInfoList, ExtensionHeaderList, InReplyToList, MediaAuthorizationList, PathList, PrivacyList, ProxyAuthenticateList, ProxyAuthorizationList, ProxyRequireList, ReasonList, RecordRouteList, RequireList, RouteList, ServiceRouteList, SupportedList, UnsupportedList, ViaList, VisitedNetworkIDList, WarningList, WWWAuthenticateList

public class SIPHeaderList
extends SIPHeader
implements List, Header

This is the root class for all lists of SIP headers. It imbeds a SIPObjectList object and extends SIPHeader Lists of ContactSIPObjects etc. derive from this class. This supports homogeneous lists (all elements in the list are of the same class). We use this for building type homogeneous lists of SIPObjects that appear in SIPHeaders

Version:
1.2 $Revision: 1.5 $ $Date: 2005/10/09 18:47:53
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface gov.nist.javax.sip.header.SIPHeaderNames
ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ALERT_INFO, ALLOW, ALLOW_EVENTS, AUTHENTICATION_INFO, AUTHORIZATION, CALL_ID, CALL_INFO, CONTACT, CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_TYPE, CSEQ, DATE, ERROR_INFO, EVENT, EXPIRES, FROM, IN_REPLY_TO, MAX_FORWARDS, MIME_VERSION, MIN_EXPIRES, MIN_SE, ORGANIZATION, PRIORITY, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, PROXY_REQUIRE, RACK, REASON, RECORD_ROUTE, REFERRED_BY, REPLACES, REPLY_TO, REQUIRE, RETRY_AFTER, ROUTE, RSEQ, SERVER, SESSION_EXPIRES, SIP_ETAG, SIP_IF_MATCH, SUBJECT, SUBSCRIPTION_STATE, SUPPORTED, TIMESTAMP, TO, UNSUPPORTED, USER_AGENT, VIA, WARNING, WWW_AUTHENTICATE
 
Method Summary
 void add(int index, Object sipHeader)
          insert at a location.
 boolean add(Object objectToAdd)
          Concatenate the list of stuff that we are keeping around and also the text corresponding to these structures (that we parsed).
 void add(Object sipheader, boolean top)
          Add to this list.
 boolean addAll(Collection collection)
          Add a collection of headers.
 boolean addAll(int index, Collection collection)
          Add all the elements of this collection.
 void addFirst(Object obj)
          Concatenate the list of stuff that we are keeping around and also the text corresponding to these structures (that we parsed).
 void clear()
           
 Object clone()
          make a clone of this header list.
 void concatenate(SIPHeaderList other)
          Concatenate two compatible lists.
 void concatenate(SIPHeaderList other, boolean topFlag)
          Concatenate two compatible lists.
 boolean contains(Object header)
           
 boolean containsAll(Collection collection)
          Check if the list contains all the headers in this collection.
 String debugDump()
          convert to a string representation
 String debugDump(int indentation)
          convert to a string representation (for printing).
 String encode()
          Encode a list of sip headers.
 boolean equals(Object other)
          Equality comparison operator.
 Object get(int index)
          Get the object at the specified location.
 SIPHeader getFirst()
          Get the first element of this list.
 List getHeaderList()
          Get the imbedded linked list.
 List getHeadersAsEncodedStrings()
          Return a list of encoded strings (one for each sipheader).
 SIPHeader getLast()
          Get the last element of this list.
 Class getMyClass()
          Get the class for the headers of this list.
 String getName()
          Gets the unique string name of this Header.
 int hashCode()
          Gets a integer hashcode representation of the Header.
 int indexOf(gov.nist.core.GenericObject gobj)
          index of an element.
 int indexOf(Object obj)
          Return the index of a given object.
 boolean isEmpty()
          Empty check
 boolean isHeaderList()
          Return true if this is a header list (overrides the base class method which returns false).
 Iterator iterator()
          Return the iterator to the imbedded list.
 int lastIndexOf(Object obj)
          Get the last index of the given object.
 ListIterator listIterator()
          Get an initialized iterator for my imbedded list
 ListIterator listIterator(int position)
          Get the list iterator for a given position.
 boolean match(SIPHeaderList template)
          Template match against a template. null field in template indicates wild card match.
 void merge(SIPHeaderList mergeHdrList)
          Merge this with a given template.
 Object remove(int index)
          Remove the object at a given index.
 boolean remove(Object obj)
          Remove the given object.
 boolean remove(SIPHeader obj)
          Remove a sip header from this list of sip headers.
 boolean removeAll(Collection collection)
          Remove all the elements.
 void removeFirst()
          Remove the first element of this list.
 void removeLast()
          Remove the last element of this list.
 boolean retainAll(Collection collection)
           
 Object set(int position, Object sipHdr)
          Set a SIPHeader at a particular position in the list.
 int size()
          Get the number of headers in the list.
 List subList(int index1, int index2)
          Get a sublist of the list.
 Object[] toArray()
          Array conversion.
 Object[] toArray(Object[] array)
          Convert a list of headers to an array.
 
Methods inherited from class gov.nist.javax.sip.header.SIPHeader
getHeaderName, getHeaderValue, getValue, setHeaderName, toString
 
Methods inherited from class gov.nist.javax.sip.header.SIPObject
dbgPrint, match
 
Methods inherited from class gov.nist.core.GenericObject
getClassFromName, getMatcher, isMySubclass, makeClone, merge, setMatcher
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.sip.header.Header
toString
 

Method Detail

getName

public String getName()
Description copied from interface: Header
Gets the unique string name of this Header. A name constant is defined in each individual Header identifying each Header.

Specified by:
getName in interface Header
Overrides:
getName in class SIPHeader
Returns:
String headerName

add

public boolean add(Object objectToAdd)
Concatenate the list of stuff that we are keeping around and also the text corresponding to these structures (that we parsed).

Specified by:
add in interface List
Parameters:
objectToAdd -

addFirst

public void addFirst(Object obj)
Concatenate the list of stuff that we are keeping around and also the text corresponding to these structures (that we parsed).

Parameters:
obj - Genericobject to set

add

public void add(Object sipheader,
                boolean top)
Add to this list.

Parameters:
sipheader - SIPHeader to add.
top - is true if we want to add to the top of the list.

concatenate

public void concatenate(SIPHeaderList other,
                        boolean topFlag)
                 throws IllegalArgumentException
Concatenate two compatible lists. This appends or prepends the new list to the end of this list.

Parameters:
other - SIPHeaderList to set
topFlag - flag which indicates which end to concatenate the lists.
Throws:
IllegalArgumentException - if the two lists are not compatible

concatenate

public void concatenate(SIPHeaderList other)
                 throws IllegalArgumentException
Concatenate two compatible lists. This appends the new list to the end of this list (which is the most common mode for this operation).

Parameters:
other - SIPHeaderList
Throws:
IllegalArgumentException - if the two lists are not compatible

encode

public String encode()
Encode a list of sip headers. Headers are returned in cannonical form.

Overrides:
encode in class SIPHeader
Returns:
String encoded string representation of this list of headers. (Contains string append of each encoded header).

getHeadersAsEncodedStrings

public List getHeadersAsEncodedStrings()
Return a list of encoded strings (one for each sipheader).

Returns:
LinkedList containing encoded strings in this header list. an empty list is returned if this header list contains no sip headers.

getFirst

public SIPHeader getFirst()
Get the first element of this list.

Returns:
SIPHeader first element of the list.

getLast

public SIPHeader getLast()
Get the last element of this list.

Returns:
SIPHeader last element of the list.

getMyClass

public Class getMyClass()
Get the class for the headers of this list.

Returns:
Class of header supported by this list.

isEmpty

public boolean isEmpty()
Empty check

Specified by:
isEmpty in interface List
Returns:
boolean true if list is empty

listIterator

public ListIterator listIterator()
Get an initialized iterator for my imbedded list

Specified by:
listIterator in interface List
Returns:
the generated ListIterator

getHeaderList

public List getHeaderList()
Get the imbedded linked list.

Returns:
the imedded linked list of SIP headers.

listIterator

public ListIterator listIterator(int position)
Get the list iterator for a given position.

Specified by:
listIterator in interface List
Parameters:
position - position for the list iterator to return
Returns:
the generated list iterator

removeFirst

public void removeFirst()
Remove the first element of this list.


removeLast

public void removeLast()
Remove the last element of this list.


remove

public boolean remove(SIPHeader obj)
Remove a sip header from this list of sip headers.

Parameters:
obj - SIPHeader to remove
Returns:
boolean

debugDump

public String debugDump(int indentation)
convert to a string representation (for printing).

Overrides:
debugDump in class SIPObject
Parameters:
indentation - int to set
Returns:
String string representation of object (for printing).

debugDump

public String debugDump()
convert to a string representation

Overrides:
debugDump in class SIPObject
Returns:
String

toArray

public Object[] toArray()
Array conversion.

Specified by:
toArray in interface List
Returns:
SIPHeader []

indexOf

public int indexOf(gov.nist.core.GenericObject gobj)
index of an element.

Returns:
index of the given element (-1) if element does not exist.

add

public void add(int index,
                Object sipHeader)
         throws IndexOutOfBoundsException
insert at a location.

Specified by:
add in interface List
Parameters:
index - location where to add the sipHeader.
sipHeader - SIPHeader structure to add.
Throws:
IndexOutOfBoundsException

equals

public boolean equals(Object other)
Equality comparison operator.

Specified by:
equals in interface List
Overrides:
equals in class SIPObject
Parameters:
other - the other object to compare with. true is returned iff the classes match and list of headers herein is equal to the list of headers in the target (order of the headers is not important).

match

public boolean match(SIPHeaderList template)
Template match against a template. null field in template indicates wild card match.


merge

public void merge(SIPHeaderList mergeHdrList)
Merge this with a given template.

Parameters:
mergeHdrList - the template to merge with.

clone

public Object clone()
make a clone of this header list.

Specified by:
clone in interface Header
Returns:
clone of this Header.

size

public int size()
Get the number of headers in the list.

Specified by:
size in interface List

isHeaderList

public boolean isHeaderList()
Return true if this is a header list (overrides the base class method which returns false).

Overrides:
isHeaderList in class SIPHeader
Returns:
true

addAll

public boolean addAll(Collection collection)
Add a collection of headers.

Specified by:
addAll in interface List
Parameters:
collection - -- a collection containing the headers to add.

addAll

public boolean addAll(int index,
                      Collection collection)
Add all the elements of this collection.

Specified by:
addAll in interface List

clear

public void clear()
Specified by:
clear in interface List

contains

public boolean contains(Object header)
Specified by:
contains in interface List

containsAll

public boolean containsAll(Collection collection)
Check if the list contains all the headers in this collection.

Specified by:
containsAll in interface List
Parameters:
collection - -- the collection of headers to test against.

get

public Object get(int index)
Get the object at the specified location.

Specified by:
get in interface List
Parameters:
index - -- location from which to get the object.

indexOf

public int indexOf(Object obj)
Return the index of a given object.

Specified by:
indexOf in interface List
Parameters:
obj - -- object whose index to compute.

iterator

public Iterator iterator()
Return the iterator to the imbedded list.

Specified by:
iterator in interface List
Returns:
iterator to the imbedded list.

lastIndexOf

public int lastIndexOf(Object obj)
Get the last index of the given object.

Specified by:
lastIndexOf in interface List
Parameters:
obj - -- object whose index to find.

remove

public boolean remove(Object obj)
Remove the given object.

Specified by:
remove in interface List
Parameters:
obj - -- object to remove.

remove

public Object remove(int index)
Remove the object at a given index.

Specified by:
remove in interface List
Parameters:
index - -- index at which to remove the object

removeAll

public boolean removeAll(Collection collection)
Remove all the elements.

Specified by:
removeAll in interface List
See Also:
List.removeAll(java.util.Collection)

retainAll

public boolean retainAll(Collection collection)
Specified by:
retainAll in interface List
Parameters:
collection -
See Also:
List.retainAll(java.util.Collection)

subList

public List subList(int index1,
                    int index2)
Get a sublist of the list.

Specified by:
subList in interface List
See Also:
List.subList(int, int)

hashCode

public int hashCode()
Description copied from interface: Header
Gets a integer hashcode representation of the Header. This method overrides the hashcode method in java.lang.Object.

Specified by:
hashCode in interface List
Overrides:
hashCode in class SIPHeader
Returns:
-- the computed hashcode.
See Also:
Object.hashCode()

set

public Object set(int position,
                  Object sipHdr)
Set a SIPHeader at a particular position in the list.

Specified by:
set in interface List
See Also:
List.set(int, java.lang.Object)

toArray

public Object[] toArray(Object[] array)
Convert a list of headers to an array.

Specified by:
toArray in interface List
See Also:
List.toArray(java.lang.Object[])

NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

A product of the NIST/ITL Advanced Networking Technologies Division.
See conditions of use.
Submit a bug report or feature request.