Exemplo n.º 1
0
  @Override
  public void copy(DataInputView in, DataOutputView target) throws IOException {
    int len = in.readUnsignedByte();
    target.writeByte(len);

    if (len >= HIGH_BIT) {
      int shift = 7;
      int curr;
      len = len & 0x7f;
      while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
        len |= (curr & 0x7f) << shift;
        shift += 7;
        target.writeByte(curr);
      }
      len |= curr << shift;
      target.writeByte(curr);
    }

    for (int i = 0; i < len; i++) {
      int c = in.readUnsignedByte();
      target.writeByte(c);
      while (c >= HIGH_BIT) {
        c = in.readUnsignedByte();
        target.writeByte(c);
      }
    }
  }
Exemplo n.º 2
0
  @Override
  public void read(final DataInputView in) throws IOException {
    int len = in.readUnsignedByte();

    if (len >= HIGH_BIT) {
      int shift = 7;
      int curr;
      len = len & 0x7f;
      while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
        len |= (curr & 0x7f) << shift;
        shift += 7;
      }
      len |= curr << shift;
    }

    this.len = len;
    this.hashCode = 0;
    ensureSize(len);
    final char[] data = this.value;

    for (int i = 0; i < len; i++) {
      int c = in.readUnsignedByte();
      if (c < HIGH_BIT) {
        data[i] = (char) c;
      } else {
        int shift = 7;
        int curr;
        c = c & 0x7f;
        while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
          c |= (curr & 0x7f) << shift;
          shift += 7;
        }
        c |= curr << shift;
        data[i] = (char) c;
      }
    }
  }