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 java.text.Collator;
22 import org.apache.lucene.queryParser.core.config.AbstractQueryConfig;
23 import org.apache.lucene.queryParser.core.config.ConfigAttribute;
24 import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
25 import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
26 import org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor;
27 import org.apache.lucene.search.TermRangeQuery;
28 import org.apache.lucene.util.AttributeImpl;
31 * This attribute is used by {@link ParametricRangeQueryNodeProcessor} processor
32 * and must be defined in the {@link QueryConfigHandler}. This attribute tells
33 * the processor which {@link Collator} should be used for a
34 * {@link TermRangeQuery} <br/>
36 * @see org.apache.lucene.queryParser.standard.config.RangeCollatorAttribute
42 public class RangeCollatorAttributeImpl extends AttributeImpl
43 implements RangeCollatorAttribute, ConfigAttribute {
45 private static final long serialVersionUID = -6804360312723049526L;
47 private AbstractQueryConfig config;
49 { enableBackwards = false; }
51 public RangeCollatorAttributeImpl() {}
53 public void setDateResolution(Collator rangeCollator) {
54 config.set(ConfigurationKeys.RANGE_COLLATOR, rangeCollator);
57 public Collator getRangeCollator() {
58 return config.get(ConfigurationKeys.RANGE_COLLATOR);
63 throw new UnsupportedOperationException();
67 public void copyTo(AttributeImpl target) {
68 throw new UnsupportedOperationException();
72 public boolean equals(Object other) {
74 if (other instanceof RangeCollatorAttributeImpl) {
75 RangeCollatorAttributeImpl rangeCollatorAttr = (RangeCollatorAttributeImpl) other;
77 Collator thisCollator = getRangeCollator();
78 Collator otherCollator = rangeCollatorAttr.getRangeCollator();
80 if (otherCollator == thisCollator
81 || otherCollator.equals(thisCollator)) {
94 public int hashCode() {
95 Collator collator = getRangeCollator();
96 return (collator == null) ? 0 : collator.hashCode();
100 public String toString() {
101 return "<rangeCollatorAttribute rangeCollator='" + getRangeCollator()
105 public void setQueryConfigHandler(AbstractQueryConfig config) {
106 this.config = config;