001: /***
002: * jwma Java WebMail
003: * Copyright (c) 2000-2003 jwma team
004: *
005: * jwma is free software; you can distribute and use this source
006: * under the terms of the BSD-style license received along with
007: * the distribution.
008: ***/package dtw.webmail.util.config;
009:
010: import org.apache.log4j.Logger;
011:
012: import java.util.Properties;
013: import java.net.InetAddress;
014: import java.io.Serializable;
015:
016: /**
017: * This class...
018: * <p>
019: * @author Dieter Wimberger (wimpi)
020: * @version (created Feb 13, 2003)
021: */
022: public class PostOffice implements Serializable {
023:
024: //class attributes
025: private static Logger log = Logger.getLogger(PostOffice.class);
026:
027: //instance attributes
028: private String m_Name = "Default";
029: private String m_Address = "localhost";
030: private int m_Port = -1; //protocol default
031: private String m_RootFolder = "";
032: private boolean m_Secure = false;
033: private String m_Type = "mixed";
034: private String m_Protocol = "imap";
035: private boolean m_Default = false;
036: private String m_ReplyToDomain;
037:
038: /**
039: * Constructs a new <tt>PostOffice</tt> instance.
040: */
041: public PostOffice() {
042: }//constructor
043:
044: /**
045: * Returns a common name for this <tt>PostOffice</tt>.
046: * Naming for different post offices should be kept unique.
047: *
048: * @return the name as <tt>String</tt>.
049: */
050: public String getName() {
051: return m_Name;
052: }//getName
053:
054: /**
055: * Sets the common name for this <tt>PostOffice</tt>.
056: *
057: * @param name the name as <tt>String</tt>.
058: */
059: public void setName(String name) {
060: m_Name = name;
061: }//setName
062:
063: /**
064: * Returns the protocol required for
065: * this <tt>PostOffice</tt>.
066: *
067: * @return the protocol as <tt>String</tt>.
068: */
069: public String getProtocol() {
070: return m_Protocol;
071: }//getProtocol
072:
073: /**
074: * Sets the protocol required for
075: * this <tt>PostOffice</tt>.
076: *
077: * @param protocol the protocol as <tt>String</tt>.
078: */
079: public void setProtocol(String protocol) {
080: m_Protocol = protocol;
081: }//setProtocol
082:
083: /**
084: * Returns the type of this <tt>PostOffice</tt>.
085: *
086: * @return the type as <tt>String</tt>.
087: * @see #TYPE_MIXED
088: * @see #TYPE_PLAIN
089: */
090: public String getType() {
091: return m_Type;
092: }//getType
093:
094: /**
095: * Sets the type of this <tt>PostOffice</tt>.
096: *
097: * @param type the type as <tt>String</tt>.
098: * @see #TYPE_MIXED
099: * @see #TYPE_PLAIN
100: */
101: public void setType(String type) {
102: m_Type = type;
103: }//setType
104:
105: /**
106: * Tests if this <tt>PostOffice</tt> is of a
107: * given type.
108: *
109: * @return true if of the given type, false otherwise.
110: * @see #TYPE_MIXED
111: * @see #TYPE_PLAIN
112: */
113: public boolean isType(String type) {
114: return m_Type.equals(type);
115: }//isType
116:
117: /**
118: * Returns the internet address of this <tt>PostOffice</tt>.
119: *
120: * @return the address as <tt>String</tt>.
121: */
122: public String getAddress() {
123: return m_Address;
124: }//getAddress
125:
126: /**
127: * Sets the internet address of this <tt>PostOffice</tt>.
128: *
129: * @param address the address as <tt>String</tt>.
130: */
131: public void setAddress(String address) {
132: try {
133: if (address == null || address.equals("")
134: || address.equals("localhost")) {
135: m_Address = InetAddress.getLocalHost().getHostName();
136: }
137: } catch (Exception ex) {
138: log.error("setAddress()", ex);
139: }
140: m_Address = address;
141: }//setAddress
142:
143: /**
144: * Returns the port of this <tt>PostOffice</tt>.
145: *
146: * @param the port as <tt>int</tt>.
147: */
148: public int getPort() {
149: return m_Port;
150: }//getPort
151:
152: /**
153: * Sets the port of this this <tt>PostOffice</tt>.
154: *
155: * @param port the port as <tt>int</tt>
156: */
157: public void setPort(int port) {
158: m_Port = port;
159: }//setPort
160:
161: /**
162: * Tests if the communication with this <tt>PostOffice</tt>
163: * should be secure.
164: *
165: * @return true if secure, false otherwise.
166: * @see #getSecureSocketFactory()
167: */
168: public boolean isSecure() {
169: return m_Secure;
170: }//isSecure
171:
172: /**
173: * Sets the communication with this <tt>PostOffice</tt>
174: * to be secure.
175: *
176: * @param secure true if secure, false otherwise.
177: * @see #setSecureSocketFactory(String factory)
178: */
179: public void setSecure(boolean secure) {
180: m_Secure = secure;
181: }//setSecure
182:
183: /**
184: * Returns the default root folder
185: * this <tt>PostOffice</tt>.
186: *
187: * @return the folder as <tt>String</tt>.
188: */
189: public String getRootFolder() {
190: return m_RootFolder;
191: }//getRootFolder
192:
193: /**
194: * Sets the default root folder for
195: * this <tt>PostOffice</tt>.
196: *
197: * @param folder the folder as <tt>String</tt>.
198: */
199: public void setRootFolder(String folder) {
200: m_RootFolder = folder;
201: }//setRootFolder
202:
203: /**
204: * Returns the reply-to domain setting for
205: * this <tt>PostOffice</tt>.
206: *
207: * @return the reply-to domain as <tt>String</tt>.
208: */
209: public String getReplyToDomain() {
210: return m_ReplyToDomain;
211: }//getReplyToDomain
212:
213: /**
214: * Sets the reply-to domain for
215: * this <tt>PostOffice</tt>.
216: *
217: * @param domain the reply-to domain as <tt>String</tt>.
218: */
219: public void setReplyToDomain(String domain) {
220: m_ReplyToDomain = domain;
221: }//setReplyToDomain
222:
223: /**
224: * Tests if this <tt>PostOffice</tt> is
225: * the default.
226: *
227: * @return true if default, false otherwise.
228: */
229: public boolean isDefault() {
230: return m_Default;
231: }//isDefault
232:
233: /**
234: * Sets the default flag for this <tt>PostOffice</tt>.
235: */
236: public void setDefault(boolean aDefault) {
237: m_Default = aDefault;
238: }//setDefault
239:
240: /**
241: * Defines a mixed type post office, were
242: * folders in the store can have subfolders and messages
243: * at the same time.
244: */
245: public static final String TYPE_MIXED = "mixed";
246:
247: /**
248: * Defines a plain type post office, were
249: * folders in the store cannot have subfolders and messages
250: * at the same time.
251: */
252: public static final String TYPE_PLAIN = "plain";
253:
254: }//class PostOffice
|