All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.solr.schema.FieldProperties Maven / Gradle / Ivy

The newest version!
/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.solr.schema;

import java.util.Map;
import java.util.HashMap;

/**
 * @version $Id: FieldProperties.java 777496 2009-05-22 12:29:02Z markrmiller $
 */
abstract class FieldProperties {

  // use a bitfield instead of many different boolean variables since
  // many of the variables are independent or semi-independent.

  // bit values for boolean field properties.
  final static int INDEXED             = 0x00000001;
  final static int TOKENIZED           = 0x00000002;
  final static int STORED              = 0x00000004;
  final static int BINARY              = 0x00000008;
  final static int COMPRESSED          = 0x00000010;
  final static int OMIT_NORMS          = 0x00000020;
  final static int OMIT_TF_POSITIONS   = 0x00000040;
  final static int STORE_TERMVECTORS   = 0x00000080;
  final static int STORE_TERMPOSITIONS = 0x00000100;
  final static int STORE_TERMOFFSETS   = 0x00000200;


  final static int MULTIVALUED         = 0x00000400;
  final static int SORT_MISSING_FIRST  = 0x00000800;
  final static int SORT_MISSING_LAST   = 0x00001000;
  
  final static int REQUIRED            = 0x00002000;
  
  static final String[] propertyNames = {
          "indexed", "tokenized", "stored",
          "binary", "compressed", "omitNorms", "omitTermFreqAndPositions",
          "termVectors", "termPositions", "termOffsets",
          "multiValued",
          "sortMissingFirst","sortMissingLast","required"
  };

  static final Map propertyMap = new HashMap();
  static {
    for (String prop : propertyNames) {
      propertyMap.put(prop, propertyNameToInt(prop));
    }
  }


  /** Returns the symbolic name for the property. */
  static String getPropertyName(int property) {
    return propertyNames[ Integer.numberOfTrailingZeros(property) ];
  }

  static int propertyNameToInt(String name) {
    for (int i=0; i properties, boolean which) {
    int props = 0;
    for (Map.Entry entry : properties.entrySet()) {
      String val = entry.getValue();
      if(val == null) continue;
      if (Boolean.parseBoolean(val) == which) {
        props |= propertyNameToInt(entry.getKey());
      }
    }
    return props;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy