1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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  /**
26   * <a href="Field.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Bruno Farache
29   * @author Brian Wing Shun Chan
30   * @author Allen Chiang
31   * @author Alex Wallace
32   *
33   */
34  public class Field {
35  
36      public static final String COMMENTS = "comments";
37  
38      public static final String COMPANY_ID = "companyId";
39  
40      public static final String CONTENT = "content";
41  
42      public static final String DESCRIPTION = "description";
43  
44      public static final String ENTRY_CLASS_NAME = "entryClassName";
45  
46      public static final String ENTRY_CLASS_PK = "entryClassPK";
47  
48      public static final String GROUP_ID = "groupId";
49  
50      public static final String MODIFIED = "modified";
51  
52      public static final String NAME = "name";
53  
54      public static final String PORTLET_ID = "portletId";
55  
56      public static final String PROPERTIES = "properties";
57  
58      public static final String ROLE_ID = "roleId";
59  
60      public static final String TAGS_CATEGORIES = "tagsCategories";
61  
62      public static final String TAGS_ENTRIES = "tagsEntries";
63  
64      public static final String TITLE = "title";
65  
66      public static final String TYPE = "type";
67  
68      public static final String UID = "uid";
69  
70      public static final String URL = "url";
71  
72      public static final String USER_ID = "userId";
73  
74      public static final String USER_NAME = "userName";
75  
76      public static final String VERSION = "version";
77  
78      public Field(String name, String value, boolean tokenized) {
79          this(name, new String[] {value}, tokenized);
80      }
81  
82      public Field(String name, String[] values, boolean tokenized) {
83          this(name, values, tokenized, 1);
84      }
85  
86      public Field(String name, String[] values, boolean tokenized, float boost) {
87          _name = name;
88          _values = values;
89          _tokenized = tokenized;
90          _boost = boost;
91      }
92  
93      public float getBoost() {
94          return _boost;
95      }
96  
97      public String getName() {
98          return _name;
99      }
100 
101     public String getValue() {
102         if ((_values != null) && (_values.length > 0)) {
103             return _values[0];
104         }
105         else {
106             return null;
107         }
108     }
109 
110     public String[] getValues() {
111         return _values;
112     }
113 
114     public boolean isTokenized() {
115         return _tokenized;
116     }
117 
118     public void setBoost(float boost) {
119         _boost = boost;
120     }
121 
122     public void setName(String name) {
123         _name = name;
124     }
125 
126     public void setTokenized(boolean type) {
127         _tokenized = type;
128     }
129 
130     public void setValue(String value) {
131         setValues(new String[] {value});
132     }
133 
134     public void setValues(String[] values) {
135         _values = values;
136     }
137 
138     private float _boost;
139     private String _name;
140     private boolean _tokenized;
141     private String[] _values;
142 
143 }