Source Code Cross Referenced for LuceneFields.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portal » lucene » 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 » Portal » liferay portal 4.4.2 » com.liferay.portal.lucene 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003:         *
004:         * Permission is hereby granted, free of charge, to any person obtaining a copy
005:         * of this software and associated documentation files (the "Software"), to deal
006:         * in the Software without restriction, including without limitation the rights
007:         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008:         * copies of the Software, and to permit persons to whom the Software is
009:         * furnished to do so, subject to the following conditions:
010:         *
011:         * The above copyright notice and this permission notice shall be included in
012:         * all copies or substantial portions of the Software.
013:         *
014:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015:         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019:         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020:         * SOFTWARE.
021:         */package com.liferay.portal.lucene;
022:
023:        import com.liferay.portal.kernel.util.InstancePool;
024:        import com.liferay.portal.kernel.util.StringMaker;
025:        import com.liferay.portal.util.PropsValues;
026:
027:        import java.io.File;
028:        import java.io.IOException;
029:        import java.io.InputStream;
030:
031:        import java.util.Date;
032:
033:        import org.apache.lucene.document.DateTools;
034:        import org.apache.lucene.document.Field;
035:
036:        /**
037:         * <a href="LuceneFields.java.html"><b><i>View Source</i></b></a>
038:         *
039:         * @author Brian Wing Shun Chan
040:         *
041:         */
042:        public class LuceneFields {
043:
044:            public static final String UID = "uid";
045:
046:            public static final String COMPANY_ID = "companyId";
047:
048:            public static final String PORTLET_ID = "portletId";
049:
050:            public static final String GROUP_ID = "groupId";
051:
052:            public static final String USER_ID = "userId";
053:
054:            public static final String USER_NAME = "userName";
055:
056:            public static final String TYPE = "type";
057:
058:            public static final String TITLE = "title";
059:
060:            public static final String DESCRIPTION = "description";
061:
062:            public static final String CONTENT = "content";
063:
064:            public static final String PROPERTIES = "properties";
065:
066:            public static final String MODIFIED = "modified";
067:
068:            public static final String VERSION_LABEL = "versionLabel";
069:
070:            public static final String TAG_ENTRY = "tag_entry";
071:
072:            public static String getUID(String portletId, long field1) {
073:                return getUID(portletId, String.valueOf(field1));
074:            }
075:
076:            public static String getUID(String portletId, Long field1) {
077:                return getUID(portletId, field1.longValue());
078:            }
079:
080:            public static String getUID(String portletId, String field1) {
081:                return getUID(portletId, field1, null);
082:            }
083:
084:            public static String getUID(String portletId, long field1,
085:                    String field2) {
086:
087:                return getUID(portletId, String.valueOf(field1), field2);
088:            }
089:
090:            public static String getUID(String portletId, Long field1,
091:                    String field2) {
092:
093:                return getUID(portletId, field1.longValue(), field2);
094:            }
095:
096:            public static String getUID(String portletId, String field1,
097:                    String field2) {
098:
099:                return getUID(portletId, field1, field2, null);
100:            }
101:
102:            public static String getUID(String portletId, String field1,
103:                    String field2, String field3) {
104:
105:                String uid = portletId + _UID_PORTLET + field1;
106:
107:                if (field2 != null) {
108:                    uid += _UID_FIELD + field2;
109:                }
110:
111:                if (field3 != null) {
112:                    uid += _UID_FIELD + field3;
113:                }
114:
115:                return uid;
116:            }
117:
118:            public static Field getDate(String field) {
119:                return getDate(field, new Date());
120:            }
121:
122:            public static Field getDate(String field, Date date) {
123:                if (date == null) {
124:                    return getDate(field);
125:                } else {
126:                    return new Field(field, DateTools.dateToString(date,
127:                            DateTools.Resolution.SECOND), Field.Store.YES,
128:                            Field.Index.UN_TOKENIZED);
129:                }
130:            }
131:
132:            public static Field getFile(String field, InputStream is,
133:                    String fileExt) throws IOException {
134:
135:                LuceneFileExtractor fileExtractor = (LuceneFileExtractor) InstancePool
136:                        .get(PropsValues.LUCENE_FILE_EXTRACTOR);
137:
138:                return fileExtractor.getFile(field, is, fileExt);
139:            }
140:
141:            public static Field getFile(String field, byte[] byteArray,
142:                    String fileExt) throws IOException {
143:
144:                LuceneFileExtractor fileExtractor = (LuceneFileExtractor) InstancePool
145:                        .get(PropsValues.LUCENE_FILE_EXTRACTOR);
146:
147:                return fileExtractor.getFile(field, byteArray, fileExt);
148:            }
149:
150:            public static Field getFile(String field, File file, String fileExt)
151:                    throws IOException {
152:
153:                LuceneFileExtractor fileExtractor = (LuceneFileExtractor) InstancePool
154:                        .get(PropsValues.LUCENE_FILE_EXTRACTOR);
155:
156:                return fileExtractor.getFile(field, file, fileExt);
157:            }
158:
159:            public static Field getKeyword(String field, double keyword) {
160:                return getKeyword(field, String.valueOf(keyword));
161:            }
162:
163:            public static Field getKeyword(String field, long keyword) {
164:                return getKeyword(field, String.valueOf(keyword));
165:            }
166:
167:            public static Field getKeyword(String field, Long keyword) {
168:                return getKeyword(field, keyword.longValue());
169:            }
170:
171:            public static Field getKeyword(String field, String keyword) {
172:                //keyword = KeywordsUtil.escape(keyword);
173:
174:                Field fieldObj = new Field(field, keyword, Field.Store.YES,
175:                        Field.Index.UN_TOKENIZED);
176:
177:                //fieldObj.setBoost(0);
178:
179:                return fieldObj;
180:            }
181:
182:            public static Field getText(String field, String text) {
183:                return new Field(field, text, Field.Store.YES,
184:                        Field.Index.TOKENIZED);
185:            }
186:
187:            public static Field getText(String field, StringMaker sm) {
188:                return getText(field, sm.toString());
189:            }
190:
191:            private static final String _UID_PORTLET = "_PORTLET_";
192:
193:            private static final String _UID_FIELD = "_FIELD_";
194:
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.