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.AllowLeadingWildcardProcessor;
25 import org.apache.lucene.util.AttributeImpl;
28 * This attribute is used by {@link AllowLeadingWildcardProcessor} processor and
29 * must be defined in the {@link QueryConfigHandler}. It basically tells the
30 * processor if it should allow leading wildcard. <br/>
32 * @see org.apache.lucene.queryParser.standard.config.AllowLeadingWildcardAttribute
37 public class AllowLeadingWildcardAttributeImpl extends AttributeImpl
38 implements AllowLeadingWildcardAttribute, ConfigAttribute {
40 private static final long serialVersionUID = -2804763012723049527L;
42 private AbstractQueryConfig config;
44 { enableBackwards = false; }
46 public void setAllowLeadingWildcard(boolean allowLeadingWildcard) {
47 config.set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, allowLeadingWildcard);
50 public boolean isAllowLeadingWildcard() {
51 return config.get(ConfigurationKeys.ALLOW_LEADING_WILDCARD, false);
56 throw new UnsupportedOperationException();
60 public void copyTo(AttributeImpl target) {
61 throw new UnsupportedOperationException();
65 public boolean equals(Object other) {
67 if (other instanceof AllowLeadingWildcardAttributeImpl
68 && ((AllowLeadingWildcardAttributeImpl) other).isAllowLeadingWildcard() == isAllowLeadingWildcard()) {
79 public int hashCode() {
80 return isAllowLeadingWildcard() ? -1 : Integer.MAX_VALUE;
84 public String toString() {
85 return "<allowLeadingWildcard allowLeadingWildcard="
86 + isAllowLeadingWildcard() + "/>";
89 public void setQueryConfigHandler(AbstractQueryConfig config) {
92 if (!config.has(ConfigurationKeys.ALLOW_LEADING_WILDCARD)) {
93 config.set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, false); // default in 2.9