예제 #1
0
  @Override
  public void fromBytes(ByteBuf buf) {
    posX = buf.readInt();
    posY = buf.readInt();
    posZ = buf.readInt();
    int size = buf.readInt();

    data = new ArrayList(size);
    for (int i = 0; i < size; i++) {
      byte tag = buf.readByte();
      if (tag == 0x00) {
        data.add(buf.readChar());
      } else if (tag == 0x01) {
        data.add(readString(buf));
      } else if (tag == 0x02) {
        data.add(buf.readFloat());
      } else if (tag == 0x03) {
        data.add(buf.readDouble());
      } else if (tag == 0x04) {
        data.add(buf.readByte());
      } else if (tag == 0x05) {
        data.add(buf.readLong());
      } else {
        data.add(buf.readInt());
      }
    }
  }
 public String getString() {
   int length = this.getInt();
   char[] ret = new char[length];
   for (int i = 0; i < length; i++) {
     ret[i] = data.readChar();
   }
   return new String(ret);
 }
  public String[] getStringArray() {
    int lengthString = this.getInt();
    String[] retString = new String[lengthString];

    for (int i = 0; i < lengthString; i++) {

      int length = this.getInt();
      char[] ret = new char[length];
      for (int j = 0; j < length; j++) {
        ret[j] = data.readChar();
      }

      retString[i] = new String(ret);
    }
    return retString;
  }
예제 #4
0
 @Override
 public char readChar() {
   return buffer.readChar();
 }
예제 #5
0
 @Override
 public double readDouble() {
   return buffer.readChar();
 }
 @Override
 public char readChar() {
   return a.readChar();
 }