KickJava   Java API By Example, From Geeks To Geeks.

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


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

18
19
20 package org.apache.struts.webapp.example.memory;
21
22
23 import org.apache.struts.webapp.example.Subscription;
24 import org.apache.struts.webapp.example.User;
25
26
27 /**
28  * <p>Concrete implementation of {@link Subscription} for an in-memory
29  * database backed by an XML data file.</p>
30  *
31  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
32  * @since Struts 1.1
33  */

34
35 public final class MemorySubscription implements Subscription {
36
37
38     // ----------------------------------------------------------- Constructors
39

40
41     /**
42      * <p>Construct a new Subscription associated with the specified
43      * {@link User}.
44      *
45      * @param user The user with which we are associated
46      * @param host The mail host for this subscription
47      */

48     public MemorySubscription(MemoryUser user, String JavaDoc host) {
49
50         super();
51         this.user = user;
52         this.host = host;
53
54     }
55
56
57     // ----------------------------------------------------- Instance Variables
58

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

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

69     private MemoryUser user = null;
70
71
72     // ------------------------------------------------------------- Properties
73

74
75     /**
76      * Should we auto-connect at startup time?
77      */

78     private boolean autoConnect = false;
79
80     public boolean getAutoConnect() {
81         return (this.autoConnect);
82     }
83
84     public void setAutoConnect(boolean autoConnect) {
85         this.autoConnect = autoConnect;
86     }
87
88
89     /**
90      * The mail host for this subscription.
91      */

92     public String JavaDoc getHost() {
93         return (this.host);
94     }
95
96
97     /**
98      * The password (in clear text) for this subscription.
99      */

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

114     private String JavaDoc type = "imap";
115
116     public String JavaDoc getType() {
117         return (this.type);
118     }
119
120     public void setType(String JavaDoc type) {
121         this.type = type;
122     }
123
124
125     /**
126      * The User owning this Subscription.
127      */

128     public User getUser() {
129         return (this.user);
130     }
131
132
133     /**
134      * The username for this subscription.
135      */

136     private String JavaDoc username = null;
137
138     public String JavaDoc getUsername() {
139         return (this.username);
140     }
141
142     public void setUsername(String JavaDoc username) {
143         this.username = username;
144     }
145
146
147     // --------------------------------------------------------- Public Methods
148

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

153     public String JavaDoc toString() {
154
155         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("<subscription host=\"");
156         sb.append(host);
157         sb.append("\" autoConnect=\"");
158         sb.append(autoConnect);
159         sb.append("\"");
160         if (password != null) {
161             sb.append(" password=\"");
162             sb.append(password);
163             sb.append("\"");
164         }
165         if (type != null) {
166             sb.append(" type=\"");
167             sb.append(type);
168             sb.append("\"");
169         }
170         if (username != null) {
171             sb.append(" username=\"");
172             sb.append(username);
173             sb.append("\"");
174         }
175         sb.append(">");
176         return (sb.toString());
177
178     }
179
180
181 }
182
Popular Tags