1 /*
2 * $Id$
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22
23 package org.apache.struts.apps.mailreader.dao.impl;
24
25 import org.apache.struts.apps.mailreader.dao.Subscription;
26 import org.apache.struts.apps.mailreader.dao.User;
27
28
29 /**
30 * <p>Concrete implementation of {@link AbstractSubscription}.</p>
31 *
32 * @version $Rev$
33 * @since Struts 1.1
34 */
35
36 public class AbstractSubscription implements Subscription {
37
38
39 // ----------------------------------------------------------- Constructors
40
41
42 /**
43 * <p>Construct a new Subscription associated with the specified
44 * {@link User}.
45 *
46 * @param user The user with which we are associated
47 * @param host The mail host for this subscription
48 */
49 public AbstractSubscription(User user, String host) {
50
51 super();
52 this.user = user;
53 this.host = host;
54
55 }
56
57
58 // ----------------------------------------------------- Instance Variables
59
60
61 /**
62 * The mail host for this subscription.
63 */
64 private String host = null;
65
66
67 /**
68 * The {@link User} with which we are associated.
69 */
70 private User user = null;
71
72
73 // ------------------------------------------------------------- Properties
74
75
76 /**
77 * Should we auto-connect at startup time?
78 */
79 private boolean autoConnect = false;
80
81 public boolean getAutoConnect() {
82 return (this.autoConnect);
83 }
84
85 public void setAutoConnect(boolean autoConnect) {
86 this.autoConnect = autoConnect;
87 }
88
89
90 /**
91 * The mail host for this subscription.
92 */
93 public String getHost() {
94 return (this.host);
95 }
96
97
98 /**
99 * The password (in clear text) for this subscription.
100 */
101 private String password = null;
102
103 public String getPassword() {
104 return (this.password);
105 }
106
107 public void setPassword(String password) {
108 this.password = password;
109 }
110
111
112 /**
113 * The subscription type ("imap" or "pop3").
114 */
115 private String type = "imap";
116
117 public String getType() {
118 return (this.type);
119 }
120
121 public void setType(String type) {
122 this.type = type;
123 }
124
125
126 /**
127 * The User owning this Subscription.
128 */
129 public User getUser() {
130 return (this.user);
131 }
132
133
134 /**
135 * The username for this subscription.
136 */
137 private String username = null;
138
139 public String getUsername() {
140 return (this.username);
141 }
142
143 public void setUsername(String username) {
144 this.username = username;
145 }
146
147
148 // --------------------------------------------------------- Public Methods
149
150
151 /**
152 * Return a String representation of this object.
153 */
154 public String toString() {
155
156 StringBuilder sb = new StringBuilder("<subscription host=\"");
157 sb.append(host);
158 sb.append("\" autoConnect=\"");
159 sb.append(autoConnect);
160 sb.append("\"");
161 if (password != null) {
162 sb.append(" password=\"");
163 sb.append(password);
164 sb.append("\"");
165 }
166 if (type != null) {
167 sb.append(" type=\"");
168 sb.append(type);
169 sb.append("\"");
170 }
171 if (username != null) {
172 sb.append(" username=\"");
173 sb.append(username);
174 sb.append("\"");
175 }
176 sb.append(">");
177 return (sb.toString());
178
179 }
180
181
182 }