001: /*
002: * $Id: AbstractSubscription.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.apps.mailreader.dao.impl;
023:
024: import org.apache.struts.apps.mailreader.dao.Subscription;
025: import org.apache.struts.apps.mailreader.dao.User;
026:
027: /**
028: * <p>Concrete implementation of {@link AbstractSubscription}.</p>
029: *
030: * @version $Rev: 471754 $
031: * @since Struts 1.1
032: */
033:
034: public class AbstractSubscription implements Subscription {
035:
036: // ----------------------------------------------------------- Constructors
037:
038: /**
039: * <p>Construct a new Subscription associated with the specified
040: * {@link User}.
041: *
042: * @param user The user with which we are associated
043: * @param host The mail host for this subscription
044: */
045: public AbstractSubscription(User user, String host) {
046:
047: super ();
048: this .user = user;
049: this .host = host;
050:
051: }
052:
053: // ----------------------------------------------------- Instance Variables
054:
055: /**
056: * The mail host for this subscription.
057: */
058: private String host = null;
059:
060: /**
061: * The {@link User} with which we are associated.
062: */
063: private User user = null;
064:
065: // ------------------------------------------------------------- Properties
066:
067: /**
068: * Should we auto-connect at startup time?
069: */
070: private boolean autoConnect = false;
071:
072: public boolean getAutoConnect() {
073: return (this .autoConnect);
074: }
075:
076: public void setAutoConnect(boolean autoConnect) {
077: this .autoConnect = autoConnect;
078: }
079:
080: /**
081: * The mail host for this subscription.
082: */
083: public String getHost() {
084: return (this .host);
085: }
086:
087: /**
088: * The password (in clear text) for this subscription.
089: */
090: private String password = null;
091:
092: public String getPassword() {
093: return (this .password);
094: }
095:
096: public void setPassword(String password) {
097: this .password = password;
098: }
099:
100: /**
101: * The subscription type ("imap" or "pop3").
102: */
103: private String type = "imap";
104:
105: public String getType() {
106: return (this .type);
107: }
108:
109: public void setType(String type) {
110: this .type = type;
111: }
112:
113: /**
114: * The User owning this Subscription.
115: */
116: public User getUser() {
117: return (this .user);
118: }
119:
120: /**
121: * The username for this subscription.
122: */
123: private String username = null;
124:
125: public String getUsername() {
126: return (this .username);
127: }
128:
129: public void setUsername(String username) {
130: this .username = username;
131: }
132:
133: // --------------------------------------------------------- Public Methods
134:
135: /**
136: * Return a String representation of this object.
137: */
138: public String toString() {
139:
140: StringBuffer sb = new StringBuffer("<subscription host=\"");
141: sb.append(host);
142: sb.append("\" autoConnect=\"");
143: sb.append(autoConnect);
144: sb.append("\"");
145: if (password != null) {
146: sb.append(" password=\"");
147: sb.append(password);
148: sb.append("\"");
149: }
150: if (type != null) {
151: sb.append(" type=\"");
152: sb.append(type);
153: sb.append("\"");
154: }
155: if (username != null) {
156: sb.append(" username=\"");
157: sb.append(username);
158: sb.append("\"");
159: }
160: sb.append(">");
161: return (sb.toString());
162:
163: }
164:
165: }
|