示例#1
0
  public boolean equalsIgnoreCase(Buffer b) {
    if (b == this) {
      return true;
    }

    if (b.length() != length()) {
      return false;
    }
    if ((this._hash != 0) && (b instanceof AbstractBuffer)) {
      AbstractBuffer ab = (AbstractBuffer) b;
      if ((ab._hash != 0) && (this._hash != ab._hash)) {
        return false;
      }
    }

    int get = getIndex();
    int bi = b.putIndex();

    byte[] array = array();
    byte[] barray = b.array();
    int i;
    if ((array != null) && (barray != null)) {
      for (i = putIndex(); i-- > get; ) {
        byte b1 = array[i];
        bi--;
        byte b2 = barray[bi];
        if (b1 != b2) {
          if ((97 <= b1) && (b1 <= 122)) {
            b1 = (byte) (b1 - 97 + 65);
          }
          if ((97 <= b2) && (b2 <= 122)) {
            b2 = (byte) (b2 - 97 + 65);
          }
          if (b1 != b2) {
            return false;
          }
        }
      }
    } else {
      for (i = putIndex(); i-- > get; ) {
        byte b1 = peek(i);
        bi--;
        byte b2 = b.peek(bi);
        if (b1 != b2) {
          if ((97 <= b1) && (b1 <= 122)) {
            b1 = (byte) (b1 - 97 + 65);
          }

          if ((97 <= b2) && (b2 <= 122)) {
            b2 = (byte) (b2 - 97 + 65);
          }

          if (b1 != b2) {
            return false;
          }
        }
      }
    }
    return true;
  }
示例#2
0
  public int poke(int index, Buffer src) {
    this._hash = 0;

    int length = src.length();
    if (index + length > capacity()) {
      length = capacity() - index;
    }

    byte[] srcArray = src.array();
    byte[] dstArray = array();
    if ((srcArray != null) && (dstArray != null)) {
      System.arraycopy(srcArray, src.getIndex(), dstArray, index, length);
    } else if (srcArray != null) {
      int s = src.getIndex();
      for (int i = 0; i < length; i++) {
        poke(index++, srcArray[s++]);
      }
    } else if (dstArray != null) {
      int s = src.getIndex();
      for (int i = 0; i < length; i++) {
        dstArray[index++] = src.peek(s++);
      }
    } else {
      int s = src.getIndex();
      for (int i = 0; i < length; i++) {
        poke(index++, src.peek(s++));
      }
    }
    return length;
  }
示例#3
0
 private void newBuffer() {
   this.buffer = allocator.allocate(PageFormat.PAGE_HEADER_SIZE + fixedRecordSize);
   this.bufferSlice = Slices.wrappedBuffer(buffer.array(), buffer.offset(), buffer.capacity());
   this.count = 0;
   this.position = PageFormat.PAGE_HEADER_SIZE;
   this.stringReferences.clear();
   this.stringReferenceSize = 0;
 }