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: * Media Range.
033: * @since 0.9
034: * @version 1.0
035: * <pre>
036: * Revisions:
037: *
038: * Version 1.0
039: * 1. Added encode method.
040: *
041: * media-range = ( "STAR/STAR"
042: * | ( type "/" STAR )
043: * | ( type "/" subtype )
044: * ) *( ";" parameter )
045: *
046: * HTTP RFC 2616 Section 14.1
047: * </pre>
048: */
049: public class MediaRange extends GenericObject {
050:
051: /**
052: * Media range type field.
053: */
054: protected String type;
055:
056: /**
057: * Media range subtype field.
058: */
059: protected String subtype;
060:
061: /**
062: * Copies the current instance.
063: * @return copy of the current object.
064: */
065: public Object clone() {
066: MediaRange retval = new MediaRange();
067: if (type != null)
068: retval.type = new String(this .type);
069: if (subtype != null)
070: retval.subtype = new String(this .subtype);
071: return retval;
072: }
073:
074: /**
075: * Default constructor.
076: */
077: public MediaRange() {
078: }
079:
080: /**
081: * Gets the media range type field.
082: * @return the type field value
083: */
084: public String getType() {
085: return type;
086: }
087:
088: /**
089: * Gets the media range subtype field.
090: * @return the sub type field value
091: */
092: public String getSubtype() {
093: return subtype;
094: }
095:
096: /**
097: * Sets the media range type member....
098: * @param t String to set
099: */
100: public void setType(String t) {
101: type = t;
102: }
103:
104: /**
105: * Sets the media range subtype member.
106: * @param s String to set
107: */
108: public void setSubtype(String s) {
109: subtype = s;
110: }
111:
112: /**
113: * Encodes the object.
114: * @return String canonical encoded version of this object.
115: */
116: public String encode() {
117: String encoding = type + Separators.SLASH + subtype;
118: return encoding;
119: }
120:
121: /**
122: * Encodes the object. Calls encode().
123: * @return String canonical encoded version of this object.
124: */
125: public String toString() {
126: return encode();
127: }
128: }
|