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

gov.nist.javax.sip.header
Class SIPHeaderList<HDR extends SIPHeader>

java.lang.Object
  extended by gov.nist.core.GenericObject
      extended by gov.nist.javax.sip.header.SIPObject
          extended by gov.nist.javax.sip.header.SIPHeader
              extended by gov.nist.javax.sip.header.SIPHeaderList<HDR>
All Implemented Interfaces:
HeaderExt, SIPHeaderNames, Serializable, Cloneable, Iterable<HDR>, Collection<HDR>, List<HDR>, Header
Direct Known Subclasses:
AcceptEncodingList, AcceptLanguageList, AcceptList, AlertInfoList, AllowEventsList, AllowList, AuthenticationInfoList, AuthorizationList, CallInfoList, ContactList, ContentEncodingList, ContentLanguageList, ErrorInfoList, ExtensionHeaderList, InReplyToList, PAssertedIdentityList, PAssociatedURIList, PathList, PMediaAuthorizationList, PrivacyList, ProxyAuthenticateList, ProxyAuthorizationList, ProxyRequireList, PVisitedNetworkIDList, ReasonList, RecordRouteList, RequireList, RouteList, SecurityClientList, SecurityServerList, SecurityVerifyList, ServiceRouteList, SupportedList, UnsupportedList, ViaList, WarningList, WWWAuthenticateList

public abstract class SIPHeaderList<HDR extends SIPHeader>
extends SIPHeader
implements List<HDR>, 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.15 $ $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, JOIN, 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
 boolean add(HDR objectToAdd)
          Concatenate the list of stuff that we are keeping around and also the text corresponding to these structures (that we parsed).
 void add(HDR sipheader, boolean top)
          Add to this list.
 void add(int index, HDR sipHeader)
          insert at a location.
 boolean addAll(Collection<? extends HDR> collection)
           
 boolean addAll(int index, Collection<? extends HDR> collection)
           
 void addFirst(HDR 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<HDR> other, boolean topFlag)
          Concatenate two compatible lists.
 boolean contains(Object header)
           
 boolean containsAll(Collection<?> 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.
 StringBuffer encode(StringBuffer buffer)
          Encode the header into the given StringBuffer.
 boolean equals(Object other)
          Equality comparison operator.
 HDR get(int index)
          Get the object at the specified location.
 Header getFirst()
          Get the first element of this list.
 List<HDR> getHeaderList()
          Get the imbedded linked list.
 List<String> getHeadersAsEncodedStrings()
          Return a list of encoded strings (one for each sipheader).
 Header getLast()
          Get the last element of this list.
 Class<HDR> getMyClass()
          Get the class for the headers of this list.
 String getName()
          Alias for getHaderName above.
 int hashCode()
          This is a pretty simple hashCode but satisfies requirements.
 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<HDR> iterator()
          Return the iterator to the imbedded list.
 int lastIndexOf(Object obj)
          Get the last index of the given object.
 ListIterator<HDR> listIterator()
          Get an initialized iterator for my imbedded list
 ListIterator<HDR> 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.
 boolean remove(HDR obj)
          Remove a sip header from this list of sip headers.
 HDR remove(int index)
          Remove the object at a given index.
 boolean remove(Object obj)
          Remove the given object.
 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)
           
 HDR set(int position, HDR sipHeader)
          Set a SIPHeader at a particular position in the list.
static void setPrettyEncode(boolean flag)
           
 int size()
          Get the number of headers in the list.
 List<HDR> subList(int index1, int index2)
          Get a sublist of the list.
 Object[] toArray()
          Array conversion.
