1 17 18 package net.sourceforge.groboutils.codecoverage.v2.ant.zip; 19 20 27 public final class ZipShort implements Cloneable { 28 29 private int value; 30 31 36 public ZipShort (int value) { 37 this.value = value; 38 } 39 40 45 public ZipShort (byte[] bytes) { 46 this(bytes, 0); 47 } 48 49 54 public ZipShort (byte[] bytes, int offset) { 55 value = (bytes[offset + 1] << 8) & 0xFF00; 56 value += (bytes[offset] & 0xFF); 57 } 58 59 64 public byte[] getBytes() { 65 byte[] result = new byte[2]; 66 result[0] = (byte) (value & 0xFF); 67 result[1] = (byte) ((value & 0xFF00) >> 8); 68 return result; 69 } 70 71 76 public int getValue() { 77 return value; 78 } 79 80 85 public boolean equals(Object o) { 86 if (o == null || !(o instanceof ZipShort)) { 87 return false; 88 } 89 return value == ((ZipShort) o).getValue(); 90 } 91 92 97 public int hashCode() { 98 return value; 99 } 100 } 101 | Popular Tags |