1 26 27 28 package org.objectweb.jonathan.apis.resources; 29 30 import org.objectweb.jonathan.apis.kernel.JonathanException; 31 32 33 42 public class Chunk { 43 44 public byte[] data; 45 46 47 public int top; 48 49 50 public int offset; 51 52 53 public Chunk next; 54 55 62 public Chunk (byte[] data,int offset,int top) { 63 this.data = data; 64 this.offset = offset; 65 this.top = top; 66 } 67 68 77 public Chunk duplicate() throws JonathanException { 78 int len = top - offset; 79 byte[] ndata = new byte[len]; 80 System.arraycopy(data,offset,ndata,0,len); 81 return new Chunk(ndata,0,len); 82 } 83 84 96 public Chunk duplicate(int offset,int top) throws JonathanException { 97 int len = top - offset; 98 byte[] ndata = new byte[len]; 99 System.arraycopy(data,offset,ndata,0,len); 100 return new Chunk(ndata,0,len); 101 } 102 103 104 111 public void release() { 112 top = 0; 113 offset = 0; 114 next = null; 115 } 116 117 122 public String toString() { 123 return "Chunk[data: " + data + " offset: " + offset + " top: " + top + "]"; 124 } 125 } 126 127 | Popular Tags |