001: /*
002: * $Id: MemorySubscription.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: package org.apache.struts.webapp.example.memory;
023:
024: import org.apache.struts.webapp.example.Subscription;
025: import org.apache.struts.webapp.example.User;
026:
027: /**
028: * <p>Concrete implementation of {@link Subscription} for an in-memory
029: * database backed by an XML data file.</p>
030: *
031: * @author Craig R. McClanahan
032: * @version $Rev: 471754 $ $Date: 2006-11-06 08:55:09 -0600 (Mon, 06 Nov 2006) $
033: * @since Struts 1.1
034: */
035:
036: public final class MemorySubscription implements Subscription {
037:
038: // ----------------------------------------------------------- Constructors
039:
040: /**
041: * <p>Construct a new Subscription associated with the specified
042: * {@link User}.
043: *
044: * @param user The user with which we are associated
045: * @param host The mail host for this subscription
046: */
047: public MemorySubscription(MemoryUser user, String host) {
048:
049: super ();
050: this .user = user;
051: this .host = host;
052:
053: }
054:
055: // ----------------------------------------------------- Instance Variables
056:
057: /**
058: * The mail host for this subscription.
059: */
060: private String host = null;
061:
062: /**
063: * The {@link User} with which we are associated.
064: */
065: private MemoryUser user = null;
066:
067: // ------------------------------------------------------------- Properties
068:
069: /**
070: * Should we auto-connect at startup time?
071: */
072: private boolean autoConnect = false;
073:
074: public boolean getAutoConnect() {
075: return (this .autoConnect);
076: }
077:
078: public void setAutoConnect(boolean autoConnect) {
079: this .autoConnect = autoConnect;
080: }
081:
082: /**
083: * The mail host for this subscription.
084: */
085: public String getHost() {
086: return (this .host);
087: }
088:
089: /**
090: * The password (in clear text) for this subscription.
091: */
092: private String password = null;
093:
094: public String getPassword() {
095: return (this .password);
096: }
097:
098: public void setPassword(String password) {
099: this .password = password;
100: }
101:
102: /**
103: * The subscription type ("imap" or "pop3").
104: */
105: private String type = "imap";
106:
107: public String getType() {
108: return (this .type);
109: }
110:
111: public void setType(String type) {
112: this .type = type;
113: }
114:
115: /**
116: * The User owning this Subscription.
117: */
118: public User getUser() {
119: return (this .user);
120: }
121:
122: /**
123: * The username for this subscription.
124: */
125: private String username = null;
126:
127: public String getUsername() {
128: return (this .username);
129: }
130:
131: public void setUsername(String username) {
132: this .username = username;
133: }
134:
135: // --------------------------------------------------------- Public Methods
136:
137: /**
138: * Return a String representation of this object.
139: */
140: public String toString() {
141:
142: StringBuffer sb = new StringBuffer("<subscription host=\"");
143: sb.append(host);
144: sb.append("\" autoConnect=\"");
145: sb.append(autoConnect);
146: sb.append("\"");
147: if (password != null) {
148: sb.append(" password=\"");
149: sb.append(password);
150: sb.append("\"");
151: }
152: if (type != null) {
153: sb.append(" type=\"");
154: sb.append(type);
155: sb.append("\"");
156: }
157: if (username != null) {
158: sb.append(" username=\"");
159: sb.append(username);
160: sb.append("\"");
161: }
162: sb.append(">");
163: return (sb.toString());
164:
165: }
166:
167: }
|