1 17 18 package net.sourceforge.groboutils.codecoverage.v2.ant.zip; 19 20 27 public final class ZipLong implements Cloneable { 28 29 private long value; 30 31 36 public ZipLong(long value) { 37 this.value = value; 38 } 39 40 45 public ZipLong (byte[] bytes) { 46 this(bytes, 0); 47 } 48 49 54 public ZipLong (byte[] bytes, int offset) { 55 value = (bytes[offset + 3] << 24) & 0xFF000000L; 56 value += (bytes[offset + 2] << 16) & 0xFF0000; 57 value += (bytes[offset + 1] << 8) & 0xFF00; 58 value += (bytes[offset] & 0xFF); 59 } 60 61 66 public byte[] getBytes() { 67 byte[] result = new byte[4]; 68 result[0] = (byte) ((value & 0xFF)); 69 result[1] = (byte) ((value & 0xFF00) >> 8); 70 result[2] = (byte) ((value & 0xFF0000) >> 16); 71 result[3] = (byte) ((value & 0xFF000000l) >> 24); 72 return result; 73 } 74 75 80 public long getValue() { 81 return value; 82 } 83 84 89 public boolean equals(Object o) { 90 if (o == null || !(o instanceof ZipLong)) { 91 return false; 92 } 93 return value == ((ZipLong) o).getValue(); 94 } 95 96 101 public int hashCode() { 102 return (int) value; 103 } 104 } 105 | Popular Tags |