Save This Page
Home » lucene-3.0.1-src » org.apache.lucene.queryParser.standard.config » [javadoc | source]
    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 java.util.LinkedHashMap;
   21   import java.util.Map;
   22   
   23   import org.apache.lucene.queryParser.core.config.FieldConfig;
   24   import org.apache.lucene.queryParser.standard.processors.MultiFieldQueryNodeProcessor;
   25   import org.apache.lucene.util.AttributeImpl;
   26   
   27   /**
   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/>
   32    * <br/>
   33    * 
   34    * @see org.apache.lucene.queryParser.standard.config.BoostAttribute
   35    */
   36   public class FieldBoostMapAttributeImpl extends AttributeImpl 
   37   				implements FieldBoostMapAttribute {
   38   
   39     private static final long serialVersionUID = -2104763012523049527L;
   40   
   41     private Map<CharSequence, Float> boosts = new LinkedHashMap<CharSequence, Float>();
   42     
   43   
   44     public FieldBoostMapAttributeImpl() {
   45       // empty constructor
   46     }
   47   
   48     public void setFieldBoostMap(Map<CharSequence, Float> boosts) {
   49       this.boosts = boosts;
   50     }
   51     
   52     public Map<CharSequence, Float> getFieldBoostMap() {
   53       return this.boosts;
   54     }
   55   
   56     @Override
   57     public void clear() {
   58       throw new UnsupportedOperationException();
   59     }
   60   
   61     @Override
   62     public void copyTo(AttributeImpl target) {
   63       throw new UnsupportedOperationException();
   64     }
   65   
   66     @Override
   67     public boolean equals(Object other) {
   68   
   69       if (other instanceof FieldBoostMapAttributeImpl && other != null
   70           && ((FieldBoostMapAttributeImpl) other).boosts.equals(this.boosts) ) {
   71   
   72         return true;
   73   
   74       }
   75   
   76       return false;
   77   
   78     }
   79   
   80     @Override
   81     public int hashCode() {
   82       final int prime = 97;
   83       if (this.boosts != null) 
   84         return this.boosts.hashCode() * prime;
   85       else 
   86         return Float.valueOf(prime).hashCode();
   87     }
   88   
   89     @Override
   90     public String toString() {
   91       return "<fieldBoostMapAttribute map=" + this.boosts + "/>";
   92     }
   93   
   94   }

Save This Page
Home » lucene-3.0.1-src » org.apache.lucene.queryParser.standard.config » [javadoc | source]