001: /*
002: * Portions Copyright 2000-2007 Sun Microsystems, Inc. All Rights
003: * Reserved. Use is subject to license terms.
004: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License version
008: * 2 only, as published by the Free Software Foundation.
009: *
010: * This program is distributed in the hope that it will be useful, but
011: * WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * General Public License version 2 for more details (a copy is
014: * included at /legal/license.txt).
015: *
016: * You should have received a copy of the GNU General Public License
017: * version 2 along with this work; if not, write to the Free Software
018: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
019: * 02110-1301 USA
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
022: * Clara, CA 95054 or visit www.sun.com if you need additional
023: * information or have any questions.
024: */
025: /*
026: */
027: package gov.nist.siplite.header;
028:
029: import gov.nist.core.*;
030:
031: /**
032: * Protocol name and version.
033: *
034: * @version 1.1
035: *
036: * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
037: *
038: */
039: public class Protocol extends GenericObject {
040:
041: /**
042: * protocolName field
043: */
044: protected String protocolName;
045:
046: /**
047: * protocolVersion field
048: */
049: protected String protocolVersion;
050:
051: /**
052: * transport field
053: */
054: protected String transport;
055:
056: /**
057: * Default constructor.
058: */
059: public Protocol() {
060: protocolName = "SIP";
061: protocolVersion = "2.0";
062: transport = "UDP";
063: }
064:
065: /**
066: * Compare two protocols for equality.
067: * @return true if the two protocols are the same.
068: * @param other Object to set
069: */
070: public boolean equals(Object other) {
071: if (!other.getClass().equals(this .getClass())) {
072: return false;
073: }
074: Protocol that = (Protocol) other;
075: if (Utils.compareToIgnoreCase(protocolName, that.protocolName) != 0) {
076: return false;
077: }
078: if (Utils.compareToIgnoreCase(protocolVersion, protocolVersion) != 0) {
079: return false;
080: }
081: if (Utils.compareToIgnoreCase(transport, that.transport) != 0) {
082: return false;
083: }
084: return true;
085: }
086:
087: /**
088: * Return canonical form.
089: * @return String
090: */
091: public String encode() {
092: return protocolName.toUpperCase() + Separators.SLASH
093: + protocolVersion + Separators.SLASH
094: + transport.toUpperCase();
095: }
096:
097: /**
098: * get the protocol name
099: * @return String
100: */
101: public String getProtocolName() {
102: return protocolName;
103: }
104:
105: /**
106: * get the protocol version
107: * @return String
108: */
109: public String getProtocolVersion() {
110: return protocolVersion;
111: }
112:
113: /**
114: * get the transport
115: * @return String
116: */
117: public String getTransport() {
118: return transport;
119: }
120:
121: /**
122: * Set the protocolName member
123: * @param p String to set
124: */
125: public void setProtocolName(String p) {
126: protocolName = p;
127: }
128:
129: /**
130: * Set the protocolVersion member
131: * @param p String to set
132: */
133: public void setProtocolVersion(String p) {
134: protocolVersion = p;
135: }
136:
137: /**
138: * Set the transport member
139: * @param t String to set
140: */
141: public void setTransport(String t) {
142: transport = t;
143: }
144:
145: /**
146: * Clone this structure.
147: * @return Object Protocol
148: */
149: public Object clone() {
150: Protocol retval = new Protocol();
151:
152: if (this .protocolName != null)
153: retval.protocolName = new String(this .protocolName);
154: if (this .protocolVersion != null)
155: retval.protocolVersion = new String(this .protocolVersion);
156: if (this .transport != null)
157: retval.transport = new String(this .transport);
158: return (Object) retval;
159:
160: }
161:
162: }
|