1 package org.apache.lucene.queryParser.standard.config;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import org.apache.lucene.queryParser.core.config.AbstractQueryConfig;
21 import org.apache.lucene.queryParser.core.config.ConfigAttribute;
22 import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
23 import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
24 import org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor;
25 import org.apache.lucene.search.MultiTermQuery;
26 import org.apache.lucene.search.MultiTermQuery.RewriteMethod;
27 import org.apache.lucene.util.AttributeImpl;
30 * This attribute is used by {@link ParametricRangeQueryNodeProcessor} processor
31 * and should be defined in the {@link QueryConfigHandler} used by this
32 * processor. It basically tells the processor which {@link RewriteMethod} to
35 * @see MultiTermRewriteMethodAttribute
41 public class MultiTermRewriteMethodAttributeImpl extends AttributeImpl
42 implements MultiTermRewriteMethodAttribute, ConfigAttribute {
44 private static final long serialVersionUID = -2104763012723049527L;
46 private AbstractQueryConfig config;
48 { enableBackwards = false; }
50 public MultiTermRewriteMethodAttributeImpl() {
54 public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method) {
55 config.set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, method);
58 public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod() {
59 return config.get(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD);
64 throw new UnsupportedOperationException();
68 public void copyTo(AttributeImpl target) {
69 throw new UnsupportedOperationException();
73 public boolean equals(Object other) {
75 if (other instanceof MultiTermRewriteMethodAttributeImpl
76 && ((MultiTermRewriteMethodAttributeImpl) other).getMultiTermRewriteMethod() == getMultiTermRewriteMethod()) {
87 public int hashCode() {
88 return getMultiTermRewriteMethod().hashCode();
92 public String toString() {
93 return "<multiTermRewriteMethod multiTermRewriteMethod="
94 + getMultiTermRewriteMethod() + "/>";
97 public void setQueryConfigHandler(AbstractQueryConfig config) {
100 if (!config.has(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD)) {
101 config.set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);