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.javax.sdp.fields;
028:
029: import gov.nist.core.*;
030: import gov.nist.javax.sdp.*;
031:
032: /**
033: * Proto version field of SDP announce.
034: *
035: * @version JSR141-PUBLIC-REVIEW (subject to change).
036: *
037: *
038: *
039: * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
040: *
041: */
042: public class ProtoVersionField extends SDPField {
043: /** Protocol version. */
044: protected int protoVersion;
045:
046: /**
047: * Copies the current instance.
048: * @return the copy of this object
049: */
050: public Object clone() {
051: ProtoVersionField retval = new ProtoVersionField();
052: retval.protoVersion = this .protoVersion;
053: return retval;
054: }
055:
056: /** Default constructor. */
057: public ProtoVersionField() {
058: super (PROTO_VERSION_FIELD);
059: }
060:
061: /**
062: * Gets the protocol version number.
063: * @return the protocol version number
064: */
065: public int getProtoVersion() {
066: return protoVersion;
067: }
068:
069: /**
070: * Sets the protocol version member.
071: * @param pv the new protocol version number
072: */
073: public void setProtoVersion(int pv) {
074: protoVersion = pv;
075: }
076:
077: /**
078: * Returns the version number.
079: * @throws SdpParseException if a parsing error occurs
080: * @return the version number
081: */
082: public int getVersion() throws SdpParseException {
083: return getProtoVersion();
084: }
085:
086: /**
087: * Sets the version number.
088: * @param value the new version value.
089: * @throws SdpException if the value is less than 0
090: */
091: public void setVersion(int value) throws SdpException {
092: if (value < 0)
093: throw new SdpException("The value is < 0");
094: else
095: setProtoVersion(value);
096: }
097:
098: /**
099: * Gets the string encoded version of this object.
100: * @return encoded string of object contents
101: * @since v1.0
102: */
103: public String encode() {
104: return PROTO_VERSION_FIELD + protoVersion + Separators.NEWLINE;
105: }
106:
107: }
|