| 1 | /** |
| 2 | * Copyright (C) 2006 NetMind Consulting Bt. |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 3 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | |
| 19 | package hu.netmind.beankeeper.parser; |
| 20 | |
| 21 | /** |
| 22 | * Represent an order by requirement of a select statement. |
| 23 | * @author Brautigam Robert |
| 24 | * @version Revision: $Revision$ |
| 25 | */ |
| 26 | public class OrderBy |
| 27 | { |
| 28 | public static int ASCENDING = 1; |
| 29 | public static int DESCENDING = 2; |
| 30 | |
| 31 | private ReferenceTerm reference; |
| 32 | private int direction; |
| 33 | |
| 34 | public OrderBy() |
| 35 | { |
| 36 | direction = ASCENDING; |
| 37 | } |
| 38 | |
| 39 | public OrderBy(ReferenceTerm reference, int direction) |
| 40 | { |
| 41 | setReferenceTerm(reference); |
| 42 | setDirection(direction); |
| 43 | } |
| 44 | |
| 45 | public ReferenceTerm getReferenceTerm() |
| 46 | { |
| 47 | return reference; |
| 48 | } |
| 49 | public void setReferenceTerm(ReferenceTerm reference) |
| 50 | { |
| 51 | this.reference=reference; |
| 52 | } |
| 53 | |
| 54 | public int getDirection() |
| 55 | { |
| 56 | return direction; |
| 57 | } |
| 58 | public void setDirection(int direction) |
| 59 | { |
| 60 | this.direction=direction; |
| 61 | } |
| 62 | |
| 63 | public String toString() |
| 64 | { |
| 65 | return "[OrderBy: "+reference.toString()+", "+direction+"]"; |
| 66 | } |
| 67 | |
| 68 | public int hashCode() |
| 69 | { |
| 70 | return (getReferenceTerm().getName()+"."+getReferenceTerm().getColumnName()).hashCode(); |
| 71 | } |
| 72 | |
| 73 | public boolean equals(Object o) |
| 74 | { |
| 75 | if ( ! (o instanceof OrderBy) ) |
| 76 | return false; |
| 77 | OrderBy orderBy = (OrderBy) o; |
| 78 | return (getReferenceTerm().getName().equals(orderBy.getReferenceTerm().getName())) && |
| 79 | (getReferenceTerm().getColumnName().equals(orderBy.getReferenceTerm().getColumnName())); |
| 80 | |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | |