1 package org.jgroups.util; 2 3 8 public class Buffer { 9 byte[] buf; 10 int offset; 11 int length; 12 13 public Buffer(byte[] buf, int offset, int length) { 14 this.buf=buf; 15 this.offset=offset; 16 this.length=length; 17 } 18 19 public byte[] getBuf() { 20 return buf; 21 } 22 23 public void setBuf(byte[] buf) { 24 this.buf=buf; 25 } 26 27 public int getOffset() { 28 return offset; 29 } 30 31 public void setOffset(int offset) { 32 this.offset=offset; 33 } 34 35 public int getLength() { 36 return length; 37 } 38 39 public void setLength(int length) { 40 this.length=length; 41 } 42 43 public String toString() { 44 StringBuffer sb=new StringBuffer (); 45 sb.append(buf != null? buf.length : '0').append(" bytes"); 46 if(offset > 0) 47 sb.append("offset=").append(offset).append(", len=").append(length).append(")"); 48 return sb.toString(); 49 } 50 } 51 | Popular Tags |