001    /**
002     * Copyright (c) 2000-2012 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.servlet;
016    
017    /**
018     * @author Juan González
019     */
020    public class Range {
021    
022            public Range(long start, long end, long total) {
023                    _start = start;
024                    _end = end;
025                    _length = end - start + 1;
026                    _total = total;
027            }
028    
029            @Override
030            public boolean equals(Object obj) {
031                    if (this == obj) {
032                            return true;
033                    }
034    
035                    if ((obj == null) || !(obj instanceof Range)) {
036                            return false;
037                    }
038    
039                    Range range = (Range)obj;
040    
041                    if ((_end == range._end) && (_length == range._length) &&
042                            (_start == range._start) && (_total == range._total)) {
043    
044                            return true;
045                    }
046    
047                    return false;
048            }
049    
050            public long getEnd() {
051                    return _end;
052            }
053    
054            public long getLength() {
055                    return _length;
056            }
057    
058            public long getStart() {
059                    return _start;
060            }
061    
062            public long getTotal() {
063                    return _total;
064            }
065    
066            @Override
067            public int hashCode() {
068                    int result = 1;
069    
070                    result = _PRIME * result + (int) (_end ^ (_end >>> 32));
071                    result = _PRIME * result + (int) (_length ^ (_length >>> 32));
072                    result = _PRIME * result + (int) (_start ^ (_start >>> 32));
073                    result = _PRIME * result + (int) (_total ^ (_total >>> 32));
074    
075                    return result;
076            }
077    
078            public void setEnd(long end) {
079                    _end = end;
080            }
081    
082            public void setLength(long length) {
083                    _length = length;
084            }
085    
086            public void setStart(long start) {
087                    _start = start;
088            }
089    
090            public void setTotal(long total) {
091                    _total = total;
092            }
093    
094            private static final int _PRIME = 31;
095    
096            private long _end;
097            private long _length;
098            private long _start;
099            private long _total;
100    
101    }