001: /*
002: * This file is part of PFIXCORE.
003: *
004: * PFIXCORE is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU Lesser General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * PFIXCORE is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public License
015: * along with PFIXCORE; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: */
019:
020: package de.schlund.pfixxml.multipart;
021:
022: import java.util.Enumeration;
023:
024: import javax.mail.MessagingException;
025: import javax.mail.internet.ParameterList;
026:
027: /**
028: *
029: *
030: */
031:
032: public class HeaderStruct {
033:
034: private static final ParameterList DEF_LIST = new ParameterList();
035:
036: private String name = null;
037: private String value = null;
038: private ParameterList params = null;
039:
040: public HeaderStruct() {
041: params = DEF_LIST;
042: }
043:
044: /**
045: * Gets the name.
046: * @return Returns a String
047: */
048: public String getName() {
049: return name;
050: }
051:
052: /**
053: * Sets the name.
054: * @param name The name to set
055: */
056: public void setName(String name) {
057: this .name = name;
058: }
059:
060: /**
061: * Gets the value.
062: * @return Returns a String
063: */
064: public String getValue() {
065: return value;
066: }
067:
068: /**
069: * Sets the value.
070: * @param value The value to set
071: */
072: public void setValue(String value) {
073: this .value = value;
074: }
075:
076: public void resetParams() {
077: params = DEF_LIST;
078: }
079:
080: public void initParams(String val) {
081: try {
082: if (val != null) {
083: params = new ParameterList(val);
084: } else {
085: params = DEF_LIST;
086: }
087: } catch (MessagingException e) {
088: e.printStackTrace();
089: System.err.println(e.getMessage());
090: params = DEF_LIST;
091: }
092: }
093:
094: public String getParam(String nameP) {
095: return params.get(nameP);
096: }
097:
098: public String toString() {
099: StringBuffer buf = new StringBuffer();
100: buf.append("name: ").append(name).append('\n');
101: buf.append("value: ").append(value).append('\n');
102: @SuppressWarnings("unchecked")
103: Enumeration enm = params.getNames();
104: while (enm.hasMoreElements()) {
105: String pName = (String) enm.nextElement();
106: buf.append("pname: '" + pName + "' pvalue: '"
107: + params.get(pName) + "'\n");
108: }
109: return buf.toString();
110: }
111:
112: }
|