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 PORTLET_ID = "portletId";
058    
059            public static final String PROPERTIES = "properties";
060    
061            public static final String ROLE_ID = "roleId";
062    
063            public static final String ROOT_ENTRY_CLASS_PK = "rootEntryClassPK";
064    
065            public static final String SCOPE_GROUP_ID = "scopeGroupId";
066    
067            public static final String TITLE = "title";
068    
069            public static final String TYPE = "type";
070    
071            public static final String UID = "uid";
072    
073            public static final String URL = "url";
074    
075            public static final String USER_ID = "userId";
076    
077            public static final String USER_NAME = "userName";
078    
079            public static final String VERSION = "version";
080    
081            public Field(String name, String value, boolean tokenized) {
082                    this(name, new String[] {value}, tokenized);
083            }
084    
085            public Field(String name, String[] values, boolean tokenized) {
086                    this(name, values, tokenized, 1);
087            }
088    
089            public Field(String name, String[] values, boolean tokenized, float boost) {
090                    _name = name;
091                    _values = values;
092                    _tokenized = tokenized;
093                    _boost = boost;
094            }
095    
096            public float getBoost() {
097                    return _boost;
098            }
099    
100            public String getName() {
101                    return _name;
102            }
103    
104            public String getValue() {
105                    if ((_values != null) && (_values.length > 0)) {
106                            return _values[0];
107                    }
108                    else {
109                            return null;
110                    }
111            }
112    
113            public String[] getValues() {
114                    return _values;
115            }
116    
117            public boolean isTokenized() {
118                    return _tokenized;
119            }
120    
121            public void setBoost(float boost) {
122                    _boost = boost;
123            }
124    
125            public void setName(String name) {
126                    _name = name;
127            }
128    
129            public void setTokenized(boolean type) {
130                    _tokenized = type;
131            }
132    
133            public void setValue(String value) {
134                    setValues(new String[] {value});
135            }
136    
137            public void setValues(String[] values) {
138                    _values = values;
139            }
140    
141            private float _boost;
142            private String _name;
143            private boolean _tokenized;
144            private String[] _values;
145    
146    }