KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > examples > mailreader > 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 package org.apache.struts.examples.mailreader.memory;
20
21 import org.apache.struts.examples.mailreader.Subscription;
22 import org.apache.struts.examples.mailreader.User;
23
24 /**
25  * <p>Concrete implementation of {@link Subscription} for an in-memory
26  * database backed by an XML data file.</p>
27  *
28  * @version $Rev: 54929 $ $Date: 2004-10-16 09:38:42 -0700 (Sat, 16 Oct 2004) $
29  * @since Struts 1.1
30  */

31
32 public final class MemorySubscription implements Subscription {
33
34
35     // ----------------------------------------------------------- Constructors
36

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

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

56
57     /**
58      * The mail host for this subscription.
59      */

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

66     private MemoryUser user = null;
67
68
69     // ------------------------------------------------------------- Properties
70

71
72     /**
73      * Should we auto-connect at startup time?
74      */

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

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

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

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

125     public User getUser() {
126         return (this.user);
127     }
128
129
130     /**
131      * The username for this subscription.
132      */

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

146
147     /**
148      * Return a String representation of this object.
149      */

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