| 1 |
package org.apache.commons.jcs3.auxiliary.disk.indexed; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
import java.io.Serializable; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public class IndexedDiskElementDescriptor |
| 29 |
implements Serializable, Comparable<IndexedDiskElementDescriptor> |
| 30 |
{ |
| 31 |
|
| 32 |
private static final long serialVersionUID = -3029163572847659450L; |
| 33 |
|
| 34 |
|
| 35 |
long pos; |
| 36 |
|
| 37 |
|
| 38 |
int len; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
public IndexedDiskElementDescriptor( final long pos, final int len ) |
| 47 |
{ |
| 48 |
this.pos = pos; |
| 49 |
this.len = len; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
@Override |
| 56 |
public String toString() |
| 57 |
{ |
| 58 |
final StringBuilder buf = new StringBuilder(); |
| 59 |
buf.append( "[DED: " ); |
| 60 |
buf.append( " pos = " + pos ); |
| 61 |
buf.append( " len = " + len ); |
| 62 |
buf.append( "]" ); |
| 63 |
return buf.toString(); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
@Override |
| 70 |
public int hashCode() |
| 71 |
{ |
| 72 |
return Long.valueOf(this.pos).hashCode() ^ Integer.valueOf(len).hashCode(); |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
@Override |
| 79 |
public boolean equals(final Object o) |
| 80 |
{ |
| 81 |
if (o == null) |
| 82 |
{ |
| 83 |
return false; |
| 84 |
} |
| 85 |
if (o instanceof IndexedDiskElementDescriptor) |
| 86 |
{ |
| 87 |
final IndexedDiskElementDescriptor ided = (IndexedDiskElementDescriptor)o; |
| 88 |
return pos == ided.pos && len == ided.len; |
| 89 |
} |
| 90 |
|
| 91 |
return false; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
@Override |
| 101 |
public int compareTo( final IndexedDiskElementDescriptor o ) |
| 102 |
{ |
| 103 |
if ( o == null ) |
| 104 |
{ |
| 105 |
return 1; |
| 106 |
} |
| 107 |
|
| 108 |
int lenCompare = Integer.compare(len, o.len); |
| 109 |
if (lenCompare == 0) |
| 110 |
{ |
| 111 |
return Long.compare(o.pos, pos); |
| 112 |
} |
| 113 |
|
| 114 |
return lenCompare; |
| 115 |
} |
| 116 |
} |