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.FieldConfig;
23 import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
24 import org.apache.lucene.queryParser.standard.processors.MultiFieldQueryNodeProcessor;
25 import org.apache.lucene.util.AttributeImpl;
28 * This attribute is used by {@link MultiFieldQueryNodeProcessor} processor and
29 * it should be defined in a {@link FieldConfig}. This processor uses this
30 * attribute to define which boost a specific field should have when none is
31 * defined to it. <br/>
34 * @see org.apache.lucene.queryParser.standard.config.BoostAttribute
40 public class BoostAttributeImpl extends AttributeImpl
41 implements BoostAttribute, ConfigAttribute {
43 private static final long serialVersionUID = -2104763012523049527L;
45 private AbstractQueryConfig config;
47 { enableBackwards = false; }
49 public BoostAttributeImpl() {
53 public void setBoost(float boost) {
54 config.set(ConfigurationKeys.BOOST, boost);
57 public float getBoost() {
58 return config.get(ConfigurationKeys.BOOST, 1.0f);
63 throw new UnsupportedOperationException();
67 public void copyTo(AttributeImpl target) {
68 throw new UnsupportedOperationException();
72 public boolean equals(Object other) {
74 if (other instanceof BoostAttributeImpl
75 && ((BoostAttributeImpl) other).getBoost() == getBoost()) {
86 public int hashCode() {
87 return Float.valueOf(getBoost()).hashCode();
91 public String toString() {
92 return "<boostAttribute boost=" + getBoost() + "/>";
95 public void setQueryConfigHandler(AbstractQueryConfig config) {
98 if (!config.has(ConfigurationKeys.BOOST)) {
99 config.set(ConfigurationKeys.BOOST, 1.0f);