Source Code Cross Referenced for AccountItem.java in  » Mail-Clients » columba-1.4 » org » columba » mail » config » 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 » Mail Clients » columba 1.4 » org.columba.mail.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //The contents of this file are subject to the Mozilla Public License Version 1.1
002:        //(the "License"); you may not use this file except in compliance with the 
003:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004:        //
005:        //Software distributed under the License is distributed on an "AS IS" basis,
006:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
007:        //for the specific language governing rights and
008:        //limitations under the License.
009:        //
010:        //The Original Code is "The Columba Project"
011:        //
012:        //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003. 
014:        //
015:        //All Rights Reserved.
016:
017:        package org.columba.mail.config;
018:
019:        import org.columba.core.config.DefaultItem;
020:        import org.columba.core.xml.XmlElement;
021:        import org.columba.ristretto.parser.ParserException;
022:
023:        public class AccountItem extends DefaultItem {
024:
025:            /*
026:             * Add supported account formats here
027:             * */
028:            public static final int POP3_ACCOUNT = 0, IMAP_ACCOUNT = 1,
029:                    UNKNOWN_TYPE = -1;
030:
031:            private AccountItem defaultAccount;
032:            //private boolean pop3;
033:            private Identity identity;
034:            private PopItem pop;
035:            private ImapItem imap;
036:            private OutgoingItem smtp;
037:            private SecurityItem pgp;
038:            private SpecialFoldersItem folder;
039:            private SpamItem spam;
040:
041:            private int accountType = UNKNOWN_TYPE;
042:
043:            public AccountItem(XmlElement e) {
044:                super (e);
045:
046:                if (e.getElement("/popserver") != null) {
047:                    accountType = POP3_ACCOUNT;
048:                } else if (e.getElement("/imapserver") != null) {
049:                    accountType = IMAP_ACCOUNT;
050:                } else
051:                    accountType = UNKNOWN_TYPE;
052:
053:            }
054:
055:            /*
056:             * validates a hostname, i.e.:
057:             * mail.myhost.com
058:             * mail.us.myhost.com
059:             * 127.0.0.1
060:             * */
061:
062:            public final String getAccountTypeDescription() {
063:                switch (accountType) {
064:                case POP3_ACCOUNT:
065:                    return "POP3";
066:                case IMAP_ACCOUNT:
067:                    return "IMAP";
068:                default:
069:                    return "UNKNOWN";
070:                }
071:            }
072:
073:            public final int getAccountType() {
074:                return accountType;
075:            }
076:
077:            public boolean isPopAccount() {
078:                return (accountType == POP3_ACCOUNT);
079:            }
080:
081:            public SpecialFoldersItem getSpecialFoldersItem() {
082:                if (folder == null) {
083:                    folder = new SpecialFoldersItem(getRoot().getElement(
084:                            "specialfolders"));
085:                }
086:
087:                if (folder.getBoolean("use_default_account")) {
088:                    // return default-account ImapItem instead 
089:                    SpecialFoldersItem item = MailConfig.getInstance()
090:                            .getAccountList().getDefaultAccount()
091:                            .getSpecialFoldersItem();
092:
093:                    return item;
094:                }
095:
096:                return folder;
097:            }
098:
099:            private AccountItem getDefaultAccount() {
100:                if (defaultAccount == null) {
101:                    defaultAccount = MailConfig.getInstance().getAccountList()
102:                            .getDefaultAccount();
103:                }
104:
105:                return defaultAccount;
106:            }
107:
108:            public PopItem getPopItem() {
109:                if (pop == null) {
110:                    pop = new PopItem(getRoot().getElement("popserver"));
111:                }
112:
113:                if (pop.getBoolean("use_default_account")) {
114:                    // return default-account ImapItem instead 
115:                    PopItem item = MailConfig.getInstance().getAccountList()
116:                            .getDefaultAccount().getPopItem();
117:
118:                    return item;
119:                }
120:
121:                return pop;
122:            }
123:
124:            public IncomingItem getIncomingItem() {
125:                if (isPopAccount()) {
126:                    return getPopItem();
127:                } else {
128:                    return getImapItem();
129:                }
130:            }
131:
132:            public OutgoingItem getSmtpItem() {
133:                if (smtp == null) {
134:                    smtp = new OutgoingItem(getRoot().getElement("smtpserver"));
135:                }
136:
137:                if (smtp.getBoolean("use_default_account")) {
138:                    // return default-account ImapItem instead 
139:                    return getDefaultAccount().getSmtpItem();
140:                }
141:
142:                return smtp;
143:            }
144:
145:            public SpamItem getSpamItem() {
146:                if (spam == null) {
147:                    XmlElement parent = getRoot().getElement("spam");
148:                    // create if not available
149:                    if (parent == null)
150:                        parent = getRoot().addSubElement("spam");
151:
152:                    spam = new SpamItem(parent);
153:                }
154:
155:                if (spam.getBoolean("use_default_account")) {
156:                    // return default-account SpamItem instead 
157:                    return getDefaultAccount().getSpamItem();
158:                }
159:
160:                return spam;
161:            }
162:
163:            public SecurityItem getPGPItem() {
164:                if (pgp == null) {
165:                    pgp = new SecurityItem(getRoot().getElement("pgp"));
166:                }
167:
168:                if (pgp.getBoolean("use_default_account")) {
169:                    // return default-account ImapItem instead 
170:                    SecurityItem item = MailConfig.getInstance()
171:                            .getAccountList().getDefaultAccount().getPGPItem();
172:
173:                    return item;
174:                }
175:
176:                return pgp;
177:            }
178:
179:            public ImapItem getImapItem() {
180:                if (imap == null) {
181:                    imap = new ImapItem(getRoot().getElement("imapserver"));
182:                }
183:
184:                if (imap.getBoolean("use_default_account")) {
185:                    // return default-account ImapItem instead 
186:                    ImapItem item = MailConfig.getInstance().getAccountList()
187:                            .getDefaultAccount().getImapItem();
188:
189:                    return item;
190:                }
191:
192:                return imap;
193:            }
194:
195:            /**
196:             * Returns the identity used with this account.
197:             */
198:            public Identity getIdentity() {
199:                if (identity == null) {
200:                    XmlElement e = getRoot().getElement("identity");
201:                    if (Boolean.valueOf(
202:                            e.getAttribute("use_default_account", "false"))
203:                            .booleanValue()) {
204:                        // return default-account identityItem instead
205:                        return MailConfig.getInstance().getAccountList()
206:                                .getDefaultAccount().getIdentity();
207:                    } else {
208:                        try {
209:                            identity = new Identity(e);
210:                        } catch (ParserException ex) {
211:                            ex.printStackTrace();
212:                        }
213:                    }
214:                }
215:
216:                return identity;
217:            }
218:
219:            public void setName(String str) {
220:                setString("name", str);
221:            }
222:
223:            public String getName() {
224:                return get("name");
225:            }
226:
227:            public void setUid(int i) {
228:                setInteger("uid", i);
229:            }
230:
231:            public int getUid() {
232:                return getInteger("uid");
233:            }
234:
235:            public boolean isDefault() {
236:                if (MailConfig.getInstance().getAccountList()
237:                        .getDefaultAccountUid() == getUid()) {
238:                    return true;
239:                }
240:
241:                return false;
242:            }
243:
244:            /** {@inheritDoc} */
245:            public boolean equals(Object obj) {
246:                if (this  == obj) {
247:                    return true; // same object
248:                }
249:
250:                if ((obj == null) || !(obj instanceof  AccountItem)) {
251:                    return false;
252:                }
253:
254:                /*
255:                 * The fields on this object is in fact represented in the xml
256:                 * structure found as getRoot(). Therefore super.equals()
257:                 * should do the job
258:                 */
259:                return super .equals(obj);
260:            }
261:
262:            /** {@inheritDoc} */
263:            public int hashCode() {
264:                /*
265:                 * The fields on this object is in fact represented in the xml
266:                 * structure found as getRoot(). Therefore super.hashCode()
267:                 * should do the job.
268:                 */
269:                return super.hashCode();
270:            }
271:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.