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;
28import javax.sip.header.ExtensionHeader;
29
30/**
31 *
32 * @author aayush.bhatnagar
33 * Rancore Technologies Pvt Ltd, Mumbai India.
34 *
35 */
36public class PUserDatabase extends gov.nist.javax.sip.header.ParametersHeader  implements PUserDatabaseHeader,SIPHeaderNamesIms, ExtensionHeader{
37
38    private String databaseName;
39
40    /**
41     *
42     * @param databaseName
43     */
44    public PUserDatabase(String databaseName)
45    {
46        super(NAME);
47        this.databaseName = databaseName;
48    }
49
50    /**
51     * Default constructor.
52     */
53    public PUserDatabase() {
54        super(P_USER_DATABASE);
55    }
56
57    public String getDatabaseName() {
58
59        return this.databaseName;
60    }
61
62
63    public void setDatabaseName(String databaseName) {
64        if((databaseName==null)||(databaseName.equals(" ")))
65            throw new NullPointerException("Database name is null");
66        else
67            if(!databaseName.contains("aaa://"))
68        this.databaseName = new StringBuffer().append("aaa://").append(databaseName).toString();
69            else
70                this.databaseName = databaseName;
71
72    }
73
74    protected String encodeBody() {
75
76        StringBuffer retval = new StringBuffer();
77        retval.append("<");
78        if(getDatabaseName()!=null)
79        retval.append(getDatabaseName());
80
81        if (!parameters.isEmpty())
82            retval.append(SEMICOLON + this.parameters.encode());
83        retval.append(">");
84
85        return retval.toString();
86    }
87
88    public boolean equals(Object other)
89    {
90        return (other instanceof PUserDatabaseHeader) && super.equals(other);
91
92    }
93
94
95    public Object clone() {
96        PUserDatabase retval = (PUserDatabase) super.clone();
97        return retval;
98    }
99
100    public void setValue(String value) throws ParseException {
101        throw new ParseException(value,0);
102
103    }
104
105
106
107}
108