| 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 PT INOVACAO - EST DEPARTMENT and Aveiro University - Portugal) * |
| 28 |
*****************************************************************************/ |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
package gov.nist.javax.sip.header.ims; |
| 34 |
|
| 35 |
import java.text.ParseException; |
| 36 |
|
| 37 |
import javax.sip.header.ExtensionHeader; |
| 38 |
import javax.sip.header.Parameters; |
| 39 |
|
| 40 |
import gov.nist.core.NameValueList; |
| 41 |
import gov.nist.javax.sip.header.SIPHeader; |
| 42 |
|
| 43 |
/** |
| 44 |
* Privacy SIP header - RFC 3323. |
| 45 |
* |
| 46 |
* @author Miguel Freitas (IT) PT-Inovacao |
| 47 |
*/ |
| 48 |
|
| 49 |
|
| 50 |
public class Privacy |
| 51 |
extends SIPHeader |
| 52 |
implements PrivacyHeader, SIPHeaderNamesIms, ExtensionHeader |
| 53 |
{ |
| 54 |
|
| 55 |
/** |
| 56 |
* Privacy type |
| 57 |
*/ |
| 58 |
private String privacy; |
| 59 |
|
| 60 |
|
| 61 |
/** |
| 62 |
* Default constructor. |
| 63 |
*/ |
| 64 |
public Privacy() { |
| 65 |
super(PRIVACY); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Constructor given a privacy type |
| 70 |
*@param privacy |
| 71 |
*/ |
| 72 |
public Privacy(String privacy) |
| 73 |
{ |
| 74 |
this(); |
| 75 |
this.privacy = privacy; |
| 76 |
|
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
/** |
| 81 |
* Encode into a canonical string. |
| 82 |
* @return String. |
| 83 |
*/ |
| 84 |
public String encodeBody() |
| 85 |
{ |
| 86 |
return this.privacy; |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
/** |
| 92 |
* Get privacy type |
| 93 |
* @return privacy type |
| 94 |
*/ |
| 95 |
public String getPrivacy() |
| 96 |
{ |
| 97 |
return privacy; |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
/** |
| 103 |
* set the privacy type. |
| 104 |
* @param privacy -- privacy type to set. |
| 105 |
*/ |
| 106 |
|
| 107 |
public void setPrivacy(String privacy) throws ParseException |
| 108 |
{ |
| 109 |
|
| 110 |
if (privacy == null || privacy == "") |
| 111 |
throw new NullPointerException( |
| 112 |
"JAIN-SIP Exception, " |
| 113 |
+ " Privacy, setPrivacy(), privacy value is null or empty"); |
| 114 |
this.privacy = privacy; |
| 115 |
|
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* Suppress direct setting of values. |
| 120 |
* |
| 121 |
*/ |
| 122 |
public void setValue(String value) throws ParseException { |
| 123 |
throw new ParseException(value,0); |
| 124 |
|
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
public boolean equals(Object other) |
| 129 |
{ |
| 130 |
if (other instanceof PrivacyHeader) |
| 131 |
{ |
| 132 |
PrivacyHeader o = (PrivacyHeader) other; |
| 133 |
return (this.getPrivacy().equals( o.getPrivacy() )); |
| 134 |
} |
| 135 |
return false; |
| 136 |
|
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
public Object clone() { |
| 141 |
Privacy retval = (Privacy) super.clone(); |
| 142 |
if (this.privacy != null) |
| 143 |
retval.privacy = this.privacy; |
| 144 |
return retval; |
| 145 |
} |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
} |