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


001:        /*
002:         * $Header$
003:         * $Revision: 1749 $
004:         * $Date: 2006-04-04 08:41:40 -0700 $
005:         *
006:         * ====================================================================
007:         *
008:         * Copyright 1999-2002 The Apache Software Foundation 
009:         *
010:         * Licensed under the Apache License, Version 2.0 (the "License");
011:         * you may not use this file except in compliance with the License.
012:         * You may obtain a copy of the License at
013:         *
014:         *     http://www.apache.org/licenses/LICENSE-2.0
015:         *
016:         * Unless required by applicable law or agreed to in writing, software
017:         * distributed under the License is distributed on an "AS IS" BASIS,
018:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019:         * See the License for the specific language governing permissions and
020:         * limitations under the License.
021:         *
022:         */
023:
024:        package org.apache.slide.search;
025:
026:        import java.util.Comparator;
027:        import java.util.Iterator;
028:        import java.util.Set;
029:        import java.util.Vector;
030:
031:        /**
032:         * Aggregates a set containing the result items of a query. This set is either
033:         * a HashSet (if no ordering was requested) or a TreeSet (if orderby was
034:         * specified) May also contain a status and a response description
035:         * (For example: 507 partial result)
036:         *
037:         *
038:         * @version $Revision: 1749 $
039:         */
040:        public class LuceneSearchQueryResult extends SearchQueryResult {
041:
042:            private int limit;
043:            private Vector container = new Vector();
044:            private Comparator comparator;
045:
046:            /**
047:             * Method add
048:             *
049:             * @param    subResultSet        a  SearchQueryResult
050:             *
051:             */
052:            public void add(SearchQueryResult subResultSet) {
053:                merge(subResultSet);
054:            }
055:
056:            /**
057:             * Merge method
058:             * 
059:             * Merges two SearchQueryResults, which are ordered
060:             *
061:             */
062:            public void merge(SearchQueryResult subResult) {
063:                Vector newContainer = new Vector();
064:
065:                Iterator newIt = subResult.iterator();
066:                Iterator conIt = container.iterator();
067:
068:                Object newObj = null;
069:                Object conObj = null;
070:
071:                if (conIt.hasNext())
072:                    conObj = conIt.next();
073:                else
074:                    conObj = null;
075:
076:                if (newIt.hasNext())
077:                    newObj = newIt.next();
078:                else
079:                    newObj = null;
080:
081:                while (newObj != null && conObj != null
082:                        && (limit < 0 || newContainer.size() <= limit)) {
083:                    if (comparator.compare(newObj, conObj) <= 0) // newObj is less
084:                    {
085:                        newContainer.add(newObj);
086:
087:                        if (newIt.hasNext())
088:                            newObj = newIt.next();
089:                        else
090:                            newObj = null;
091:                    } else {
092:                        newContainer.add(conObj);
093:
094:                        if (conIt.hasNext())
095:                            conObj = conIt.next();
096:                        else
097:                            conObj = null;
098:                    }
099:                }
100:
101:                while (newObj != null
102:                        && (limit < 0 || newContainer.size() <= limit)) {
103:                    newContainer.add(newObj);
104:
105:                    if (newIt.hasNext())
106:                        newObj = newIt.next();
107:                    else
108:                        newObj = null;
109:                }
110:                while (conObj != null
111:                        && (limit < 0 || newContainer.size() <= limit)) {
112:                    newContainer.add(conObj);
113:
114:                    if (conIt.hasNext())
115:                        conObj = conIt.next();
116:                    else
117:                        conObj = null;
118:                }
119:
120:                //System.err.println("LuceneSearchQueryResult.merge: was: "+container.size()+" is: "+newContainer.size()+" limit: "+limit);
121:
122:                container = newContainer;
123:
124:                // make sure
125:                if (limit >= 0 && container.size() > limit)
126:                    container.setSize(limit);
127:            }
128:
129:            /**
130:             * Constructs an empty unorderred SearchQueryResult
131:             *
132:             */
133:            public LuceneSearchQueryResult() {
134:                this (null, null, -1);
135:            }
136:
137:            /**
138:             * Constructs an unordered SearchQueryResult
139:             *
140:             * @param result    the set containing the result items
141:             */
142:            public LuceneSearchQueryResult(Set result) {
143:                this (result, null, -1);
144:            }
145:
146:            /**
147:             * Constructs an empty orderred LuceneSearchQueryResult
148:             *
149:             */
150:            public LuceneSearchQueryResult(Comparator comparator) {
151:                this (null, comparator, -1);
152:            }
153:
154:            /**
155:             * Constructs an empty orderred LuceneSearchQueryResult
156:             *
157:             */
158:            public LuceneSearchQueryResult(Set result, Comparator comparator) {
159:                this (result, comparator, -1);
160:            }
161:
162:            /**
163:             * Constructs a LuceneSearchQueryResult
164:             *
165:             * @param result    the set containing the result items already sorted
166:             * @param comparator for ordering (for merging, only)
167:             */
168:            public LuceneSearchQueryResult(Set result, Comparator comparator,
169:                    int limit) {
170:                super ();
171:
172:                this .limit = limit;
173:                this .comparator = comparator;
174:
175:                if (result != null)
176:                    container.addAll(result);
177:
178:                if (limit >= 0 && container.size() > limit)
179:                    container.setSize(limit);
180:            }
181:
182:            /**
183:             * Method iterator
184:             *
185:             * @return   iterator for iterating the result, RequestedResource
186:             *
187:             */
188:            public Iterator iterator() {
189:                return container.iterator();
190:            }
191:
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.