NIST SIP Parser and Stack (v1.2) API

gov.nist.javax.sip.header
Class SIPHeaderList

java.lang.Object
  |
  +--gov.nist.core.GenericObject
        |
        +--gov.nist.javax.sip.header.SIPObject
              |
              +--gov.nist.javax.sip.header.SIPHeader
                    |
                    +--gov.nist.javax.sip.header.SIPHeaderList
All Implemented Interfaces:
Cloneable, Collection, Header, List, Serializable, SIPHeaderNames
Direct Known Subclasses:
AcceptEncodingList, AcceptLanguageList, AcceptList, AlertInfoList, AllowEventsList, AllowList, AuthenticationInfoList, CallInfoList, ContactList, ContentEncodingList, ContentLanguageList, ErrorInfoList, ExtensionHeaderList, InReplyToList, ProxyAuthenticateList, ProxyRequireList, ReasonList, RecordRouteList, RequireList, RouteList, SupportedList, UnsupportedList, ViaList, WarningList, WWWAuthenticateList

public class SIPHeaderList
extends SIPHeader
implements List

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

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, ORGANIZATION, PRIORITY, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, PROXY_REQUIRE, RACK, REASON, RECORD_ROUTE, REPLY_TO, REQUIRE, RETRY_AFTER, ROUTE, RSEQ, SERVER, SUBJECT, SUBSCRIPTION_STATE, SUPPORTED, TIMESTAMP, TO, UNSUPPORTED, USER_AGENT, VIA, WARNING, WWW_AUTHENTICATE
 
Constructor Summary
SIPHeaderList(Class objclass, String hname)
          Constructor
SIPHeaderList(SIPObjectList hl, String hname)
          Constructor
SIPHeaderList(String hName)
          Constructor
SIPHeaderList(String classname, String hname)
          Constructor
 
Method Summary
 void add(int position, Object headerToAdd)
          Add an element at a specified position.
 void add(int index, SIPHeader 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(SIPHeader 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 top)
          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.
 SIPObject first()
          Initialize the iterator for a loop
 Object get(int index)
          Get the object at the specified location.
 SIPHeader getFirst()
          Get the first element of this list.
 SIPObjectList getHeaderList()
          Get the imbedded linked list.
 LinkedList 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.
 int indexOf(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(Object template)
          Template match against a template.
 void merge(Object mergeObject)
          Merge this with a given template.
 SIPObject next()
          Get the next element in the list .
 SIPObject next(ListIterator iterator)
          Get the next item for an iterative scan of the list
 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.
 void removeAll(Class cl)
          Remove all occurances of a given class of SIPObject from the SIP object list.
 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 index, Object obj)
           
 int size()
          Get the number of headers in the list.
 List subList(int index1, int index2)
           
 Object[] toArray()
          Array conversion.
 Object[] toArray(Object[] obj)
           
 String toString()
          Encode this to a string representation.
 
Methods inherited from class gov.nist.javax.sip.header.SIPHeader
getHeaderName, getHeaderValue, getName, getValue, setHeaderName
 
Methods inherited from class gov.nist.javax.sip.header.SIPObject
dbgPrint, replace, replace, replace, replace
 
Methods inherited from class gov.nist.core.GenericObject
getClassFromName, getMatcher, isMySubclass, setMatcher
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
hashCode
 

Constructor Detail

SIPHeaderList

public SIPHeaderList(SIPObjectList hl,
                     String hname)
Constructor

Parameters:
hl - SIPObjectList to set
hname - String to set

SIPHeaderList

public SIPHeaderList(String hName)
Constructor

Parameters:
hName - String to set

SIPHeaderList

public SIPHeaderList(Class objclass,
                     String hname)
Constructor

Parameters:
objclass - Class to set
hname - String to set

SIPHeaderList

public SIPHeaderList(String classname,
                     String hname)
Constructor

Parameters:
classname - String to set
hname - String to set
Method Detail

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

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(SIPHeader sipheader,
                boolean top)
Add to this list.

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

concatenate

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

Parameters:
other - SIPHeaderList to set
top - boolean to set
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 LinkedList 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.

first

public SIPObject first()
Initialize the iterator for a loop

Returns:
SIPObject first element of the list.

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 SIPObjectList 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

next

public SIPObject next()
Get the next element in the list . This is not thread safe and cannot handle nesting

Returns:
SIPObject next object in this list.

next

public SIPObject next(ListIterator iterator)
Get the next item for an iterative scan of the list

Parameters:
iterator - ListIterator
Returns:
SIPObject next object in this list.

removeAll

public void removeAll(Class cl)
Remove all occurances of a given class of SIPObject from the SIP object list.

Parameters:
cl - Class to set

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 set
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(GenericObject gobj)
index of an element.

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

add

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

Parameters:
index - location where to add the sipHeader.
sipHeader - SIPHeader structure to add.
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).
Returns:
true if obj is an instance of this class representing the same SIP Header as this, false otherwise.

match

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

Overrides:
match in class SIPObject
Parameters:
template - the match pattern to test against. The match object has to be of the same type (class). Primitive types and non-sip fields that are non null are matched for equality. Null in any field matches anything. Some book-keeping fields are ignored when making the comparison.

merge

public void merge(Object mergeObject)
Merge this with a given template.

Overrides:
merge in class SIPObject
Parameters:
mergeObject - the template to merge with.

clone

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

Specified by:
clone in interface Header
Overrides:
clone in class SIPObject
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

toString

public String toString()
Encode this to a string representation. This is an alias to the encode function above.

Specified by:
toString in interface Header
Overrides:
toString in class SIPObject
Returns:
string representation of Header

add

public void add(int position,
                Object headerToAdd)
Add an element at a specified position.

Specified by:
add in interface List
Parameters:
headerToAdd - -- the header to add.

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

retainAll

public boolean retainAll(Collection collection)
Specified by:
retainAll in interface List

set

public Object set(int index,
                  Object obj)
Specified by:
set in interface List

subList

public List subList(int index1,
                    int index2)
Specified by:
subList in interface List

toArray

public Object[] toArray(Object[] obj)
Specified by:
toArray in interface List

NIST SIP Parser and Stack (v1.2) API

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