Index: contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/AbstractQueryConfig.java =================================================================== --- contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/AbstractQueryConfig.java (revision 0) +++ contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/AbstractQueryConfig.java (revision 0) @@ -0,0 +1,167 @@ +package org.apache.lucene.queryParser.core.config; + +/** + * 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. + */ + +import java.util.HashMap; + +import org.apache.lucene.util.Attribute; +import org.apache.lucene.util.AttributeSource; + +/** + *
+ * This class is the base of {@link QueryConfigHandler} and {@link FieldConfig}. + * It has operations to set, unset and get configuration values. + *
+ *+ * Each configuration is is a key->value pair. The key should be an unique + * {@link ConfigurationKey} instance and it also holds the value's type. + *
+ * + * NOTE: in future this class will no longer extend {@link AttributeSource} + * + * @see ConfigurationKey + */ +public abstract class AbstractQueryConfig extends AttributeSource { + + final private HashMapnull
+ *
+ * @return the value held by the given key
+ */
+ @SuppressWarnings("unchecked")
+ public null
+ * @param defaultValue the default value
+ *
+ * @return the value held by the given key or the default value
+ */
+ @SuppressWarnings("unchecked")
+ public null
+ * @return true if there is a value set with the given key, otherwise false
+ */
+ public null
+ * @param value
+ */
+ public -The package org.apache.lucene.queryParser.config contains query configuration handler +The package org.apache.lucene.queryParser.core.config contains query configuration handler abstract class that all config handlers should extend.
@@ -33,18 +33,33 @@ implementation.
-{@link org.apache.lucene.queryParser.core.config.FieldConfig} and {@link org.apache.lucene.queryParser.core.config.QueryConfigHandler} - should use {@link org.apache.lucene.util.Attribute} to store all attributes -required by the config implementation. See org.apache.lucene.queryParser.standard.config.*Attribute -for reference implementation. -
--The {@link org.apache.lucene.queryParser.core.config.QueryConfigHandler}, {@link org.apache.lucene.queryParser.core.config.FieldConfig}, - and {@link org.apache.lucene.util.Attribute}s are used in the processors to access config +The {@link org.apache.lucene.queryParser.core.config.QueryConfigHandler} and {@link org.apache.lucene.queryParser.core.config.FieldConfig} are used in the processors to access config information in a flexible and independent way. See {@link org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor} for a reference implementation.
++Since version 3.4, the configuration API has changed. It no longer uses {@link org.apache.lucene.util.Attribute} objects to configure +a query parser. Instead, it uses {@link org.apache.lucene.queryParser.core.config.ConfigurationKey} objects to set any configuration +to a {@link org.apache.lucene.queryParser.core.config.QueryConfigHandler}. For now, both configuration APIs are working, however, +they cannot be used at the same time. So if you start moving your code to the new API, move it completely or keep using the old API. +
++Here is an example about how the new configuration API works: +
+
+
+...
+// this constant will be the key to get and set your configuration. This should be unique in your application.
+final public static {@link org.apache.lucene.queryParser.core.config.ConfigurationKey}<{@link java.text.NumberFormat}> MY_CONFIG = {@link org.apache.lucene.queryParser.core.config.ConfigurationKey}.newInstance();
+...
+// make sure to use your unique key instance to set and get your configuration
+queryConfigHandler.set(MY_CONFIG, {@link java.text.NumberFormat}.getInstance());
+{@link java.text.NumberFormat} numberFormat = queryConfigHandler.get(MY_CONFIG);
+...
+
+
+