001    /**
002     * Copyright (c) 2000-2011 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            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    }