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_ENTRIES = "tagsEntries";
61  
62      public static final String TITLE = "title";
63  
64      public static final String TYPE = "type";
65  
66      public static final String UID = "uid";
67  
68      public static final String URL = "url";
69  
70      public static final String USER_ID = "userId";
71  
72      public static final String USER_NAME = "userName";
73  
74      public static final String VERSION = "version";
75  
76      public Field(String name, String value, boolean tokenized) {
77          this(name, new String[] {value}, tokenized);
78      }
79  
80      public Field(String name, String[] values, boolean tokenized) {
81          this(name, values, tokenized, 1);
82      }
83  
84      public Field(String name, String[] values, boolean tokenized, float boost) {
85          _name = name;
86          _values = values;
87          _tokenized = tokenized;
88          _boost = boost;
89      }
90  
91      public float getBoost() {
92          return _boost;
93      }
94  
95      public String getName() {
96          return _name;
97      }
98  
99      public String getValue() {
100         if ((_values != null) && (_values.length > 0)) {
101             return _values[0];
102         }
103         else {
104             return null;
105         }
106     }
107 
108     public String[] getValues() {
109         return _values;
110     }
111 
112     public boolean isTokenized() {
113         return _tokenized;
114     }
115 
116     public void setBoost(float boost) {
117         _boost = boost;
118     }
119 
120     public void setName(String name) {
121         _name = name;
122     }
123 
124     public void setTokenized(boolean type) {
125         _tokenized = type;
126     }
127 
128     public void setValue(String value) {
129         setValues(new String[] {value});
130     }
131 
132     public void setValues(String[] values) {
133         _values = values;
134     }
135 
136     private float _boost;
137     private String _name;
138     private boolean _tokenized;
139     private String[] _values;
140 
141 }