1 package org.apache.lucene.queryParser.core.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 org.apache.lucene.queryParser.core.util.StringUtils;
21 import org.apache.lucene.util.AttributeSource;
24 * This class represents a field configuration. Every configuration should be
25 * set using the methods inherited from {@link AttributeSource}.
27 * @see QueryConfigHandler
28 * @see org.apache.lucene.util.Attribute
30 public class FieldConfig extends AbstractQueryConfig {
32 private String fieldName;
35 * Constructs a {@link FieldConfig}
37 * @param fieldName the field name, it cannot be null
38 * @throws IllegalArgumentException if the field name is null
40 * @deprecated use {@link #FieldConfig(String)} instead
43 public FieldConfig(CharSequence fieldName) {
44 this(StringUtils.toString(fieldName));
48 * Constructs a {@link FieldConfig}
50 * @param fieldName the field name, it cannot be null
51 * @throws IllegalArgumentException if the field name is null
53 public FieldConfig(String fieldName) {
55 if (fieldName == null) {
56 throw new IllegalArgumentException("field name should not be null!");
59 this.fieldName = fieldName;
64 * Returns the field name this configuration represents.
66 * @return the field name
68 * @deprecated use {@link #getField()} instead
71 public CharSequence getFieldName() {
72 return this.fieldName;
76 * Returns the field name this configuration represents.
78 * @return the field name
80 public String getField() {
81 return this.fieldName;
85 public String toString() {
86 return "<fieldconfig name=\"" + this.fieldName + "\" configurations=\""
87 + super.toString() + "\"/>";