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: * email field in the SDP announce.
034: *
035: *@version JSR141-PUBLIC-REVIEW (subject to change).
036: *
037: *
038: *<a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
039: */
040: public class EmailField extends SDPField {
041: /** Email address. */
042: protected EmailAddress emailAddress;
043:
044: /**
045: * Copies the current instance.
046: * @return the copy of this object
047: */
048: public Object clone() {
049: EmailField retval = new EmailField();
050: if (emailAddress != null)
051: retval.emailAddress = (EmailAddress) this .emailAddress
052: .clone();
053: return retval;
054: }
055:
056: /** DEfault constructor. */
057: public EmailField() {
058: super (SDPFieldNames.EMAIL_FIELD);
059: emailAddress = new EmailAddress();
060: }
061:
062: /**
063: * Gets the email address.
064: * @return the email address
065: */
066: public EmailAddress getEmailAddress() {
067: return emailAddress;
068: }
069:
070: /**
071: * Sets the email address member.
072: * @param emailAddress the new email address
073: */
074: public void setEmailAddress(EmailAddress emailAddress) {
075: this .emailAddress = emailAddress;
076: }
077:
078: /**
079: * Gets the string encoded version of this object.
080: * @return encoded string of object contents
081: * @since v1.0
082: */
083: public String encode() {
084: return EMAIL_FIELD + emailAddress.encode() + Separators.NEWLINE;
085: }
086:
087: /**
088: * Gets the string encoded version of this object.
089: * @return encoded string of object contents
090: */
091: public String toString() {
092: return this .encode();
093: }
094:
095: /**
096: * Gets the email address value.
097: * @throws SdpParseException if a parsing error occurs
098: * @return the value
099: */
100: public String getValue() throws SdpParseException {
101: if (emailAddress == null)
102: return null;
103: else {
104: return emailAddress.getDisplayName();
105: }
106: }
107:
108: /**
109: * Sets the email value.
110: * @param value to set
111: * @throws SdpException if the value is null
112: */
113: public void setValue(String value) throws SdpException {
114: if (value == null)
115: throw new SdpException("The value is null");
116: else {
117:
118: emailAddress.setDisplayName(value);
119: }
120: }
121:
122: }
|