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