Source Code Cross Referenced for CmsSearchFieldConfiguration.java in  » Content-Management-System » opencms » org » opencms » search » fields » 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 » Content Management System » opencms » org.opencms.search.fields 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/search/fields/CmsSearchFieldConfiguration.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:31 $
004:         * Version: $Revision: 1.5 $
005:         *
006:         * This library is part of OpenCms -
007:         * the Open Source Content Management System
008:         *
009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010:         *
011:         * This library is free software; you can redistribute it and/or
012:         * modify it under the terms of the GNU Lesser General Public
013:         * License as published by the Free Software Foundation; either
014:         * version 2.1 of the License, or (at your option) any later version.
015:         *
016:         * This library is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019:         * Lesser General Public License for more details.
020:         *
021:         * For further information about Alkacon Software, please see the
022:         * company website: http://www.alkacon.com
023:         *
024:         * For further information about OpenCms, please see the
025:         * project website: http://www.opencms.org
026:         * 
027:         * You should have received a copy of the GNU Lesser General Public
028:         * License along with this library; if not, write to the Free Software
029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030:         */
031:
032:        package org.opencms.search.fields;
033:
034:        import org.opencms.file.CmsPropertyDefinition;
035:
036:        import java.util.ArrayList;
037:        import java.util.Iterator;
038:        import java.util.List;
039:
040:        /**
041:         * Describes a configuration of fields that are used in building a search index.<p>
042:         * 
043:         * @author Alexander Kandzior 
044:         * 
045:         * @version $Revision: 1.5 $ 
046:         * 
047:         * @since 7.0.0 
048:         */
049:        public class CmsSearchFieldConfiguration implements  Comparable {
050:
051:            /**
052:             * The default for the standard search configuration.<p>
053:             * 
054:             * This defines the default that is used in case no "standard" field configuration 
055:             * is defined in <code>opencms-search.xml</code>.<p>
056:             */
057:            public static final CmsSearchFieldConfiguration DEFAULT_STANDARD = createStandardConfiguration();
058:
059:            /** The name for the standard field configuration. */
060:            public static final String STR_STANDARD = "standard";
061:
062:            /** The description for the standard field configuration. */
063:            public static final String STR_STANDARD_DESCRIPTION = "The standard OpenCms 7.0 search index field configuration.";
064:
065:            /** The description of the configuration. */
066:            private String m_description;
067:
068:            /** Contains all names of the fields that are used in the excerpt. */
069:            private List m_excerptFieldNames;
070:
071:            /** The list of configured {@link CmsSearchField} names. */
072:            private List m_fieldNames;
073:
074:            /** The list of configured {@link CmsSearchField} objects. */
075:            private List m_fields;
076:
077:            /** The name of the configuration. */
078:            private String m_name;
079:
080:            /**
081:             * Creates a new, empty field configuration.<p>
082:             */
083:            public CmsSearchFieldConfiguration() {
084:
085:                m_fields = new ArrayList();
086:            }
087:
088:            /**
089:             * Creates the default standard search configuration.<p>
090:             * 
091:             * This defines the default that is used in case no "standard" field configuration 
092:             * is defined in <code>opencms-search.xml</code>.<p>
093:             * 
094:             * @return the default standard search configuration
095:             */
096:            private static CmsSearchFieldConfiguration createStandardConfiguration() {
097:
098:                CmsSearchFieldConfiguration result = new CmsSearchFieldConfiguration();
099:                result.setName(STR_STANDARD);
100:                result.setDescription(STR_STANDARD_DESCRIPTION);
101:
102:                CmsSearchField field;
103:                // content mapping
104:                field = new CmsSearchField(CmsSearchField.FIELD_CONTENT,
105:                        "%(key.field.content)", true, true, true, true,
106:                        CmsSearchField.BOOST_DEFAULT, null);
107:                field.addMapping(new CmsSearchFieldMapping(
108:                        CmsSearchFieldMappingType.CONTENT, null));
109:                result.addField(field);
110:
111:                // title mapping as a keyword
112:                field = new CmsSearchField(CmsSearchField.FIELD_TITLE,
113:                        CmsSearchField.IGNORE_DISPLAY_NAME, true, true, false,
114:                        false, 0.0f, null);
115:                field.addMapping(new CmsSearchFieldMapping(
116:                        CmsSearchFieldMappingType.PROPERTY,
117:                        CmsPropertyDefinition.PROPERTY_TITLE));
118:                result.addField(field);
119:
120:                // title mapping as indexed field
121:                field = new CmsSearchField(CmsSearchField.FIELD_TITLE_UNSTORED,
122:                        "%(key.field.title)", false, true);
123:                field.addMapping(new CmsSearchFieldMapping(
124:                        CmsSearchFieldMappingType.PROPERTY,
125:                        CmsPropertyDefinition.PROPERTY_TITLE));
126:                result.addField(field);
127:
128:                // mapping of "Keywords" property to search field with the same name
129:                field = new CmsSearchField(CmsSearchField.FIELD_KEYWORDS,
130:                        "%(key.field.keywords)", true, true);
131:                field.addMapping(new CmsSearchFieldMapping(
132:                        CmsSearchFieldMappingType.PROPERTY,
133:                        CmsPropertyDefinition.PROPERTY_KEYWORDS));
134:                result.addField(field);
135:
136:                // mapping of "Description" property to search field with the same name
137:                field = new CmsSearchField(CmsSearchField.FIELD_DESCRIPTION,
138:                        "%(key.field.description)", true, true);
139:                field.addMapping(new CmsSearchFieldMapping(
140:                        CmsSearchFieldMappingType.PROPERTY,
141:                        CmsPropertyDefinition.PROPERTY_DESCRIPTION));
142:                result.addField(field);
143:
144:                // "meta" field is a combination of "Title", "Keywords" and "Description" properties
145:                field = new CmsSearchField(CmsSearchField.FIELD_META,
146:                        "%(key.field.meta)", false, true);
147:                field.addMapping(new CmsSearchFieldMapping(
148:                        CmsSearchFieldMappingType.PROPERTY,
149:                        CmsPropertyDefinition.PROPERTY_TITLE));
150:                field.addMapping(new CmsSearchFieldMapping(
151:                        CmsSearchFieldMappingType.PROPERTY,
152:                        CmsPropertyDefinition.PROPERTY_KEYWORDS));
153:                field.addMapping(new CmsSearchFieldMapping(
154:                        CmsSearchFieldMappingType.PROPERTY,
155:                        CmsPropertyDefinition.PROPERTY_DESCRIPTION));
156:                result.addField(field);
157:
158:                return result;
159:            }
160:
161:            /**
162:             * Adds a field to this search field configuration.<p>
163:             * 
164:             * @param field the field to add
165:             */
166:            public void addField(CmsSearchField field) {
167:
168:                if (field != null) {
169:                    m_fields.add(field);
170:                }
171:            }
172:
173:            /** 
174:             * @see java.lang.Comparable#compareTo(Object)
175:             */
176:            public int compareTo(Object obj) {
177:
178:                if (obj instanceof  CmsSearchFieldConfiguration) {
179:                    return m_name
180:                            .compareTo(((CmsSearchFieldConfiguration) obj).m_name);
181:                }
182:                return 0;
183:            }
184:
185:            /**
186:             * @see java.lang.Object#equals(java.lang.Object)
187:             */
188:            public boolean equals(Object obj) {
189:
190:                if (obj == this ) {
191:                    return true;
192:                }
193:                if (obj instanceof  CmsSearchFieldConfiguration) {
194:                    return ((CmsSearchFieldConfiguration) obj).m_name
195:                            .equals(m_name);
196:                }
197:                return false;
198:            }
199:
200:            /**
201:             * Returns the description of this field configuration.<p>
202:             * 
203:             * @return the description of this field configuration
204:             */
205:            public String getDescription() {
206:
207:                return m_description;
208:            }
209:
210:            /**
211:             * Returns a list of all field names (Strings) that are used in generating the search excerpt.<p>
212:             * 
213:             * @return a list of all field names (Strings) that are used in generating the search excerpt
214:             */
215:            public List getExcerptFieldNames() {
216:
217:                if (m_excerptFieldNames == null) {
218:                    // lazy initialize the field names
219:                    m_excerptFieldNames = new ArrayList();
220:                    Iterator i = m_fields.iterator();
221:                    while (i.hasNext()) {
222:                        CmsSearchField field = (CmsSearchField) i.next();
223:                        if (field.isInExcerptAndStored()) {
224:                            m_excerptFieldNames.add(field.getName());
225:                        }
226:                    }
227:                }
228:
229:                // create a copy of the list to prevent changes in other classes
230:                return new ArrayList(m_excerptFieldNames);
231:            }
232:
233:            /**
234:             * Returns the list of configured field names (Strings).<p>
235:             * 
236:             * @return the list of configured field names (Strings)
237:             */
238:            public List getFieldNames() {
239:
240:                if (m_fieldNames == null) {
241:                    // lazy initialize the field names
242:                    m_fieldNames = new ArrayList();
243:                    Iterator i = m_fields.iterator();
244:                    while (i.hasNext()) {
245:                        m_fieldNames.add(((CmsSearchField) i.next()).getName());
246:                    }
247:                }
248:
249:                // create a copy of the list to prevent changes in other classes
250:                return new ArrayList(m_fieldNames);
251:            }
252:
253:            /**
254:             * Returns the list of configured {@link CmsSearchField} instances.<p>
255:             * 
256:             * @return the list of configured {@link CmsSearchField} instances
257:             */
258:            public List getFields() {
259:
260:                return m_fields;
261:            }
262:
263:            /**
264:             * Returns the name of this field configuration.<p>
265:             *
266:             * @return the name of this field configuration
267:             */
268:            public String getName() {
269:
270:                return m_name;
271:            }
272:
273:            /**
274:             * @see java.lang.Object#hashCode()
275:             */
276:            public int hashCode() {
277:
278:                return m_name.hashCode();
279:            }
280:
281:            /**
282:             * Sets the description of this field configuration.<p>
283:             * 
284:             * @param description the description to set
285:             */
286:            public void setDescription(String description) {
287:
288:                m_description = description;
289:            }
290:
291:            /**
292:             * Sets the name of this field configuration.<p>
293:             *
294:             * @param name the name to set
295:             */
296:            public void setName(String name) {
297:
298:                m_name = name;
299:            }
300:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.