PProfileKey.java revision 600c7a4bbc7348167293eac928192e695b4ad5ba
1package gov.nist.javax.sip.header.ims;
2/*
3* Conditions Of Use
4*
5* This software was developed by employees of the National Institute of
6* Standards and Technology (NIST), an agency of the Federal Government.
7* Pursuant to title 15 Untied States Code Section 105, works of NIST
8* employees are not subject to copyright protection in the United States
9* and are considered to be in the public domain.  As a result, a formal
10* license is not needed to use the software.
11*
12* This software is provided by NIST as a service and is expressly
13* provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
14* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
15* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
16* AND DATA ACCURACY.  NIST does not warrant or make any representations
17* regarding the use of the software or the results thereof, including but
18* not limited to the correctness, accuracy, reliability or usefulness of
19* the software.
20*
21* Permission to use this software is contingent upon your acceptance
22* of the terms of this agreement
23*
24* .
25*
26*/
27import java.text.ParseException;
28
29import gov.nist.javax.sip.address.AddressImpl;
30import gov.nist.javax.sip.header.AddressParametersHeader;
31import javax.sip.header.ExtensionHeader;
32
33/**
34 *
35 * @author aayush.bhatnagar
36 * Rancore Technologies Pvt Ltd, Mumbai India.
37 *
38 */
39public class PProfileKey extends AddressParametersHeader implements PProfileKeyHeader, SIPHeaderNamesIms , ExtensionHeader {
40
41    public PProfileKey( ) {
42        super(P_PROFILE_KEY);
43
44    }
45
46    public PProfileKey(AddressImpl address)
47    {
48        super(NAME);
49        this.address = address;
50    }
51
52    @Override
53    protected String encodeBody() {
54
55        StringBuffer retval = new StringBuffer();
56
57        if (address.getAddressType() == AddressImpl.ADDRESS_SPEC) {
58            retval.append(LESS_THAN);
59        }
60        retval.append(address.encode());
61        if (address.getAddressType() == AddressImpl.ADDRESS_SPEC) {
62            retval.append(GREATER_THAN);
63        }
64        if (!parameters.isEmpty())
65            retval.append(SEMICOLON + this.parameters.encode());
66
67        return retval.toString();
68    }
69
70    public void setValue(String value) throws ParseException {
71        throw new ParseException(value,0);
72
73    }
74
75    public boolean equals(Object other)
76    {
77        return (other instanceof PProfileKey) && super.equals(other);
78
79    }
80
81
82    public Object clone() {
83        PProfileKey retval = (PProfileKey) super.clone();
84        return retval;
85    }
86
87}
88