Source Code Cross Referenced for VCardIndexer.java in  » Search-Engine » Lius-0.4 » de » teamskill » lius » index » application » 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 » Search Engine » Lius 0.4 » de.teamskill.lius.index.application 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Project: LIUS 
003:         * Package: de.teamskill.lius.index.application
004:         * 
005:         * Copyright (c) 2004 by Jens Fendler <jf@teamskill.de>
006:         * 
007:         * This program is a free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU General Public License as published by the Free
009:         * Software Foundation; either version 2 of the License, or (at your option) any
010:         * later version. This program is distributed in the hope that it will be
011:         * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
013:         * Public License for more details. You should have received a copy of the GNU
014:         * General Public License along with this program; if not, write to the Free
015:         * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
016:         * USA
017:         */
018:
019:        package de.teamskill.lius.index.application;
020:
021:        import java.io.IOException;
022:        import java.util.ArrayList;
023:        import java.util.Collection;
024:        import java.util.Iterator;
025:        import java.util.List;
026:
027:        import org.apache.lucene.document.Document;
028:
029:        import ca.ulaval.bibl.lius.config.LiusConfig;
030:        import ca.ulaval.bibl.lius.config.LiusField;
031:        import ca.ulaval.bibl.lius.config.LiusProxyField;
032:        import ca.ulaval.bibl.lius.config.LiusValueProxyField;
033:        import ca.ulaval.bibl.lius.index.Indexer;
034:        import de.teamskill.util.VCard;
035:        import de.teamskill.util.parser.VCardParser;
036:
037:        /**
038:         * Class: VCardIndexer <br>
039:         * 
040:         * This Indexer reads .vcf and .vcard files as exported by various email and PIM
041:         * applications (e.g. Mozilla Mail, Evolution, KMail). Fields which can be
042:         * indexed are:
043:         * 
044:         * <ul>
045:         * <li><code>name</code>: The contact's full name</li>
046:         * <li><code>title</code>: Title (e.g. 'Dr.')</li>
047:         * <li><code>nickname</code>: nickname</li>
048:         * <li><code>birthday</code>: user notes</li>
049:         * <li><code>email</code>: email addresses</li>
050:         * <li><code>phone</code>: all available phone numbers</li>
051:         * <li><code>homephone</code>: home phone number</li>
052:         * <li><code>workphone</code>: work phone number</li>
053:         * <li><code>cellphone</code>: cell phone number</li>
054:         * <li><code>categories</code>: categories as used by the creator-application
055:         * </li>
056:         * <li><code>address</code>: all available addresses</li>
057:         * <li><code>homeaddress</code>: the home address</li>
058:         * <li><code>workaddress</code>: the work address</li>
059:         * <li><code>url</code>: the URL (usually an http address)</li>
060:         * <li><code>organization</code>: the organization</li>
061:         * </ul>
062:         * <br/>
063:         * 
064:         * Changelog:
065:         * <ul>
066:         * <li>02.06.2005: Initial implementation (jf)</li>
067:         * </ul>
068:         * 
069:         * @author <a href="mailto:jf@teamskill.de">Jens Fendler </a>
070:         */
071:        public class VCardIndexer extends Indexer {
072:
073:            /**
074:             * @see ca.ulaval.bibl.lius.index.Indexer#createLuceneDocument(java.lang.String,
075:             *      ca.ulaval.bibl.lius.config.LiusConfig)
076:             */
077:            public Document createLuceneDocument(String file, LiusConfig lc) {
078:                return createLuceneDocument(file, lc.getVCardFields());
079:            }
080:
081:            /**
082:             * @see ca.ulaval.bibl.lius.index.Indexer#getLiusFields(ca.ulaval.bibl.lius.config.LiusConfig)
083:             */
084:            public Collection getLiusFields(LiusConfig lc) {
085:                return lc.getVCardFields();
086:            }
087:
088:            /**
089:             * @see ca.ulaval.bibl.lius.index.Indexer#getPopulatedCollection(java.lang.Object,
090:             *      java.util.Collection)
091:             */
092:            public Collection getPopulatedCollection(Object file,
093:                    Collection liusFields) {
094:                Collection c = new ArrayList();
095:                try {
096:                    VCardParser vcp = new VCardParser((String) file);
097:                    for (Iterator i = liusFields.iterator(); i.hasNext();) {
098:                        Object next = i.next();
099:                        if (next instanceof  LiusField) {
100:                            LiusField lf = (LiusField) next;
101:                            addVCardProxyFields(vcp, lf, c);
102:                        } else
103:                            c.add(next);
104:                    }
105:                } catch (IOException e) {
106:                    // ignore for now..
107:                }
108:
109:                return c;
110:            }
111:
112:            private void addVCardProxyFields(VCardParser vcp, LiusField lf,
113:                    Collection c) {
114:                if ("name".equalsIgnoreCase(lf.getGet())) {
115:                    addElements(vcp, "FN", null, lf, c);
116:                } else if ("title".equalsIgnoreCase(lf.getGet())) {
117:                    addElements(vcp, "TITLE", null, lf, c);
118:                } else if ("nickname".equalsIgnoreCase(lf.getGet())) {
119:                    addElements(vcp, "NICKNAME", null, lf, c);
120:                } else if ("birthday".equalsIgnoreCase(lf.getGet())) {
121:                    addElements(vcp, "BDAY", null, lf, c);
122:                } else if ("notes".equalsIgnoreCase(lf.getGet())) {
123:                    addElements(vcp, "NOTE", null, lf, c);
124:                } else if ("email".equalsIgnoreCase(lf.getGet())) {
125:                    addElements(vcp, "EMAIL", null, lf, c);
126:                } else if ("phone".equalsIgnoreCase(lf.getGet())) {
127:                    addElements(vcp, "TEL", null, lf, c);
128:                } else if ("homephone".equalsIgnoreCase(lf.getGet())) {
129:                    addElements(vcp, "TEL", "HOME", lf, c);
130:                } else if ("workphone".equalsIgnoreCase(lf.getGet())) {
131:                    addElements(vcp, "TEL", "WORK", lf, c);
132:                } else if ("cellphone".equalsIgnoreCase(lf.getGet())) {
133:                    addElements(vcp, "TEL", "CELL", lf, c);
134:                } else if ("categories".equalsIgnoreCase(lf.getGet())) {
135:                    addElements(vcp, "CATEGORIES", null, lf, c);
136:                } else if ("address".equalsIgnoreCase(lf.getGet())) {
137:                    addElements(vcp, "ADR", null, lf, c);
138:                } else if ("homeaddress".equalsIgnoreCase(lf.getGet())) {
139:                    addElements(vcp, "ADR", "HOME", lf, c);
140:                } else if ("workaddress".equalsIgnoreCase(lf.getGet())) {
141:                    addElements(vcp, "ADR", "WORK", lf, c);
142:                } else if ("url".equalsIgnoreCase(lf.getGet())) {
143:                    addElements(vcp, "URL", null, lf, c);
144:                } else if ("organization".equalsIgnoreCase(lf.getGet())) {
145:                    addElements(vcp, "ORG", null, lf, c);
146:                }
147:            }
148:
149:            private void addElements(VCardParser vcp, String key, String type,
150:                    LiusField realField, Collection c) {
151:                List cards = vcp.getCards();
152:                for (int i = 0; i < cards.size(); i++) {
153:                    VCard card = (VCard) cards.get(i);
154:                    String data = (type == null) ? card.getElement(key) : card
155:                            .getElement(key, type);
156:                    if (data != null) {
157:                        LiusProxyField lpf = new LiusValueProxyField(realField);
158:                        lpf.setValue(data);
159:                        c.add(lpf);
160:                    }
161:                }
162:            }
163:
164:            /**
165:             * @see ca.ulaval.bibl.lius.index.Indexer#getPopulatedCollection(java.lang.Object,
166:             *      java.lang.String)
167:             */
168:            public Collection getPopulatedCollection(Object file,
169:                    String liusConfig) {
170:                return getPopulatedCollection(file, liusConfig);
171:            }
172:
173:            /**
174:             * @see ca.ulaval.bibl.lius.index.Indexer#getPopulatedCollection(java.lang.Object,
175:             *      ca.ulaval.bibl.lius.config.LiusConfig)
176:             */
177:            public Collection getPopulatedCollection(Object file,
178:                    LiusConfig liusConfig) {
179:                return getPopulatedCollection(file, liusConfig.getVCardFields());
180:            }
181:
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.