1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts.webapp.example2.memory;
19
20
21 import org.apache.struts.webapp.example2.Subscription;
22 import org.apache.struts.webapp.example2.User;
23
24
25 /***
26 * <p>Concrete implementation of {@link Subscription} for an in-memory
27 * database backed by an XML data file.</p>
28 *
29 * @author Craig R. McClanahan
30 * @version $Rev: 421494 $ $Date: 2006-07-12 20:55:17 -0700 (Wed, 12 Jul 2006) $
31 * @since Struts 1.1
32 */
33
34 public final class MemorySubscription implements Subscription {
35
36
37
38
39
40 /***
41 * <p>Construct a new Subscription associated with the specified
42 * {@link User}.
43 *
44 * @param user The user with which we are associated
45 * @param host The mail host for this subscription
46 */
47 public MemorySubscription(MemoryUser user, String host) {
48
49 super();
50 this.user = user;
51 this.host = host;
52
53 }
54
55
56
57
58
59 /***
60 * The mail host for this subscription.
61 */
62 private String host = null;
63
64
65 /***
66 * The {@link User} with which we are associated.
67 */
68 private MemoryUser user = null;
69
70
71
72
73
74 /***
75 * Should we auto-connect at startup time?
76 */
77 private boolean autoConnect = false;
78
79 public boolean getAutoConnect() {
80 return (this.autoConnect);
81 }
82
83 public void setAutoConnect(boolean autoConnect) {
84 this.autoConnect = autoConnect;
85 }
86
87
88 /***
89 * The mail host for this subscription.
90 */
91 public String getHost() {
92 return (this.host);
93 }
94
95
96 /***
97 * The password (in clear text) for this subscription.
98 */
99 private String password = null;
100
101 public String getPassword() {
102 return (this.password);
103 }
104
105 public void setPassword(String password) {
106 this.password = password;
107 }
108
109
110 /***
111 * The subscription type ("imap" or "pop3").
112 */
113 private String type = "imap";
114
115 public String getType() {
116 return (this.type);
117 }
118
119 public void setType(String type) {
120 this.type = type;
121 }
122
123
124 /***
125 * The User owning this Subscription.
126 */
127 public User getUser() {
128 return (this.user);
129 }
130
131
132 /***
133 * The username for this subscription.
134 */
135 private String username = null;
136
137 public String getUsername() {
138 return (this.username);
139 }
140
141 public void setUsername(String username) {
142 this.username = username;
143 }
144
145
146
147
148
149 /***
150 * Return a String representation of this object.
151 */
152 public String toString() {
153
154 StringBuffer sb = new StringBuffer("<subscription host=\"");
155 sb.append(host);
156 sb.append("\" autoConnect=\"");
157 sb.append(autoConnect);
158 sb.append("\"");
159 if (password != null) {
160 sb.append(" password=\"");
161 sb.append(password);
162 sb.append("\"");
163 }
164 if (type != null) {
165 sb.append(" type=\"");
166 sb.append(type);
167 sb.append("\"");
168 }
169 if (username != null) {
170 sb.append(" username=\"");
171 sb.append(username);
172 sb.append("\"");
173 }
174 sb.append(">");
175 return (sb.toString());
176
177 }
178
179
180 }