1 package com.daffodilwoods.daffodildb.utils; 2 3 import com.daffodilwoods.database.resource.DException; 4 import java.text.Collator ; 5 6 public class BufferRange implements _DComparator { 7 8 private byte[] bufferBytes; 9 private int length; 10 private int offset; 11 private boolean isNull; 12 13 public BufferRange(boolean isNull0){ 14 isNull = isNull0; 15 } 16 17 public void setNull(boolean isNull0) { 18 isNull = isNull0; 19 } 20 21 public final boolean getNull() { 22 return isNull; 23 } 24 25 26 public BufferRange(byte[] bytes,int offset0,int length0) { 27 bufferBytes = bytes; 28 length = length0; 29 offset = offset0; 30 if(offset > bufferBytes.length) 31 new Exception (" OFFSET "+offset+" BYTES LENGTH "+bufferBytes.length + " LENGTH "+length).printStackTrace(); 32 } 33 34 public BufferRange(byte[] bytes) { 35 bufferBytes = bytes; 36 isNull = bufferBytes == null; 37 length = bytes == null ? 0 : bytes.length; 38 } 39 40 public final byte getByte(int index){ 41 return bufferBytes[offset+index]; 42 } 43 44 public int getLength() { 45 return length; 46 } 47 48 public byte[] getBytes(){ 49 if(offset == 0 && length == bufferBytes.length) 50 return bufferBytes; 51 byte[] result = new byte[length]; 52 System.arraycopy(bufferBytes,offset,result,0,length); 53 return result; 54 } 55 56 public byte[] getFulBytes(){ 57 return bufferBytes; 58 } 59 60 public int getOffSet(){ 61 return offset; 62 } 63 64 public void setOffSet(int offset0) { 65 offset = offset0; 66 } 67 68 public String toString(){ 69 return "NULL IS " + isNull; 70 } 71 } 72 | Popular Tags |