| 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.db; |
| 20 | |
| 21 | /** |
| 22 | * A simple object which holds limits to a selection. |
| 23 | * Offset means the index of first row returned after applying the |
| 24 | * conditions and ordering. Limit means to return at most the given amount |
| 25 | * of rows. A limit of 0 means no limit. |
| 26 | * @author Brautigam Robert |
| 27 | * @version Revision: $Revision$ |
| 28 | */ |
| 29 | public class Limits |
| 30 | { |
| 31 | private long offset; |
| 32 | private long limit; |
| 33 | private long size; |
| 34 | |
| 35 | public Limits(int offset,int limit, int size) |
| 36 | { |
| 37 | setOffset(offset); |
| 38 | setLimit(limit); |
| 39 | setSize(size); |
| 40 | } |
| 41 | |
| 42 | public long getOffset() |
| 43 | { |
| 44 | return offset; |
| 45 | } |
| 46 | public void setOffset(long offset) |
| 47 | { |
| 48 | this.offset=offset; |
| 49 | } |
| 50 | |
| 51 | public long getLimit() |
| 52 | { |
| 53 | return limit; |
| 54 | } |
| 55 | public void setLimit(long limit) |
| 56 | { |
| 57 | this.limit=limit; |
| 58 | } |
| 59 | |
| 60 | public boolean isEmpty() |
| 61 | { |
| 62 | return (limit<=0); |
| 63 | } |
| 64 | |
| 65 | public long getSize() |
| 66 | { |
| 67 | return size; |
| 68 | } |
| 69 | public void setSize(long size) |
| 70 | { |
| 71 | this.size=size; |
| 72 | } |
| 73 | |
| 74 | public String toString() |
| 75 | { |
| 76 | return "[Limit: "+offset+"-"+limit+"]"; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | |