pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / queryparser / src / java / org / apache / lucene / queryParser / core / config / FieldConfig.java
1 package org.apache.lucene.queryParser.core.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.util.StringUtils;
21 import org.apache.lucene.util.AttributeSource;
22
23 /**
24  * This class represents a field configuration. Every configuration should be
25  * set using the methods inherited from {@link AttributeSource}.
26  * 
27  * @see QueryConfigHandler
28  * @see org.apache.lucene.util.Attribute
29  */
30 public class FieldConfig extends AbstractQueryConfig {
31
32   private String fieldName;
33
34   /**
35    * Constructs a {@link FieldConfig}
36    * 
37    * @param fieldName the field name, it cannot be null
38    * @throws IllegalArgumentException if the field name is null
39    * 
40    * @deprecated use {@link #FieldConfig(String)} instead
41    */
42   @Deprecated
43   public FieldConfig(CharSequence fieldName) {
44     this(StringUtils.toString(fieldName));
45   }
46
47   /**
48    * Constructs a {@link FieldConfig}
49    * 
50    * @param fieldName the field name, it cannot be null
51    * @throws IllegalArgumentException if the field name is null
52    */
53   public FieldConfig(String fieldName) {
54
55     if (fieldName == null) {
56       throw new IllegalArgumentException("field name should not be null!");
57     }
58
59     this.fieldName = fieldName;
60
61   }
62
63   /**
64    * Returns the field name this configuration represents.
65    * 
66    * @return the field name
67    * 
68    * @deprecated use {@link #getField()} instead
69    */
70   @Deprecated
71   public CharSequence getFieldName() {
72     return this.fieldName;
73   }
74
75   /**
76    * Returns the field name this configuration represents.
77    * 
78    * @return the field name
79    */
80   public String getField() {
81     return this.fieldName;
82   }
83
84   @Override
85   public String toString() {
86     return "<fieldconfig name=\"" + this.fieldName + "\" configurations=\""
87         + super.toString() + "\"/>";
88   }
89
90 }