001: /****************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one *
003: * or more contributor license agreements. See the NOTICE file *
004: * distributed with this work for additional information *
005: * regarding copyright ownership. The ASF licenses this file *
006: * to you under the Apache License, Version 2.0 (the *
007: * "License"); you may not use this file except in compliance *
008: * with the License. You may obtain a copy of the License at *
009: * *
010: * http://www.apache.org/licenses/LICENSE-2.0 *
011: * *
012: * Unless required by applicable law or agreed to in writing, *
013: * software distributed under the License is distributed on an *
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015: * KIND, either express or implied. See the License for the *
016: * specific language governing permissions and limitations *
017: * under the License. *
018: ****************************************************************/package org.apache.james.util.mail.mdn;
019:
020: /**
021: * Class <code>Disposition</code> encapsulating
022: * disposition information as defined by RFC 2298.
023: */
024: public class Disposition {
025: private DispositionActionMode fieldActionMode;
026: private DispositionSendingMode fieldSendingMode;
027: private DispositionType fieldDispositionType;
028: private DispositionModifier[] fieldDispositionModifiers;
029:
030: /**
031: * Default Construcor
032: */
033: private Disposition() {
034: super ();
035: }
036:
037: /**
038: * Constructor.
039: *
040: * @param actionMode
041: * @param sendingMode
042: * @param type
043: */
044: public Disposition(DispositionActionMode actionMode,
045: DispositionSendingMode sendingMode, DispositionType type) {
046: this ();
047: setActionMode(actionMode);
048: setSendingMode(sendingMode);
049: setDispositionType(type);
050: }
051:
052: /**
053: * Constructor.
054: *
055: * @param actionMode
056: * @param sendingMode
057: * @param type
058: * @param modifiers
059: */
060: public Disposition(DispositionActionMode actionMode,
061: DispositionSendingMode sendingMode, DispositionType type,
062: DispositionModifier[] modifiers) {
063: this (actionMode, sendingMode, type);
064: setDispositionModifiers(modifiers);
065: }
066:
067: /**
068: * Answer the Disposition Mode.
069: *
070: * @return Returns the dispostionMode.
071: */
072: protected DispositionActionMode getActionMode() {
073: return fieldActionMode;
074: }
075:
076: /**
077: * Set the Disposition Mode.
078: *
079: * @param dispostionMode The dispostionMode to set.
080: */
081: protected void setActionMode(DispositionActionMode dispostionMode) {
082: fieldActionMode = dispostionMode;
083: }
084:
085: /**
086: * Answer the Disposition Modifiers.
087: *
088: * @return Returns the dispostionModifiers.
089: */
090: protected DispositionModifier[] getDispositionModifiers() {
091: return fieldDispositionModifiers;
092: }
093:
094: /**
095: * Set the Disposition Modifiers.
096: *
097: * @param dispostionModifiers The dispostionModifiers to set.
098: */
099: protected void setDispositionModifiers(
100: DispositionModifier[] dispostionModifiers) {
101: fieldDispositionModifiers = dispostionModifiers;
102: }
103:
104: /**
105: * Answer the Disposition Type.
106: *
107: * @return Returns the dispostionType.
108: */
109: protected DispositionType getDispositionType() {
110: return fieldDispositionType;
111: }
112:
113: /**
114: * Set the Disposition Type.
115: *
116: * @param dispostionType The dispostionType to set.
117: */
118: protected void setDispositionType(DispositionType dispostionType) {
119: fieldDispositionType = dispostionType;
120: }
121:
122: /**
123: * @see java.lang.Object#toString()
124: */
125: public String toString() {
126: StringBuffer buffer = new StringBuffer(64);
127: buffer.append("Disposition: ");
128: buffer.append(getActionMode() == null ? "" : getActionMode()
129: .toString());
130: buffer.append('/');
131: buffer.append(getSendingMode() == null ? "" : getSendingMode()
132: .toString());
133: buffer.append(';');
134: buffer.append(getDispositionType() == null ? ""
135: : getDispositionType().toString());
136: if (null != getDispositionModifiers()
137: && getDispositionModifiers().length > 0) {
138: buffer.append('/');
139: for (int i = 0; i < getDispositionModifiers().length; i++) {
140: if (i > 0)
141: buffer.append(',');
142: buffer.append(getDispositionModifiers()[i]);
143: }
144: }
145: return buffer.toString();
146: }
147:
148: /**
149: * Answer the Sending Mode.
150: *
151: * @return Returns the sendingMode.
152: */
153: protected DispositionSendingMode getSendingMode() {
154: return fieldSendingMode;
155: }
156:
157: /**
158: * Set the Sending Mode.
159: *
160: * @param sendingMode The sendingMode to set.
161: */
162: protected void setSendingMode(DispositionSendingMode sendingMode) {
163: fieldSendingMode = sendingMode;
164: }
165: }
|