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.siplite.address.*;
030: import gov.nist.core.*;
031:
032: /**
033: * FromHeader SIP Header
034: * <a "href=${docRoot}/uncopyright.html">This code is in the public domain.</a>
035: */
036:
037: public final class FromHeader extends AddressParametersHeader {
038: /** Label for tag. */
039: public static final String TAG = "tag";
040: /** Label for from header field. */
041: public static final String NAME = Header.FROM;
042: /** Class handle. */
043: public static Class clazz;
044:
045: static {
046: clazz = new FromHeader().getClass();
047: }
048:
049: /**
050: * Default constructor.
051: */
052: public FromHeader() {
053: super (FROM);
054: }
055:
056: /**
057: * Generate a FROM header from a TO header.
058: * @param to target receipient
059: */
060: public FromHeader(ToHeader to) {
061: super (FROM);
062: this .address = (Address) to.address.clone();
063: this .parameters = (NameValueList) to.parameters.clone();
064: }
065:
066: /**
067: * Compares two from headers for equality.
068: * @param otherHeader Object to set
069: * @return true if the two headers are the same, false otherwise.
070: */
071: public boolean equals(Object otherHeader) {
072: if (otherHeader == null || address == null)
073: return false;
074: if (!otherHeader.getClass().equals(this .getClass())) {
075: return false;
076: }
077:
078: return super .equals(otherHeader);
079: }
080:
081: /**
082: * Gets the tag parameter from the address parm list.
083: * @return String
084: */
085: public String getTag() {
086: return super .getParameter(FromHeader.TAG);
087: }
088:
089: /**
090: * Returns true if the tag label is found.
091: * @return true if this header has a Tag, false otherwise.
092: */
093: public boolean hasTag() {
094: return super .hasParameter(TAG);
095:
096: }
097:
098: /**
099: * Removes the Tag field.
100: */
101: public void removeTag() {
102: super .removeParameter(TAG);
103:
104: }
105:
106: /**
107: * Sets the tag member.
108: * @param tag String to set.
109: */
110: public void setTag(String tag) {
111: super.setParameter(TAG, tag);
112:
113: }
114: }
|