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/******************************************************************************* 27 * Product of NIST/ITL Advanced Networking Technologies Division (ANTD). * 28 *******************************************************************************/ 29 30package gov.nist.javax.sip.header; 31 32import java.text.ParseException; 33import javax.sip.header.*; 34import java.util.*; 35 36/** 37 * Supported SIP Header. 38 * 39 * @version 1.2 $Revision: 1.5 $ $Date: 2009/07/17 18:57:38 $ 40 * 41 * @author M. Ranganathan <br/> 42 * @author Olivier Deruelle <br/> 43 * 44 * 45 * 46 */ 47public class Server extends SIPHeader implements ServerHeader { 48 49 /** 50 * Comment for <code>serialVersionUID</code> 51 */ 52 private static final long serialVersionUID = -3587764149383342973L; 53 /** Product tokens. 54 */ 55 protected List productTokens; 56 57 /** 58 * Return canonical form. 59 * @return String 60 */ 61 private String encodeProduct() { 62 StringBuffer tokens = new StringBuffer(); 63 ListIterator it = productTokens.listIterator(); 64 65 while (it.hasNext()) { 66 tokens.append((String) it.next()); 67 if (it.hasNext()) 68 tokens.append('/'); 69 else 70 break; 71 } 72 return tokens.toString(); 73 } 74 75 /** set the productToken field 76 * @param pt String to set 77 */ 78 public void addProductToken(String pt) { 79 productTokens.add(pt); 80 } 81 82 /** 83 * Constructor. 84 */ 85 public Server() { 86 super(NAME); 87 productTokens = new LinkedList(); 88 } 89 90 /** Encode only the body of this header. 91 *@return encoded value of the header. 92 */ 93 public String encodeBody() { 94 return encodeProduct(); 95 } 96 97 /** 98 * Returns the list value of the product parameter. 99 * 100 * @return the software of this UserAgentHeader 101 */ 102 public ListIterator getProduct() { 103 if (productTokens == null || productTokens.isEmpty()) 104 return null; 105 else 106 return productTokens.listIterator(); 107 } 108 109 /** 110 * Sets the product value of the UserAgentHeader. 111 * 112 * @param product - a List specifying the product value 113 * @throws ParseException which signals that an error has been reached 114 * unexpectedly while parsing the product value. 115 */ 116 public void setProduct(List product) throws ParseException { 117 if (product == null) 118 throw new NullPointerException( 119 "JAIN-SIP Exception, UserAgent, " 120 + "setProduct(), the " 121 + " product parameter is null"); 122 productTokens = product; 123 } 124} 125/* 126 * $Log: Server.java,v $ 127 * Revision 1.5 2009/07/17 18:57:38 emcho 128 * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project. 129 * 130 * Revision 1.4 2006/07/13 09:01:04 mranga 131 * Issue number: 132 * Obtained from: 133 * Submitted by: jeroen van bemmel 134 * Reviewed by: mranga 135 * Moved some changes from jain-sip-1.2 to java.net 136 * 137 * CVS: ---------------------------------------------------------------------- 138 * CVS: Issue number: 139 * CVS: If this change addresses one or more issues, 140 * CVS: then enter the issue number(s) here. 141 * CVS: Obtained from: 142 * CVS: If this change has been taken from another system, 143 * CVS: then name the system in this line, otherwise delete it. 144 * CVS: Submitted by: 145 * CVS: If this code has been contributed to the project by someone else; i.e., 146 * CVS: they sent us a patch or a set of diffs, then include their name/email 147 * CVS: address here. If this is your work then delete this line. 148 * CVS: Reviewed by: 149 * CVS: If we are doing pre-commit code reviews and someone else has 150 * CVS: reviewed your changes, include their name(s) here. 151 * CVS: If you have not had it reviewed then delete this line. 152 * 153 * Revision 1.3 2006/06/19 06:47:27 mranga 154 * javadoc fixups 155 * 156 * Revision 1.2 2006/06/16 15:26:28 mranga 157 * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak 158 * 159 * Revision 1.1.1.1 2005/10/04 17:12:35 mranga 160 * 161 * Import 162 * 163 * 164 * Revision 1.2 2004/01/22 13:26:29 sverker 165 * Issue number: 166 * Obtained from: 167 * Submitted by: sverker 168 * Reviewed by: mranga 169 * 170 * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags. 171 * 172 * CVS: ---------------------------------------------------------------------- 173 * CVS: Issue number: 174 * CVS: If this change addresses one or more issues, 175 * CVS: then enter the issue number(s) here. 176 * CVS: Obtained from: 177 * CVS: If this change has been taken from another system, 178 * CVS: then name the system in this line, otherwise delete it. 179 * CVS: Submitted by: 180 * CVS: If this code has been contributed to the project by someone else; i.e., 181 * CVS: they sent us a patch or a set of diffs, then include their name/email 182 * CVS: address here. If this is your work then delete this line. 183 * CVS: Reviewed by: 184 * CVS: If we are doing pre-commit code reviews and someone else has 185 * CVS: reviewed your changes, include their name(s) here. 186 * CVS: If you have not had it reviewed then delete this line. 187 * 188 */ 189