001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.search;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    
019    import java.io.Serializable;
020    
021    /**
022     * @author Bruno Farache
023     */
024    public class Sort implements Serializable {
025    
026            public static final int AUTO_TYPE = 2;
027    
028            public static final int CUSTOM_TYPE = 9;
029    
030            public static final int DOC_TYPE = 1;
031    
032            public static final int DOUBLE_TYPE = 7;
033    
034            public static final int FLOAT_TYPE = 5;
035    
036            public static final int INT_TYPE = 4;
037    
038            public static final int LONG_TYPE = 6;
039    
040            public static final int SCORE_TYPE = 0;
041    
042            public static final int STRING_TYPE = 3;
043    
044            public Sort() {
045            }
046    
047            public Sort(String fieldName, boolean reverse) {
048                    this(fieldName, AUTO_TYPE, reverse);
049            }
050    
051            public Sort(String fieldName, int type, boolean reverse) {
052                    _fieldName = fieldName;
053                    _type = type;
054                    _reverse = reverse;
055            }
056    
057            public String getFieldName() {
058                    return _fieldName;
059            }
060    
061            public int getType() {
062                    return _type;
063            }
064    
065            public boolean isReverse() {
066                    return _reverse;
067            }
068    
069            public void setFieldName(String fieldName) {
070                    _fieldName = fieldName;
071            }
072    
073            public void setReverse(boolean reverse) {
074                    _reverse = reverse;
075            }
076    
077            public void setType(int type) {
078                    _type = type;
079            }
080    
081            public String toString() {
082                    StringBundler sb = new StringBundler(7);
083    
084                    sb.append("{fieldName=");
085                    sb.append(_fieldName);
086                    sb.append(", type=");
087                    sb.append(_type);
088                    sb.append(", reverse=");
089                    sb.append(_reverse);
090                    sb.append("}");
091    
092                    return sb.toString();
093            }
094    
095            private String _fieldName;
096            private boolean _reverse;
097            private int _type;
098    
099    }