FileDocCategorySizeDatePackage
NameMap.javaAPI DocphoneME MR2 API (J2ME)5264Wed May 02 18:00:42 BST 2007gov.nist.siplite.header

NameMap

public class NameMap extends Object
A mapping class that returns the Header for a given header name.

Fields Summary
static Hashtable
nameMap
Contents of the name mapping table.
Constructors Summary
Methods Summary
public static java.lang.StringexpandHeaderName(java.lang.String headerName)
Checks if the parameter is a short form of some header's name and if this is true, expands it to the full form.

param
headerName the name to expand
return
the expanded name or the source name if it was not expanded

        /*
         * Support for short forms of header names.
         *
         * i call-id; m contact; e content-encoding; l content-length;
         * c content-type; f from; s subject; k supported; t to; v via;
         * o event; r refer-to
         */
        String   shortNames = "imelcfsktvoura";
        String[] fullNames = {
            Header.CALL_ID, Header.CONTACT, Header.CONTENT_ENCODING,
            Header.CONTENT_LENGTH, Header.CONTENT_TYPE, Header.FROM,
            Header.SUBJECT, Header.SUPPORTED, Header.TO, Header.VIA,
            Header.EVENT, Header.ALLOW_EVENTS, Header.REFER_TO,
            Header.ACCEPT_CONTACT
        };
        String name = headerName;

        if (name.length() == 1) {
            int idx = shortNames.indexOf(name.toLowerCase().charAt(0));
            if (idx != -1) {
                name = fullNames[idx];
            }
        }

        return name;
    
public static java.lang.ClassgetClassFromName(java.lang.String headerName)
Looks up the class to use from the header field label.

param
headerName the key for looking up class handler
return
the class handler for requested header field

        return (Class) nameMap.get(headerName.toLowerCase());
    
private static voidinitializeNameMap()
Initializes the header to class mapping table.

        nameMap = new Hashtable();

        putNameMap(Header.CSEQ, CSeqHeader.clazz); // 1

        putNameMap(Header.RECORD_ROUTE, RecordRouteHeader.clazz); // 2

        putNameMap(Header.VIA, ViaHeader.clazz); // 3

        putNameMap(Header.FROM, FromHeader.clazz); // 4

        putNameMap(Header.CALL_ID, CallIdHeader.clazz); // 5

        putNameMap(Header.MAX_FORWARDS, MaxForwardsHeader.clazz); // 6


        putNameMap(Header.PROXY_AUTHENTICATE,
                ProxyAuthenticateHeader.clazz); // 7

        putNameMap(Header.CONTENT_TYPE, ContentTypeHeader.clazz); // 8

        putNameMap(Header.CONTENT_LENGTH, ContentLengthHeader.clazz); // 9

        putNameMap(Header.ROUTE, RouteHeader.clazz); // 10

        putNameMap(Header.CONTACT, ContactHeader.clazz); // 11

        putNameMap(Header.WWW_AUTHENTICATE,
                WWWAuthenticateHeader.clazz); // 12

        putNameMap(Header.PROXY_AUTHORIZATION,
                ProxyAuthorizationHeader.clazz); // 13

        putNameMap(Header.DATE, DateHeader.clazz); // 14

        putNameMap(Header.EXPIRES, ExpiresHeader.clazz); // 15

        putNameMap(Header.AUTHORIZATION, AuthorizationHeader.clazz); // 16

        putNameMap(Header.TO, ToHeader.clazz); // 17 -- mg

        putNameMap(Header.EVENT, EventHeader.clazz); // 18

        putNameMap(Header.SUBSCRIPTION_STATE, SubscriptionStateHeader.clazz);

        putNameMap(Header.RSEQ, RSeqHeader.clazz); // 20

        putNameMap(Header.RACK, RAckHeader.clazz); // 21

        putNameMap(Header.ACCEPT_CONTACT, AcceptContactHeader.clazz); // 22
    
public static booleanisHeaderSupported(java.lang.String headerName)
Checks if requested header is supported.

param
headerName the key for looking up class handler
return
true if the header has a class handler

        return nameMap.containsKey(headerName);
    
protected static voidputNameMap(java.lang.String headerName, java.lang.Class clazz)
Adds an entry to the name map table.

param
headerName the header field label key
param
clazz the class that handles the processing of the named header

        initializeNameMap();
    
        nameMap.put(headerName.toLowerCase(), clazz);