KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > util > mail > mdn > Disposition


1 /***********************************************************************
2  * Copyright (c) 2003-2004 The Apache Software Foundation. *
3  * All rights reserved. *
4  * ------------------------------------------------------------------- *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you *
6  * may not use this file except in compliance with the License. You *
7  * may obtain a copy of the License at: *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
14  * implied. See the License for the specific language governing *
15  * permissions and limitations under the License. *
16  ***********************************************************************/

17 package org.apache.james.util.mail.mdn;
18
19 /**
20  * Class <code>Disposition</code> encapsulating
21  * disposition information as defined by RFC 2298.
22  */

23 public class Disposition
24 {
25     private DispositionActionMode fieldActionMode;
26     private DispositionSendingMode fieldSendingMode;
27     private DispositionType fieldDispositionType;
28     private DispositionModifier[] fieldDispositionModifiers;
29
30     /**
31      * Default Construcor
32      */

33     private Disposition()
34     {
35         super();
36     }
37
38     /**
39      * Constructor.
40      *
41      * @param actionMode
42      * @param sendingMode
43      * @param type
44      */

45     public Disposition(DispositionActionMode actionMode, DispositionSendingMode sendingMode, DispositionType type)
46     {
47         this();
48         setActionMode(actionMode);
49         setSendingMode(sendingMode);
50         setDispositionType(type);
51     }
52
53     /**
54      * Constructor.
55      *
56      * @param actionMode
57      * @param sendingMode
58      * @param type
59      * @param modifiers
60      */

61     public Disposition(DispositionActionMode actionMode, DispositionSendingMode sendingMode, DispositionType type,
62             DispositionModifier[] modifiers)
63     {
64         this(actionMode, sendingMode, type);
65         setDispositionModifiers(modifiers);
66     }
67
68     /**
69      * Answer the Disposition Mode.
70      *
71      * @return Returns the dispostionMode.
72      */

73     protected DispositionActionMode getActionMode()
74     {
75         return fieldActionMode;
76     }
77
78     /**
79      * Set the Disposition Mode.
80      *
81      * @param dispostionMode The dispostionMode to set.
82      */

83     protected void setActionMode(DispositionActionMode dispostionMode)
84     {
85         fieldActionMode = dispostionMode;
86     }
87
88     /**
89      * Answer the Disposition Modifiers.
90      *
91      * @return Returns the dispostionModifiers.
92      */

93     protected DispositionModifier[] getDispositionModifiers()
94     {
95         return fieldDispositionModifiers;
96     }
97
98     /**
99      * Set the Disposition Modifiers.
100      *
101      * @param dispostionModifiers The dispostionModifiers to set.
102      */

103     protected void setDispositionModifiers(DispositionModifier[] dispostionModifiers)
104     {
105         fieldDispositionModifiers = dispostionModifiers;
106     }
107
108     /**
109      * Answer the Disposition Type.
110      *
111      * @return Returns the dispostionType.
112      */

113     protected DispositionType getDispositionType()
114     {
115         return fieldDispositionType;
116     }
117
118     /**
119      * Set the Disposition Type.
120      *
121      * @param dispostionType The dispostionType to set.
122      */

123     protected void setDispositionType(DispositionType dispostionType)
124     {
125         fieldDispositionType = dispostionType;
126     }
127
128     /**
129      * @see java.lang.Object#toString()
130      */

131     public String JavaDoc toString()
132     {
133         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(64);
134         buffer.append("Disposition: ");
135         buffer.append(getActionMode() == null ? "" : getActionMode().toString());
136         buffer.append('/');
137         buffer.append(getSendingMode() == null ? "" : getSendingMode().toString());
138         buffer.append(';');
139         buffer.append(getDispositionType() == null ? "" : getDispositionType().toString());
140         if (null != getDispositionModifiers()
141                 && getDispositionModifiers().length > 0)
142         {
143             buffer.append('/');
144             for (int i = 0; i < getDispositionModifiers().length; i++)
145             {
146                 if (i > 0)
147                     buffer.append(',');
148                 buffer.append(getDispositionModifiers()[i]);
149             }
150         }
151         return buffer.toString();
152     }
153
154     /**
155      * Answer the Sending Mode.
156      *
157      * @return Returns the sendingMode.
158      */

159     protected DispositionSendingMode getSendingMode()
160     {
161         return fieldSendingMode;
162     }
163
164     /**
165      * Set the Sending Mode.
166      *
167      * @param sendingMode The sendingMode to set.
168      */

169     protected void setSendingMode(DispositionSendingMode sendingMode)
170     {
171         fieldSendingMode = sendingMode;
172     }
173 }
174
Popular Tags