1 package org.jbpm.bytes; 2 3 import java.io.Serializable ; 4 import java.util.Arrays ; 5 import java.util.List ; 6 7 17 public class ByteArray implements Serializable { 18 19 private static final long serialVersionUID = 1L; 20 21 private long id = 0; 22 protected String name = null; 23 protected List byteBlocks = null; 24 25 public ByteArray() { 26 } 27 28 public ByteArray(byte[] bytes) { 29 this.byteBlocks = ByteBlockChopper.chopItUp(bytes); 30 } 31 32 public ByteArray(String name, byte[] bytes) { 33 this(bytes); 34 this.name = name; 35 } 36 37 public ByteArray(ByteArray other) { 38 this.byteBlocks = other.byteBlocks; 39 this.name = other.name; 40 } 41 42 public byte[] getBytes() { 43 return ByteBlockChopper.glueChopsBackTogether(byteBlocks); 44 } 45 46 public long getId() { 47 return id; 48 } 49 50 public boolean equals(Object o) { 51 if (o==null) return false; 52 if (! (o instanceof ByteArray)) return false; 53 ByteArray other = (ByteArray) o; 54 return Arrays.equals(ByteBlockChopper.glueChopsBackTogether(byteBlocks), ByteBlockChopper.glueChopsBackTogether(other.byteBlocks)); 55 } 56 57 public int hashCode() { 58 if (byteBlocks==null) return 0; 59 return byteBlocks.hashCode(); 60 } 61 } 62 | Popular Tags |