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 org.apache.lucene.queryParser.core.config.QueryConfigHandler;
   21   import org.apache.lucene.queryParser.standard.processors.AnalyzerQueryNodeProcessor;
   22   import org.apache.lucene.util.AttributeImpl;
   23   
   24   /**
   25    * This attribute is used by {@link AnalyzerQueryNodeProcessor} processor and
   26    * must be defined in the {@link QueryConfigHandler}. This attribute tells the
   27    * processor if the position increment is enabled. <br/>
   28    * 
   29    * @see org.apache.lucene.queryParser.standard.config.PositionIncrementsAttribute
   30    */
   31   public class PositionIncrementsAttributeImpl extends AttributeImpl
   32   				implements PositionIncrementsAttribute {
   33   
   34     private static final long serialVersionUID = -2804763012793049527L;
   35   
   36     private boolean positionIncrementsEnabled = false;
   37   
   38     public PositionIncrementsAttributeImpl() {
   39   	  positionIncrementsEnabled = false; //default in 2.4
   40     }
   41   
   42     public void setPositionIncrementsEnabled(boolean positionIncrementsEnabled) {
   43       this.positionIncrementsEnabled = positionIncrementsEnabled;
   44     }
   45   
   46     public boolean isPositionIncrementsEnabled() {
   47       return this.positionIncrementsEnabled;
   48     }
   49   
   50     @Override
   51     public void clear() {
   52       throw new UnsupportedOperationException();
   53     }
   54   
   55     @Override
   56     public void copyTo(AttributeImpl target) {
   57       throw new UnsupportedOperationException();
   58     }
   59   
   60     @Override
   61     public boolean equals(Object other) {
   62   
   63       if (other instanceof PositionIncrementsAttributeImpl
   64           && other != null
   65           && ((PositionIncrementsAttributeImpl) other).positionIncrementsEnabled == this.positionIncrementsEnabled) {
   66   
   67         return true;
   68   
   69       }
   70   
   71       return false;
   72   
   73     }
   74   
   75     @Override
   76     public int hashCode() {
   77       return this.positionIncrementsEnabled ? -1 : Integer.MAX_VALUE;
   78     }
   79   
   80     @Override
   81     public String toString() {
   82       return "<positionIncrements positionIncrementsEnabled="
   83           + this.positionIncrementsEnabled + "/>";
   84     }
   85   
   86   }

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