1 18 19 package org.apache.activemq.util; 20 21 public class ByteSequence { 22 23 public byte[] data; 24 public int offset; 25 public int length; 26 27 public ByteSequence(byte data[]) { 28 this.data = data; 29 this.offset = 0; 30 this.length = data.length; 31 } 32 33 public ByteSequence(byte data[], int offset, int length) { 34 this.data = data; 35 this.offset = offset; 36 this.length = length; 37 } 38 39 public byte[] getData() { 40 return data; 41 } 42 public int getLength() { 43 return length; 44 } 45 public int getOffset() { 46 return offset; 47 } 48 public void setData(byte[] data) { 49 this.data = data; 50 } 51 public void setLength(int length) { 52 this.length = length; 53 } 54 public void setOffset(int offset) { 55 this.offset = offset; 56 } 57 58 public void compact() { 59 if( length != data.length ) { 60 byte t[] = new byte[length]; 61 System.arraycopy(data, offset, t, 0, length); 62 data=t; 63 offset=0; 64 } 65 } 66 67 } 68 | Popular Tags |