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: /**
19: * SolrParams wrapper which acts similar to DefaultSolrParams except that
20: * it "appends" the values of multi-value params from both sub instances, so
21: * that all of the values are returned.
22: */
23: public class AppendedSolrParams extends DefaultSolrParams {
24: public AppendedSolrParams(SolrParams main, SolrParams extra) {
25: super (main, extra);
26: }
27:
28: public String[] getParams(String param) {
29: String[] main = params.getParams(param);
30: String[] extra = defaults.getParams(param);
31: if (null == extra || 0 == extra.length) {
32: return main;
33: }
34: if (null == main || 0 == main.length) {
35: return extra;
36: }
37: String[] result = new String[main.length + extra.length];
38: System.arraycopy(main, 0, result, 0, main.length);
39: System.arraycopy(extra, 0, result, main.length, extra.length);
40: return result;
41: }
42:
43: public String toString() {
44: return "{main(" + params + "),extra(" + defaults + ")}";
45: }
46: }
|