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