add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / queryparser / src / java / org / apache / lucene / queryParser / standard / config / MultiTermRewriteMethodAttributeImpl.java
1 package org.apache.lucene.queryParser.standard.config;
2
3 /**
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
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
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;
28
29 /**
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
33  * use. <br/>
34  * 
35  * @see MultiTermRewriteMethodAttribute
36  * 
37  * @deprecated
38  * 
39  */
40 @Deprecated
41 public class MultiTermRewriteMethodAttributeImpl extends AttributeImpl
42     implements MultiTermRewriteMethodAttribute, ConfigAttribute {
43
44   private static final long serialVersionUID = -2104763012723049527L;
45   
46   private AbstractQueryConfig config;
47   
48   { enableBackwards = false; }
49   
50   public MultiTermRewriteMethodAttributeImpl() {
51     // empty constructor
52   }
53
54   public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method) {
55    config.set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, method);
56   }
57
58   public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod() {
59     return config.get(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD);
60   }
61
62   @Override
63   public void clear() {
64     throw new UnsupportedOperationException();
65   }
66
67   @Override
68   public void copyTo(AttributeImpl target) {
69     throw new UnsupportedOperationException();
70   }
71
72   @Override
73   public boolean equals(Object other) {
74
75     if (other instanceof MultiTermRewriteMethodAttributeImpl
76         && ((MultiTermRewriteMethodAttributeImpl) other).getMultiTermRewriteMethod() == getMultiTermRewriteMethod()) {
77
78       return true;
79
80     }
81
82     return false;
83
84   }
85
86   @Override
87   public int hashCode() {
88     return getMultiTermRewriteMethod().hashCode();
89   }
90
91   @Override
92   public String toString() {
93     return "<multiTermRewriteMethod multiTermRewriteMethod="
94         + getMultiTermRewriteMethod() + "/>";
95   }
96   
97   public void setQueryConfigHandler(AbstractQueryConfig config) {
98     this.config = config;
99     
100     if (!config.has(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD)) {
101       config.set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
102     }
103     
104   }
105
106 }