001    /**
002     * Copyright (c) 2000-2013 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 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            /**
027             * @deprecated As of 6.1.0
028             */
029            @Deprecated
030            public static final int AUTO_TYPE = 2;
031    
032            public static final int CUSTOM_TYPE = 9;
033    
034            public static final int DOC_TYPE = 1;
035    
036            public static final int DOUBLE_TYPE = 7;
037    
038            public static final int FLOAT_TYPE = 5;
039    
040            public static final int INT_TYPE = 4;
041    
042            public static final int LONG_TYPE = 6;
043    
044            public static final int SCORE_TYPE = 0;
045    
046            public static final int STRING_TYPE = 3;
047    
048            public Sort() {
049            }
050    
051            public Sort(String fieldName, boolean reverse) {
052                    this(fieldName, STRING_TYPE, reverse);
053            }
054    
055            public Sort(String fieldName, int type, boolean reverse) {
056                    _fieldName = fieldName;
057                    _type = type;
058                    _reverse = reverse;
059            }
060    
061            public String getFieldName() {
062                    return _fieldName;
063            }
064    
065            public int getType() {
066                    return _type;
067            }
068    
069            public boolean isReverse() {
070                    return _reverse;
071            }
072    
073            public void setFieldName(String fieldName) {
074                    _fieldName = fieldName;
075            }
076    
077            public void setReverse(boolean reverse) {
078                    _reverse = reverse;
079            }
080    
081            public void setType(int type) {
082                    _type = type;
083            }
084    
085            @Override
086            public String toString() {
087                    StringBundler sb = new StringBundler(7);
088    
089                    sb.append("{fieldName=");
090                    sb.append(_fieldName);
091                    sb.append(", type=");
092                    sb.append(_type);
093                    sb.append(", reverse=");
094                    sb.append(_reverse);
095                    sb.append("}");
096    
097                    return sb.toString();
098            }
099    
100            private String _fieldName;
101            private boolean _reverse;
102            private int _type;
103    
104    }