01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.solr.request;
17:
18: import org.apache.solr.util.NamedList;
19: import org.apache.solr.core.SolrCore;
20:
21: import java.util.Map;
22: import java.util.HashMap;
23: import java.util.Iterator;
24:
25: // With the addition of SolrParams, this class isn't needed for much anymore... it's currently
26: // retained more for backward compatibility.
27:
28: /**
29: * @author yonik
30: * @version $Id: LocalSolrQueryRequest.java 486904 2006-12-14 00:15:45Z hossman $
31: */
32: public class LocalSolrQueryRequest extends SolrQueryRequestBase {
33: public final static Map emptyArgs = new HashMap(0, 1);
34:
35: protected static SolrParams makeParams(String query, String qtype,
36: int start, int limit, Map args) {
37: Map<String, String[]> map = new HashMap<String, String[]>();
38: for (Iterator iter = args.entrySet().iterator(); iter.hasNext();) {
39: Map.Entry e = (Map.Entry) iter.next();
40: String k = e.getKey().toString();
41: Object v = e.getValue();
42: if (v instanceof String[])
43: map.put(k, (String[]) v);
44: else
45: map.put(k, new String[] { v.toString() });
46: }
47: if (query != null)
48: map.put(SolrParams.Q, new String[] { query });
49: if (qtype != null)
50: map.put(SolrParams.QT, new String[] { qtype });
51: map.put(SolrParams.START, new String[] { Integer
52: .toString(start) });
53: map.put(SolrParams.ROWS,
54: new String[] { Integer.toString(limit) });
55: return new MultiMapSolrParams(map);
56: }
57:
58: public LocalSolrQueryRequest(SolrCore core, String query,
59: String qtype, int start, int limit, Map args) {
60: super (core, makeParams(query, qtype, start, limit, args));
61: }
62:
63: public LocalSolrQueryRequest(SolrCore core, NamedList args) {
64: super (core, SolrParams.toSolrParams(args));
65: }
66:
67: public LocalSolrQueryRequest(SolrCore core,
68: Map<String, String[]> args) {
69: super (core, new MultiMapSolrParams(args));
70: }
71:
72: public LocalSolrQueryRequest(SolrCore core, SolrParams args) {
73: super(core, args);
74: }
75:
76: }
|