Source Code Cross Referenced for AbstractUser.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » apps » mailreader » dao » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » struts 1.3.8 » org.apache.struts.apps.mailreader.dao.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: AbstractUser.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 java.util.HashMap;
025:
026:        import org.apache.struts.apps.mailreader.dao.Subscription;
027:        import org.apache.struts.apps.mailreader.dao.User;
028:        import org.apache.struts.apps.mailreader.dao.UserDatabase;
029:
030:        /**
031:         * <p>Concrete implementation of {@link AbstractUser}.</p>
032:         *
033:         * @version $Rev: 471754 $
034:         * @since Struts 1.1
035:         */
036:
037:        public abstract class AbstractUser implements  User {
038:
039:            // ----------------------------------------------------------- Constructors
040:
041:            /**
042:             * <p>Construct a new User associated with the specified
043:             * {@link UserDatabase}.
044:             *
045:             * @param database The user database with which we are associated
046:             * @param username The username of this user
047:             */
048:            public AbstractUser(UserDatabase database, String username) {
049:
050:                super ();
051:                this .database = database;
052:                this .username = username;
053:
054:            }
055:
056:            // ----------------------------------------------------- Instance Variables
057:
058:            /**
059:             * The {@link UserDatabase} with which we are associated.
060:             */
061:            private UserDatabase database = null;
062:
063:            /**
064:             * The {@link Subscription}s for this User, keyed by hostname.
065:             */
066:            private HashMap subscriptions = new HashMap();
067:
068:            /**
069:             * The username for this user.
070:             */
071:            private String username = null;
072:
073:            // ------------------------------------------------------------- Properties
074:
075:            /**
076:             * The {@link UserDatabase} with which we are associated.
077:             */
078:            public UserDatabase getDatabase() {
079:                return (this .database);
080:            }
081:
082:            /**
083:             * The email address from which messages are sent.
084:             */
085:            private String fromAddress = null;
086:
087:            public String getFromAddress() {
088:                return (this .fromAddress);
089:            }
090:
091:            public void setFromAddress(String fromAddress) {
092:                this .fromAddress = fromAddress;
093:            }
094:
095:            /**
096:             * The full name of this user, included in from addresses.
097:             */
098:            private String fullName = null;
099:
100:            public String getFullName() {
101:                return (this .fullName);
102:            }
103:
104:            public void setFullName(String fullName) {
105:                this .fullName = fullName;
106:            }
107:
108:            /**
109:             * The password (in clear text).
110:             */
111:            private String password = null;
112:
113:            public String getPassword() {
114:                return (this .password);
115:            }
116:
117:            public void setPassword(String password) {
118:                this .password = password;
119:            }
120:
121:            /**
122:             * The EMAIL address to which replies should be sent.
123:             */
124:            private String replyToAddress = null;
125:
126:            public String getReplyToAddress() {
127:                return (this .replyToAddress);
128:            }
129:
130:            public void setReplyToAddress(String replyToAddress) {
131:                this .replyToAddress = replyToAddress;
132:            }
133:
134:            /**
135:             * Find and return all {@link Subscription}s associated with this user.
136:             * If there are none, a zero-length array is returned.
137:             */
138:            public Subscription[] getSubscriptions() {
139:
140:                synchronized (subscriptions) {
141:                    Subscription results[] = new Subscription[subscriptions
142:                            .size()];
143:                    return ((Subscription[]) subscriptions.values().toArray(
144:                            results));
145:                }
146:
147:            }
148:
149:            /**
150:             * The username (must be unique).
151:             */
152:            public String getUsername() {
153:                return (this .username);
154:            }
155:
156:            // --------------------------------------------------------- Public Methods
157:
158:            /**
159:             * Create and return a new {@link Subscription} associated with this
160:             * User, for the specified host name.
161:             *
162:             * @param host Host name for which to create a subscription
163:             *
164:             * @exception IllegalArgumentException if the host name is not unique
165:             *  for this user
166:             */
167:            public Subscription createSubscription(String host) {
168:
169:                synchronized (subscriptions) {
170:                    if (subscriptions.get(host) != null) {
171:                        throw new IllegalArgumentException("Duplicate host '"
172:                                + host + "' for user '" + username + "'");
173:                    }
174:                    Subscription subscription = new AbstractSubscription(this ,
175:                            host);
176:                    synchronized (subscriptions) {
177:                        subscriptions.put(host, subscription);
178:                    }
179:                    return (subscription);
180:                }
181:
182:            }
183:
184:            /**
185:             * Find and return the {@link Subscription} associated with the specified
186:             * host.  If none is found, return <code>null</code>.
187:             *
188:             * @param host Host name to look up
189:             */
190:            public Subscription findSubscription(String host) {
191:
192:                synchronized (subscriptions) {
193:                    return ((Subscription) subscriptions.get(host));
194:                }
195:
196:            }
197:
198:            /**
199:             * Remove the specified {@link Subscription} from being associated
200:             * with this User.
201:             *
202:             * @param subscription Subscription to be removed
203:             *
204:             * @exception IllegalArgumentException if the specified subscription is not
205:             *  associated with this User
206:             */
207:            public void removeSubscription(Subscription subscription) {
208:
209:                if (!(this  == subscription.getUser())) {
210:                    throw new IllegalArgumentException(
211:                            "Subscription not associated with this user");
212:                }
213:                synchronized (subscriptions) {
214:                    subscriptions.remove(subscription.getHost());
215:                }
216:
217:            }
218:
219:        }
w__w__w___.___j__a_va_2___s.___c_om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.