NameMappublic class NameMap extends Object A mapping class that returns the Header for a given header name. |
Fields Summary |
---|
static Hashtable | nameMapContents of the name mapping table. |
Methods Summary |
---|
public static java.lang.String | expandHeaderName(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.
/*
* 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.Class | getClassFromName(java.lang.String headerName)Looks up the class to use from the header field label.
return (Class) nameMap.get(headerName.toLowerCase());
| private static void | initializeNameMap()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 boolean | isHeaderSupported(java.lang.String headerName)Checks if requested header is supported.
return nameMap.containsKey(headerName);
| protected static void | putNameMap(java.lang.String headerName, java.lang.Class clazz)Adds an entry to the name map table.
initializeNameMap();
nameMap.put(headerName.toLowerCase(), clazz);
|
|