Source Code Cross Referenced for IntFieldSource.java in  » Net » lucene-connector » org » apache » lucene » search » function » 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 » Net » lucene connector » org.apache.lucene.search.function 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.lucene.search.function;
002:
003:        /**
004:         * Licensed to the Apache Software Foundation (ASF) under one or more
005:         * contributor license agreements.  See the NOTICE file distributed with
006:         * this work for additional information regarding copyright ownership.
007:         * The ASF licenses this file to You under the Apache License, Version 2.0
008:         * (the "License"); you may not use this file except in compliance with
009:         * the License.  You may obtain a copy of the License at
010:         *
011:         *     http://www.apache.org/licenses/LICENSE-2.0
012:         *
013:         * Unless required by applicable law or agreed to in writing, software
014:         * distributed under the License is distributed on an "AS IS" BASIS,
015:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016:         * See the License for the specific language governing permissions and
017:         * limitations under the License.
018:         */
019:
020:        import org.apache.lucene.index.IndexReader;
021:        import org.apache.lucene.search.FieldCache;
022:        import org.apache.lucene.search.function.DocValues;
023:
024:        import java.io.IOException;
025:
026:        /**
027:         * Expert: obtains int field values from the 
028:         * {@link org.apache.lucene.search.FieldCache FieldCache}
029:         * using <code>getInts()</code> and makes those values 
030:         * available as other numeric types, casting as needed.
031:         * 
032:         * <p><font color="#FF0000">
033:         * WARNING: The status of the <b>search.function</b> package is experimental. 
034:         * The APIs introduced here might change in the future and will not be 
035:         * supported anymore in such a case.</font>
036:         * 
037:         * @see org.apache.lucene.search.function.FieldCacheSource for requirements 
038:         * on the field.
039:         *
040:         *
041:         */
042:        public class IntFieldSource extends FieldCacheSource {
043:            private FieldCache.IntParser parser;
044:
045:            /**
046:             * Create a cached int field source with default string-to-int parser. 
047:             */
048:            public IntFieldSource(String field) {
049:                this (field, null);
050:            }
051:
052:            /**
053:             * Create a cached int field source with a specific string-to-int parser. 
054:             */
055:            public IntFieldSource(String field, FieldCache.IntParser parser) {
056:                super (field);
057:                this .parser = parser;
058:            }
059:
060:            /*(non-Javadoc) @see org.apache.lucene.search.function.ValueSource#description() */
061:            public String description() {
062:                return "int(" + super .description() + ')';
063:            }
064:
065:            /*(non-Javadoc) @see org.apache.lucene.search.function.FieldCacheSource#getCachedValues(org.apache.lucene.search.FieldCache, java.lang.String, org.apache.lucene.index.IndexReader) */
066:            public DocValues getCachedFieldValues(FieldCache cache,
067:                    String field, IndexReader reader) throws IOException {
068:                final int[] arr = (parser == null) ? cache.getInts(reader,
069:                        field) : cache.getInts(reader, field, parser);
070:                return new DocValues() {
071:                    /*(non-Javadoc) @see org.apache.lucene.search.function.DocValues#floatVal(int) */
072:                    public float floatVal(int doc) {
073:                        return (float) arr[doc];
074:                    }
075:
076:                    /*(non-Javadoc) @see org.apache.lucene.search.function.DocValues#intVal(int) */
077:                    public int intVal(int doc) {
078:                        return arr[doc];
079:                    }
080:
081:                    /*(non-Javadoc) @see org.apache.lucene.search.function.DocValues#toString(int) */
082:                    public String toString(int doc) {
083:                        return description() + '=' + intVal(doc);
084:                    }
085:
086:                    /*(non-Javadoc) @see org.apache.lucene.search.function.DocValues#getInnerArray() */
087:                    Object getInnerArray() {
088:                        return arr;
089:                    }
090:                };
091:            }
092:
093:            /*(non-Javadoc) @see org.apache.lucene.search.function.FieldCacheSource#cachedFieldSourceEquals(org.apache.lucene.search.function.FieldCacheSource) */
094:            public boolean cachedFieldSourceEquals(FieldCacheSource o) {
095:                if (o.getClass() != IntFieldSource.class) {
096:                    return false;
097:                }
098:                IntFieldSource other = (IntFieldSource) o;
099:                return this .parser == null ? other.parser == null : this .parser
100:                        .getClass() == other.parser.getClass();
101:            }
102:
103:            /*(non-Javadoc) @see org.apache.lucene.search.function.FieldCacheSource#cachedFieldSourceHashCode() */
104:            public int cachedFieldSourceHashCode() {
105:                return parser == null ? Integer.class.hashCode() : parser
106:                        .getClass().hashCode();
107:            }
108:
109:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.