1 /* 2 * Conditions Of Use 3 * 4 * This software was developed by employees of the National Institute of 5 * Standards and Technology (NIST), an agency of the Federal Government. 6 * Pursuant to title 15 Untied States Code Section 105, works of NIST 7 * employees are not subject to copyright protection in the United States 8 * and are considered to be in the public domain. As a result, a formal 9 * license is not needed to use the software. 10 * 11 * This software is provided by NIST as a service and is expressly 12 * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED 13 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF 14 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT 15 * AND DATA ACCURACY. NIST does not warrant or make any representations 16 * regarding the use of the software or the results thereof, including but 17 * not limited to the correctness, accuracy, reliability or usefulness of 18 * the software. 19 * 20 * Permission to use this software is contingent upon your acceptance 21 * of the terms of this agreement 22 * 23 * . 24 * 25 */ 26 package gov.nist.javax.sip.header; 27 import gov.nist.core.*; 28 import gov.nist.javax.sip.header.ims.*; 29 30 import java.util.Hashtable; 31 32 /** 33 * A mapping class that returns the SIPHeader for a given header name. 34 * Add new classes to this map if you are implementing new header types if 35 * you want some of the introspection based methods to work. 36 * @version 1.2 $Revision: 1.11 $ $Date: 2009/07/17 18:57:32 $ 37 * @since 1.1 38 */ 39 public class NameMap implements SIPHeaderNames, PackageNames { 40 static Hashtable nameMap; 41 static { initializeNameMap()42 initializeNameMap(); 43 } 44 putNameMap(String headerName, String className)45 protected static void putNameMap(String headerName, String className) { 46 nameMap.put( 47 headerName.toLowerCase(), 48 className); 49 } 50 getClassFromName(String headerName)51 public static Class getClassFromName(String headerName) { 52 String className = (String) nameMap.get(headerName.toLowerCase()); 53 if (className == null) 54 return null; 55 else { 56 try { 57 return Class.forName(className); 58 } catch (ClassNotFoundException ex) { 59 return null; 60 } 61 } 62 } 63 64 /** add an extension header to this map. 65 *@param headerName is the extension header name. 66 *@param className is the fully qualified class name that implements 67 * the header (does not have to belong to the nist-sip package). 68 * Use this if you want to use the introspection-based methods. 69 */ 70 addExtensionHeader( String headerName, String className)71 public static void addExtensionHeader( 72 String headerName, 73 String className) { 74 nameMap.put(headerName.toLowerCase(), className); 75 } 76 initializeNameMap()77 private static void initializeNameMap() { 78 nameMap = new Hashtable(); 79 putNameMap(MinExpires.NAME, MinExpires.class.getName()); // 1 80 81 putNameMap(ErrorInfo.NAME, ErrorInfo.class.getName()); // 2 82 83 putNameMap(MimeVersion.NAME, MimeVersion.class.getName()); // 3 84 85 putNameMap(InReplyTo.NAME, InReplyTo.class.getName()); // 4 86 87 putNameMap(Allow.NAME, Allow.class.getName()); // 5 88 89 putNameMap(ContentLanguage.NAME, ContentLanguage.class.getName()); // 6 90 91 putNameMap(CALL_INFO, CallInfo.class.getName()); //7 92 93 putNameMap(CSEQ, CSeq.class.getName()); //8 94 95 putNameMap(ALERT_INFO, AlertInfo.class.getName()); //9 96 97 putNameMap(ACCEPT_ENCODING, AcceptEncoding.class.getName()); //10 98 99 putNameMap(ACCEPT, Accept.class.getName()); //11 100 101 putNameMap(ACCEPT_LANGUAGE, AcceptLanguage.class.getName()); //12 102 103 putNameMap(RECORD_ROUTE, RecordRoute.class.getName()); //13 104 105 putNameMap(TIMESTAMP, TimeStamp.class.getName()); //14 106 107 putNameMap(TO, To.class.getName()); //15 108 109 putNameMap(VIA, Via.class.getName()); //16 110 111 putNameMap(FROM, From.class.getName()); //17 112 113 putNameMap(CALL_ID, CallID.class.getName()); //18 114 115 putNameMap(AUTHORIZATION, Authorization.class.getName()); //19 116 117 putNameMap(PROXY_AUTHENTICATE, ProxyAuthenticate.class.getName()); //20 118 119 putNameMap(SERVER, Server.class.getName()); //21 120 121 putNameMap(UNSUPPORTED, Unsupported.class.getName()); //22 122 123 putNameMap(RETRY_AFTER, RetryAfter.class.getName()); //23 124 125 putNameMap(CONTENT_TYPE, ContentType.class.getName()); //24 126 127 putNameMap(CONTENT_ENCODING, ContentEncoding.class.getName()); //25 128 129 putNameMap(CONTENT_LENGTH, ContentLength.class.getName()); //26 130 131 putNameMap(ROUTE, Route.class.getName()); //27 132 133 putNameMap(CONTACT, Contact.class.getName()); //28 134 135 putNameMap(WWW_AUTHENTICATE, WWWAuthenticate.class.getName()); //29 136 137 putNameMap(MAX_FORWARDS, MaxForwards.class.getName()); //30 138 139 putNameMap(ORGANIZATION, Organization.class.getName()); //31 140 141 putNameMap(PROXY_AUTHORIZATION, ProxyAuthorization.class.getName()); //32 142 143 putNameMap(PROXY_REQUIRE, ProxyRequire.class.getName()); //33 144 145 putNameMap(REQUIRE, Require.class.getName()); //34 146 147 putNameMap(CONTENT_DISPOSITION, ContentDisposition.class.getName()); //35 148 149 putNameMap(SUBJECT, Subject.class.getName()); //36 150 151 putNameMap(USER_AGENT, UserAgent.class.getName()); //37 152 153 putNameMap(WARNING, Warning.class.getName()); //38 154 155 putNameMap(PRIORITY, Priority.class.getName()); //39 156 157 putNameMap(DATE, SIPDateHeader.class.getName()); //40 158 159 putNameMap(EXPIRES, Expires.class.getName()); //41 160 161 putNameMap(SUPPORTED, Supported.class.getName()); //42 162 163 putNameMap(REPLY_TO, ReplyTo.class.getName()); // 43 164 165 putNameMap(SUBSCRIPTION_STATE, SubscriptionState.class.getName()); //44 166 167 putNameMap(EVENT, Event.class.getName()); //45 168 169 putNameMap(ALLOW_EVENTS, AllowEvents.class.getName()); //46 170 171 172 // pmusgrave - extensions 173 putNameMap(REFERRED_BY, "ReferredBy"); 174 putNameMap(SESSION_EXPIRES, "SessionExpires"); 175 putNameMap(MIN_SE, "MinSE"); 176 putNameMap(REPLACES, "Replaces"); 177 // jean deruelle 178 putNameMap(JOIN, "Join"); 179 180 181 // IMS Specific headers. 182 183 putNameMap(PAccessNetworkInfoHeader.NAME, PAccessNetworkInfo.class.getName()); 184 185 putNameMap(PAssertedIdentityHeader.NAME, PAssertedIdentity.class.getName()); 186 187 putNameMap(PAssociatedURIHeader.NAME, PAssociatedURI.class.getName()); 188 189 putNameMap(PCalledPartyIDHeader.NAME, PCalledPartyID.class.getName()); 190 191 putNameMap(PChargingFunctionAddressesHeader.NAME, PChargingFunctionAddresses.class.getName()); 192 193 putNameMap(PChargingVectorHeader.NAME,PChargingVector.class.getName()); 194 195 putNameMap(PMediaAuthorizationHeader.NAME,PMediaAuthorization.class.getName()); 196 197 putNameMap(Path.NAME, Path.class.getName()); 198 199 putNameMap(PPreferredIdentity.NAME, PPreferredIdentity.class.getName()); 200 201 putNameMap(Privacy.NAME,Privacy.class.getName()); 202 203 putNameMap(ServiceRoute.NAME, ServiceRoute.class.getName()); 204 205 putNameMap(PVisitedNetworkID.NAME, PVisitedNetworkID.class.getName()); 206 207 208 209 } 210 } 211