001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package gov.nist.siplite.header;
028:
029: import gov.nist.core.*;
030:
031: /** Use this class for the headers that can not have any parameters. */
032: public class ParameterLessHeader extends Header {
033:
034: /** Class handle. */
035: public static Class clazz;
036:
037: static {
038: clazz = new ParameterLessHeader().getClass();
039: }
040:
041: /**
042: * Default constructor for a generic parameter-less header.
043: */
044: public ParameterLessHeader() {
045: }
046:
047: /**
048: * Constructor given the name.
049: * @param headerName is the header name.
050: */
051: public ParameterLessHeader(String headerName) {
052: super (headerName);
053: }
054:
055: /**
056: * Constructor given the name and value.
057: * @param headerName is the header name.
058: * @param headerVal is the header value.
059: */
060: public ParameterLessHeader(String headerName, String headerVal) {
061: super (headerName);
062: headerValue = StringTokenizer.convertNewLines(headerVal.trim());
063: }
064:
065: /**
066: * Sets the value without parameters for a generic header.
067: * @param value the new value to be set
068: */
069: public void setValue(String value) {
070: headerValue = StringTokenizer.convertNewLines(value.trim());
071: }
072:
073: /**
074: * Sets the name for a generic header.
075: * @param name the new name to be set
076: */
077: public void setName(String name) {
078: headerName = name.trim();
079: }
080:
081: /**
082: * Gets the parameter list (which is always empty) for this header.
083: * @return always null
084: */
085: public NameValueList getParameters() {
086: return null;
087: }
088:
089: /**
090: * Encodes the body as a textstring.
091: * @return encoded string of body contents
092: */
093: public String encodeBody() {
094: return headerValue;
095: }
096:
097: /**
098: * Gets the value of the header without parameters.
099: * @return value of extension header field
100: */
101: public Object getValue() {
102: return headerValue;
103: }
104: }
|