Source Code Cross Referenced for FieldProperties.java in  » Search-Engine » apache-solr-1.2.0 » org » apache » solr » schema » 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 » apache solr 1.2.0 » org.apache.solr.schema 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */package org.apache.solr.schema;
017:
018:        import java.util.Map;
019:        import java.util.HashMap;
020:
021:        /**
022:         * @author yonik
023:         * @version $Id: FieldProperties.java 533571 2007-04-29 23:03:03Z ryan $
024:         */
025:        abstract class FieldProperties {
026:
027:            // use a bitfield instead of many different boolean variables since
028:            // many of the variables are independent or semi-independent.
029:
030:            // bit values for boolean field properties.
031:            final static int INDEXED = 0x00000001;
032:            final static int TOKENIZED = 0x00000002;
033:            final static int STORED = 0x00000004;
034:            final static int BINARY = 0x00000008;
035:            final static int COMPRESSED = 0x00000010;
036:            final static int OMIT_NORMS = 0x00000020;
037:            final static int STORE_TERMVECTORS = 0x00000040;
038:            final static int STORE_TERMPOSITIONS = 0x00000080;
039:            final static int STORE_TERMOFFSETS = 0x00000100;
040:
041:            final static int MULTIVALUED = 0x00000200;
042:            final static int SORT_MISSING_FIRST = 0x00000400;
043:            final static int SORT_MISSING_LAST = 0x00000800;
044:
045:            final static int REQUIRED = 0x00001000;
046:
047:            static final String[] propertyNames = { "indexed", "tokenized",
048:                    "stored", "binary", "compressed", "omitNorms",
049:                    "termVectors", "termPositions", "termOffsets",
050:                    "multiValued", "sortMissingFirst", "sortMissingLast",
051:                    "required" };
052:
053:            static final Map<String, Integer> propertyMap = new HashMap<String, Integer>();
054:            static {
055:                for (String prop : propertyNames) {
056:                    propertyMap.put(prop, propertyNameToInt(prop));
057:                }
058:            }
059:
060:            /** Returns the symbolic name for the property. */
061:            static String getPropertyName(int property) {
062:                return propertyNames[Integer.numberOfTrailingZeros(property)];
063:            }
064:
065:            static int propertyNameToInt(String name) {
066:                for (int i = 0; i < propertyNames.length; i++) {
067:                    if (propertyNames[i].equals(name)) {
068:                        return 1 << i;
069:                    }
070:                }
071:                return 0;
072:            }
073:
074:            static String propertiesToString(int properties) {
075:                StringBuilder sb = new StringBuilder();
076:                boolean first = true;
077:                while (properties != 0) {
078:                    if (!first)
079:                        sb.append(',');
080:                    first = false;
081:                    int bitpos = Integer.numberOfTrailingZeros(properties);
082:                    sb.append(getPropertyName(1 << bitpos));
083:                    properties &= ~(1 << bitpos); // clear that bit position
084:                }
085:                return sb.toString();
086:            }
087:
088:            static boolean on(int bitfield, int props) {
089:                return (bitfield & props) != 0;
090:            }
091:
092:            static boolean off(int bitfield, int props) {
093:                return (bitfield & props) == 0;
094:            }
095:
096:            /***
097:            static int normalize(int properties) {
098:              int p = properties;
099:              if (on(p,TOKENIZED) && off(p,INDEXED)) {
100:                throw new RuntimeException("field must be indexed to be tokenized.");
101:              }
102:
103:              if (on(p,STORE_TERMPOSITIONS)) p|=STORE_TERMVECTORS;
104:              if (on(p,STORE_TERMOFFSETS)) p|=STORE_TERMVECTORS;
105:              if (on(p,STORE_TERMOFFSETS) && off(p,INDEXED)) {
106:                throw new RuntimeException("field must be indexed to store term vectors.");
107:              }
108:
109:              if (on(p,OMIT_NORMS) && off(p,INDEXED)) {
110:                throw new RuntimeException("field must be indexed for norms to be omitted.");
111:              }
112:
113:              if (on(p,SORT_MISSING_FIRST) && on(p,SORT_MISSING_LAST)) {
114:                throw new RuntimeException("conflicting options sortMissingFirst,sortMissingLast.");
115:              }
116:
117:              if ((on(p,SORT_MISSING_FIRST) || on(p,SORT_MISSING_LAST)) && off(p,INDEXED)) {
118:                throw new RuntimeException("field must be indexed to be sorted.");
119:              }
120:
121:              if ((on(p,BINARY) || on(p,COMPRESSED)) && off(p,STORED)) {
122:                throw new RuntimeException("field must be stored for compressed or binary options.");
123:              }
124:
125:              return p;
126:            }
127:             ***/
128:
129:            static int parseProperties(Map<String, String> properties,
130:                    boolean which) {
131:                int props = 0;
132:                for (String prop : properties.keySet()) {
133:                    if (propertyMap.get(prop) == null)
134:                        continue;
135:                    String val = properties.get(prop);
136:                    if (Boolean.parseBoolean(val) == which) {
137:                        props |= propertyNameToInt(prop);
138:                    }
139:                }
140:                return props;
141:            }
142:
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.