FileDocCategorySizeDatePackage
ListMap.javaAPI DocphoneME MR2 API (J2ME)4560Wed May 02 18:00:42 BST 2007gov.nist.siplite.message

ListMap

public class ListMap extends Object
A map of which of the standard headers may appear as a list

Fields Summary
private static Hashtable
headerListTable
A table that indicates whether a header has a list representation or not (to catch adding of the non-list form when a list exists.) Entries in this table allow you to look up the list form of a header (provided it has a list form).
Constructors Summary
Methods Summary
protected static HeaderListgetList(Header sipHeader)
Returns a list object for this header if it has an associated list object.

param
sipHeader the requested header with associated list
return
list object

        try {
            Class headerClass = sipHeader.getClass();
            Class listClass = (Class) headerListTable.get(headerClass);
            HeaderList shl =  (HeaderList) listClass.newInstance();
            shl.setHeaderName(sipHeader.getHeaderName());
            return shl;
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex)  {
            ex.printStackTrace();
        }
        return null;
    
protected static java.lang.ClassgetListClass(java.lang.Class sipHdrClass)
Gets the associated list class.

param
sipHdrClass the class to be checked
return
the list class

        return (Class) headerListTable.get(sipHdrClass);
    
protected static booleanhasList(Header sipHeader)
Returns true if this has an associated list object.

param
sipHeader the requested header to be checked
return
true if list is present

        if (sipHeader instanceof HeaderList)
            return false;
        else {
            Class headerClass = sipHeader.getClass();
            return headerListTable.get(headerClass) != null;
        }
    
protected static booleanhasList(java.lang.Class sipHdrClass)
Returns true if this has an associated list object.

param
sipHdrClass the class to be checked
return
true if listis present

        return headerListTable.get(sipHdrClass) != null;
    
private static voidinitializeListMap()
Builds a table mapping between objects that have a list form and the class of such objects.

        initializeListMap();
    
        headerListTable = new Hashtable();

        headerListTable.put(ExtensionHeader.clazz,
                new HeaderList().getClass());

        headerListTable.put(ParameterLessHeader.clazz,
                new HeaderList().getClass());

        headerListTable.put(ContactHeader.clazz,
                new ContactList().getClass());

        headerListTable.put(ViaHeader.clazz,
                new ViaList().getClass());

        headerListTable.put(WWWAuthenticateHeader.clazz,
                new WWWAuthenticateList().getClass());

        headerListTable.put(RouteHeader.clazz,
                new RouteList().getClass());

        headerListTable.put(ProxyAuthenticateHeader.clazz,
                new ProxyAuthenticateList().getClass());

        headerListTable.put(ProxyAuthorizationHeader.clazz,
                new HeaderList().getClass());

        headerListTable.put(RecordRouteHeader.clazz,
                new RecordRouteList().getClass());