001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.search;
016    
017    import java.io.Serializable;
018    
019    /**
020     * @author Bruno Farache
021     * @author Brian Wing Shun Chan
022     * @author Allen Chiang
023     * @author Alex Wallace
024     */
025    public class Field implements Serializable {
026    
027            public static final String ASSET_CATEGORY_IDS = "assetCategoryIds";
028    
029            public static final String ASSET_TAG_NAMES = "assetTagNames";
030    
031            public static final String CATEGORY_ID = "categoryId";
032    
033            public static final String COMMENTS = "comments";
034    
035            public static final String COMPANY_ID = "companyId";
036    
037            public static final String CONTENT = "content";
038    
039            public static final String DESCRIPTION = "description";
040    
041            public static final String ENTRY_CLASS_NAME = "entryClassName";
042    
043            public static final String ENTRY_CLASS_PK = "entryClassPK";
044    
045            public static final String FOLDER_ID = "folderId";
046    
047            public static final String GROUP_ID = "groupId";
048    
049            public static final String GROUP_ROLE_ID = "groupRoleId";
050    
051            public static final String MODIFIED = "modified";
052    
053            public static final String NAME = "name";
054    
055            public static final String NODE_ID = "nodeId";
056    
057            public static final String ORGANIZATION_ID = "organzationId";
058    
059            public static final String PORTLET_ID = "portletId";
060    
061            public static final String PROPERTIES = "properties";
062    
063            public static final String ROLE_ID = "roleId";
064    
065            public static final String ROOT_ENTRY_CLASS_PK = "rootEntryClassPK";
066    
067            public static final String SCOPE_GROUP_ID = "scopeGroupId";
068    
069            public static final String TITLE = "title";
070    
071            public static final String TYPE = "type";
072    
073            public static final String UID = "uid";
074    
075            public static final String URL = "url";
076    
077            public static final String USER_ID = "userId";
078    
079            public static final String USER_NAME = "userName";
080    
081            public static final String VERSION = "version";
082    
083            public Field(String name, String value, boolean tokenized) {
084                    this(name, new String[] {value}, tokenized);
085            }
086    
087            public Field(String name, String[] values, boolean tokenized) {
088                    this(name, values, tokenized, 1);
089            }
090    
091            public Field(String name, String[] values, boolean tokenized, float boost) {
092                    _name = name;
093                    _values = values;
094                    _tokenized = tokenized;
095                    _boost = boost;
096            }
097    
098            public float getBoost() {
099                    return _boost;
100            }
101    
102            public String getName() {
103                    return _name;
104            }
105    
106            public String getValue() {
107                    if ((_values != null) && (_values.length > 0)) {
108                            return _values[0];
109                    }
110                    else {
111                            return null;
112                    }
113            }
114    
115            public String[] getValues() {
116                    return _values;
117            }
118    
119            public boolean isTokenized() {
120                    return _tokenized;
121            }
122    
123            public void setBoost(float boost) {
124                    _boost = boost;
125            }
126    
127            public void setName(String name) {
128                    _name = name;
129            }
130    
131            public void setTokenized(boolean type) {
132                    _tokenized = type;
133            }
134    
135            public void setValue(String value) {
136                    setValues(new String[] {value});
137            }
138    
139            public void setValues(String[] values) {
140                    _values = values;
141            }
142    
143            private float _boost;
144            private String _name;
145            private boolean _tokenized;
146            private String[] _values;
147    
148    }