Source Code Cross Referenced for SolrQueryRequestBase.java in  » Search-Engine » apache-solr-1.2.0 » org » apache » solr » request » 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.request 
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.request;
017:
018:        import org.apache.solr.search.SolrIndexSearcher;
019:        import org.apache.solr.util.ContentStream;
020:        import org.apache.solr.util.RefCounted;
021:        import org.apache.solr.schema.IndexSchema;
022:        import org.apache.solr.core.SolrCore;
023:        import org.apache.solr.core.SolrException;
024:
025:        import java.util.Iterator;
026:        import java.util.Map;
027:        import java.util.HashMap;
028:
029:        /**
030:         * Base implementation of <code>SolrQueryRequest</code> that provides some
031:         * convenience methods for accessing parameters, and manages an IndexSearcher
032:         * reference.
033:         *
034:         * <p>
035:         * The <code>close()</code> method must be called on any instance of this
036:         * class once it is no longer in use.
037:         * </p>
038:         *
039:         *
040:         * @author yonik
041:         * @version $Id: SolrQueryRequestBase.java 542679 2007-05-29 22:28:21Z ryan $
042:         */
043:        public abstract class SolrQueryRequestBase implements  SolrQueryRequest {
044:            @Deprecated
045:            public static final String QUERY_NAME = "q";
046:            @Deprecated
047:            public static final String START_NAME = "start";
048:            @Deprecated
049:            public static final String ROWS_NAME = "rows";
050:            @Deprecated
051:            public static final String XSL_NAME = "xsl";
052:            @Deprecated
053:            public static final String QUERYTYPE_NAME = "qt";
054:
055:            protected final SolrCore core;
056:            protected final SolrParams origParams;
057:            protected SolrParams params;
058:            protected Map<Object, Object> context;
059:            protected Iterable<ContentStream> streams;
060:
061:            public SolrQueryRequestBase(SolrCore core, SolrParams params) {
062:                this .core = core;
063:                this .params = this .origParams = params;
064:            }
065:
066:            public Map<Object, Object> getContext() {
067:                // SolrQueryRequest as a whole isn't thread safe, and this isn't either.
068:                if (context == null)
069:                    context = new HashMap<Object, Object>();
070:                return context;
071:            }
072:
073:            public SolrParams getParams() {
074:                return params;
075:            }
076:
077:            public SolrParams getOriginalParams() {
078:                return origParams;
079:            }
080:
081:            public void setParams(SolrParams params) {
082:                this .params = params;
083:            }
084:
085:            public String getParam(String name) {
086:                return params.get(name);
087:            }
088:
089:            public String[] getParams(String name) {
090:                return params.getParams(name);
091:            }
092:
093:            /**
094:             * use getParams().required().getInt( name ) instead
095:             */
096:            @Deprecated
097:            public int getIntParam(String name) {
098:                String s = getParam(name);
099:                if (s == null) {
100:                    throw new SolrException(
101:                            SolrException.ErrorCode.SERVER_ERROR,
102:                            "Missing required parameter '" + name + "' from "
103:                                    + this );
104:                }
105:                return Integer.parseInt(s);
106:            }
107:
108:            /**
109:             * use getParams().required().getInt( name ) instead
110:             */
111:            @Deprecated
112:            public int getIntParam(String name, int defval) {
113:                String s = getParam(name);
114:                return s == null ? defval : Integer.parseInt(s);
115:            }
116:
117:            /**
118:             * use getParams().required().getParam( name ) instead
119:             */
120:            @Deprecated
121:            public String getStrParam(String name) {
122:                String s = getParam(name);
123:                if (s == null) {
124:                    throw new SolrException(
125:                            SolrException.ErrorCode.SERVER_ERROR,
126:                            "Missing required parameter '" + name + "' from "
127:                                    + this );
128:                }
129:                return s;
130:            }
131:
132:            /**
133:             * use getParams().required().getParam( name ) instead
134:             */
135:            @Deprecated
136:            public String getStrParam(String name, String defval) {
137:                String s = getParam(name);
138:                return s == null ? defval : s;
139:            }
140:
141:            @Deprecated
142:            public String getQueryString() {
143:                return params.get(SolrParams.Q);
144:            }
145:
146:            @Deprecated
147:            public String getQueryType() {
148:                return params.get(SolrParams.QT);
149:            }
150:
151:            // starting position in matches to return to client
152:            @Deprecated
153:            public int getStart() {
154:                return params.getInt(SolrParams.START, 0);
155:            }
156:
157:            // number of matching documents to return
158:            @Deprecated
159:            public int getLimit() {
160:                return params.getInt(SolrParams.ROWS, 10);
161:            }
162:
163:            protected final long startTime = System.currentTimeMillis();
164:
165:            // Get the start time of this request in milliseconds
166:            public long getStartTime() {
167:                return startTime;
168:            }
169:
170:            // The index searcher associated with this request
171:            protected RefCounted<SolrIndexSearcher> searcherHolder;
172:
173:            public SolrIndexSearcher getSearcher() {
174:                // should this reach out and get a searcher from the core singleton, or
175:                // should the core populate one in a factory method to create requests?
176:                // or there could be a setSearcher() method that Solr calls
177:
178:                if (searcherHolder == null) {
179:                    searcherHolder = core.getSearcher();
180:                }
181:
182:                return searcherHolder.get();
183:            }
184:
185:            // The solr core (coordinator, etc) associated with this request
186:            public SolrCore getCore() {
187:                return core;
188:            }
189:
190:            // The index schema associated with this request
191:            public IndexSchema getSchema() {
192:                return core.getSchema();
193:            }
194:
195:            /**
196:             * Frees resources associated with this request, this method <b>must</b>
197:             * be called when the object is no longer in use.
198:             */
199:            public void close() {
200:                if (searcherHolder != null) {
201:                    searcherHolder.decref();
202:                }
203:            }
204:
205:            /** A Collection of ContentStreams passed to the request
206:             */
207:            public Iterable<ContentStream> getContentStreams() {
208:                return streams;
209:            }
210:
211:            public void setContentStreams(Iterable<ContentStream> s) {
212:                streams = s;
213:            }
214:
215:            public String getParamString() {
216:                return origParams.toString();
217:            }
218:
219:            public String toString() {
220:                return this .getClass().getSimpleName() + '{' + params + '}';
221:            }
222:
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.