KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > webapp > example2 > memory > MemorySubscription


1 /*
2  * Copyright 1999-2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
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: 54934 $ $Date: 2004-10-16 18:07:50 +0100 (Sat, 16 Oct 2004) $
31  * @since Struts 1.1
32  */

33
34 public final class MemorySubscription implements Subscription {
35
36
37     // ----------------------------------------------------------- Constructors
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 JavaDoc host) {
48
49         super();
50         this.user = user;
51         this.host = host;
52
53     }
54
55
56     // ----------------------------------------------------- Instance Variables
57

58
59     /**
60      * The mail host for this subscription.
61      */

62     private String JavaDoc host = null;
63
64
65     /**
66      * The {@link User} with which we are associated.
67      */

68     private MemoryUser user = null;
69
70
71     // ------------------------------------------------------------- Properties
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 JavaDoc getHost() {
92         return (this.host);
93     }
94
95
96     /**
97      * The password (in clear text) for this subscription.
98      */

99     private String JavaDoc password = null;
100
101     public String JavaDoc getPassword() {
102         return (this.password);
103     }
104
105     public void setPassword(String JavaDoc password) {
106         this.password = password;
107     }
108
109
110     /**
111      * The subscription type ("imap" or "pop3").
112      */

113     private String JavaDoc type = "imap";
114
115     public String JavaDoc getType() {
116         return (this.type);
117     }
118
119     public void setType(String JavaDoc 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 JavaDoc username = null;
136
137     public String JavaDoc getUsername() {
138         return (this.username);
139     }
140
141     public void setUsername(String JavaDoc username) {
142         this.username = username;
143     }
144
145
146     // --------------------------------------------------------- Public Methods
147

148
149     /**
150      * Return a String representation of this object.
151      */

152     public String JavaDoc toString() {
153
154         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("<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 }
181
Popular Tags