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*******************************************************************************/
29package gov.nist.javax.sip.header;
30
31import javax.sip.header.*;
32import java.text.ParseException;
33
34/**
35 * InReplyTo SIP Header.
36 *
37 * @version 1.2 $Revision: 1.6 $ $Date: 2009/07/17 18:57:31 $
38 *
39 * @author M. Ranganathan   <br/>
40 * @author Olivier Deruelle <br/>
41 *
42 *
43 */
44public class InReplyTo extends SIPHeader implements InReplyToHeader {
45
46    /**
47     * Comment for <code>serialVersionUID</code>
48     */
49    private static final long serialVersionUID = 1682602905733508890L;
50
51    protected CallIdentifier callId;
52
53    /** Default constructor
54     */
55    public InReplyTo() {
56        super(IN_REPLY_TO);
57    }
58
59    /** constructor
60     * @param cid CallIdentifier to set
61     */
62    public InReplyTo(CallIdentifier cid) {
63        super(IN_REPLY_TO);
64        callId = cid;
65    }
66
67    /**
68     * Sets the Call-Id of the InReplyToHeader. The CallId parameter uniquely
69     * identifies a serious of messages within a dialogue.
70     *
71     * @param callId - the string value of the Call-Id of this InReplyToHeader.
72     * @throws ParseException which signals that an error has been reached
73     * unexpectedly while parsing the callId value.
74     */
75    public void setCallId(String callId) throws ParseException {
76        try {
77            this.callId = new CallIdentifier(callId);
78        } catch (Exception e) {
79            throw new ParseException(e.getMessage(), 0);
80        }
81    }
82
83    /**
84     * Returns the Call-Id of InReplyToHeader. The CallId parameter uniquely
85     * identifies a series of messages within a dialogue.
86     *
87     * @return the String value of the Call-Id of this InReplyToHeader
88     */
89    public String getCallId() {
90        if (callId == null)
91            return null;
92        return callId.encode();
93    }
94
95    /**
96         * Generate canonical form of the header.
97         * @return String
98         */
99    public String encodeBody() {
100        return callId.encode();
101    }
102
103    public Object clone() {
104        InReplyTo retval = (InReplyTo) super.clone();
105        if (this.callId != null)
106            retval.callId = (CallIdentifier) this.callId.clone();
107        return retval;
108    }
109}
110
111