<T> T[]
toArray(T[] 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 class: SIPHeader
Alias for getHaderName above.

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

add

public boolean add(HDR 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 Collection<HDR extends SIPHeader>
Specified by:
add in interface List<HDR extends SIPHeader>
Parameters:
objectToAdd -

addFirst

public void addFirst(HDR 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(HDR 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<HDR> 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

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).

encode

public StringBuffer encode(StringBuffer buffer)
Description copied from class: SIPObject
Encode the header into the given StringBuffer. Default implemation calls encode().

Overrides:
encode in class SIPHeader

getHeadersAsEncodedStrings

public List<String> 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 Header getFirst()
Get the first element of this list.

Returns:
SIPHeader first element of the list.

getLast

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

Returns:
SIPHeader last element of the list.

getMyClass

public Class<HDR> 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 Collection<HDR extends SIPHeader>
Specified by:
isEmpty in interface List<HDR extends SIPHeader>
Returns:
boolean true if list is empty

listIterator

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

Specified by:
listIterator in interface List<HDR extends SIPHeader>
Returns:
the generated ListIterator

getHeaderList

public List<HDR> getHeaderList()
Get the imbedded linked list.

Returns:
the imedded linked list of SIP headers.

listIterator

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

Specified by:
listIterator in interface List<HDR extends SIPHeader>
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(HDR 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 Collection<HDR extends SIPHeader>
Specified by:
toArray in interface List<HDR extends SIPHeader>
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,
                HDR sipHeader)
         throws IndexOutOfBoundsException
insert at a location.

Specified by:
add in interface List<HDR extends SIPHeader>
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 Collection<HDR extends SIPHeader>
Specified by:
equals in interface List<HDR extends SIPHeader>
Specified by:
equals in interface Header
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 the objects are euqal and false otherwise

match

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


clone

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

Specified by:
clone in interface Header
Overrides:
clone in class gov.nist.core.GenericObject
Returns:
clone of this Header.

size

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

Specified by:
size in interface Collection<HDR extends SIPHeader>
Specified by:
size in interface List<HDR extends SIPHeader>

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<? extends HDR> collection)
Specified by:
addAll in interface Collection<HDR extends SIPHeader>
Specified by:
addAll in interface List<HDR extends SIPHeader>

addAll

public boolean addAll(int index,
                      Collection<? extends HDR> collection)
Specified by:
addAll in interface List<HDR extends SIPHeader>

containsAll

public boolean containsAll(Collection<?> collection)
Specified by:
containsAll in interface Collection<HDR extends SIPHeader>
Specified by:
containsAll in interface List<HDR extends SIPHeader>

clear

public void clear()
Specified by:
clear in interface Collection<HDR extends SIPHeader>
Specified by:
clear in interface List<HDR extends SIPHeader>

contains

public boolean contains(Object header)
Specified by:
contains in interface Collection<HDR extends SIPHeader>
Specified by:
contains in interface List<HDR extends SIPHeader>

get

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

Specified by:
get in interface List<HDR extends SIPHeader>
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<HDR extends SIPHeader>
Parameters:
obj - -- object whose index to compute.

iterator

public Iterator<HDR> iterator()
Return the iterator to the imbedded list.

Specified by:
iterator in interface Iterable<HDR extends SIPHeader>
Specified by:
iterator in interface Collection<HDR extends SIPHeader>
Specified by:
iterator in interface List<HDR extends SIPHeader>
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<HDR extends SIPHeader>
Parameters:
obj - -- object whose index to find.

remove

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

Specified by:
remove in interface Collection<HDR extends SIPHeader>
Specified by:
remove in interface List<HDR extends SIPHeader>
Parameters:
obj - -- object to remove.

remove

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

Specified by:
remove in interface List<HDR extends SIPHeader>
Parameters:
index - -- index at which to remove the object

removeAll

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

Specified by:
removeAll in interface Collection<HDR extends SIPHeader>
Specified by:
removeAll in interface List<HDR extends SIPHeader>
See Also:
List.removeAll(java.util.Collection)

retainAll

public boolean retainAll(Collection<?> collection)
Specified by:
retainAll in interface Collection<HDR extends SIPHeader>
Specified by:
retainAll in interface List<HDR extends SIPHeader>
Parameters:
collection -
See Also:
List.retainAll(java.util.Collection)

subList

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

Specified by:
subList in interface List<HDR extends SIPHeader>
See Also:
List.subList(int, int)

hashCode

public int hashCode()
Description copied from class: SIPHeader
This is a pretty simple hashCode but satisfies requirements.

Specified by:
hashCode in interface Collection<HDR extends SIPHeader>
Specified by:
hashCode in interface List<HDR extends SIPHeader>
Specified by:
hashCode in interface Header
Overrides:
hashCode in class SIPHeader
Returns:
-- the computed hashcode.
See Also:
Object.hashCode()

set

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

Specified by:
set in interface List<HDR extends SIPHeader>
See Also:
List.set(int, java.lang.Object)

setPrettyEncode

public static void setPrettyEncode(boolean flag)

toArray

public <T> T[] toArray(T[] array)
Specified by:
toArray in interface Collection<HDR extends SIPHeader>
Specified by:
toArray in interface List<HDR extends SIPHeader>

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.