1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.kernel.search;
24  
25  import java.io.Serializable;
26  
27  /**
28   * <a href="Field.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Bruno Farache
31   * @author Brian Wing Shun Chan
32   * @author Allen Chiang
33   * @author Alex Wallace
34   */
35  public class Field implements Serializable {
36  
37      public static final String COMMENTS = "comments";
38  
39      public static final String COMPANY_ID = "companyId";
40  
41      public static final String CONTENT = "content";
42  
43      public static final String DESCRIPTION = "description";
44  
45      public static final String ENTRY_CLASS_NAME = "entryClassName";
46  
47      public static final String ENTRY_CLASS_PK = "entryClassPK";
48  
49      public static final String GROUP_ID = "groupId";
50  
51      public static final String MODIFIED = "modified";
52  
53      public static final String NAME = "name";
54  
55      public static final String PORTLET_ID = "portletId";
56  
57      public static final String PROPERTIES = "properties";
58  
59      public static final String TAGS_ENTRIES = "tagsEntries";
60  
61      public static final String TITLE = "title";
62  
63      public static final String TYPE = "type";
64  
65      public static final String UID = "uid";
66  
67      public static final String URL = "url";
68  
69      public static final String USER_ID = "userId";
70  
71      public static final String USER_NAME = "userName";
72  
73      public static final String VERSION = "version";
74  
75      public Field(String name, String value, boolean tokenized) {
76          this(name, new String[] {value}, tokenized);
77      }
78  
79      public Field(String name, String[] values, boolean tokenized) {
80          this(name, values, tokenized, 1);
81      }
82  
83      public Field(String name, String[] values, boolean tokenized, float boost) {
84          _name = name;
85          _values = values;
86          _tokenized = tokenized;
87          _boost = boost;
88      }
89  
90      public float getBoost() {
91          return _boost;
92      }
93  
94      public String getName() {
95          return _name;
96      }
97  
98      public String getValue() {
99          if ((_values != null) && (_values.length > 0)) {
100             return _values[0];
101         }
102         else {
103             return null;
104         }
105     }
106 
107     public String[] getValues() {
108         return _values;
109     }
110 
111     public boolean isTokenized() {
112         return _tokenized;
113     }
114 
115     public void setBoost(float boost) {
116         _boost = boost;
117     }
118 
119     public void setName(String name) {
120         _name = name;
121     }
122 
123     public void setTokenized(boolean type) {
124         _tokenized = type;
125     }
126 
127     public void setValue(String value) {
128         setValues(new String[] {value});
129     }
130 
131     public void setValues(String[] values) {
132         _values = values;
133     }
134 
135     private float _boost;
136     private String _name;
137     private boolean _tokenized;
138     private String[] _values;
139 
140 }