Exemplo n.º 1
0
        protected void transfer(Pipe pipe, Input input, Output output) throws IOException {
          for (int number = input.readFieldNumber(wrappedSchema);
              ;
              number = input.readFieldNumber(wrappedSchema)) {
            switch (number) {
              case 0:
                return;
              case 1:
                output.writeInt32(number, input.readInt32(), true);
                break;
              case 2:
                input.transferByteRangeTo(output, true, number, true);
                break;

              case 3:
                output.writeObject(number, pipe, Bar.getPipeSchema(), true);
                break;

              case 4:
                output.writeEnum(number, input.readEnum(), true);
                break;

              case 5:
                input.transferByteRangeTo(output, false, number, true);
                break;
              case 6:
                output.writeBool(number, input.readBool(), true);
                break;
              case 7:
                output.writeFloat(number, input.readFloat(), true);
                break;
              case 8:
                output.writeDouble(number, input.readDouble(), true);
                break;
              case 9:
                output.writeInt64(number, input.readInt64(), true);
                break;
              default:
                input.handleUnknownField(number, wrappedSchema);
            }
          }
        }
Exemplo n.º 2
0
  public void writeTo(Output output, Object /* Foo */ messageObj) throws IOException {
    Foo message = (Foo) messageObj;
    if (message.someInt != null) {
      for (int i = 0; i < message.someInt.size(); i++) {
        Integer someInt = (Integer) message.someInt.elementAt(i);
        if (someInt != null) output.writeInt32(1, someInt.intValue(), true);
      }
    }

    if (message.someString != null) {
      for (int i = 0; i < message.someString.size(); i++) {
        String someString = (String) message.someString.elementAt(i);
        if (someString != null) output.writeString(2, someString, true);
      }
    }

    if (message.someBar != null) {
      for (int i = 0; i < message.someBar.size(); i++) {
        Bar someBar = (Bar) message.someBar.elementAt(i);
        if (someBar != null) output.writeObject(3, someBar, Bar.getSchema(), true);
      }
    }

    if (message.someEnum != null) {
      for (int i = 0; i < message.someEnum.size(); i++) {
        Integer someEnum = (Integer) message.someEnum.elementAt(i);
        if (someEnum != null) output.writeEnum(4, someEnum.intValue(), true);
      }
    }

    if (message.someBytes != null) {
      for (int i = 0; i < message.someBytes.size(); i++) {
        ByteString someBytes = (ByteString) message.someBytes.elementAt(i);
        if (someBytes != null) output.writeBytes(5, someBytes, true);
      }
    }

    if (message.someBoolean != null) {
      for (int i = 0; i < message.someBoolean.size(); i++) {
        Boolean someBoolean = (Boolean) message.someBoolean.elementAt(i);
        if (someBoolean != null) output.writeBool(6, someBoolean.booleanValue(), true);
      }
    }

    if (message.someFloat != null) {
      for (int i = 0; i < message.someFloat.size(); i++) {
        Float someFloat = (Float) message.someFloat.elementAt(i);
        if (someFloat != null) output.writeFloat(7, someFloat.floatValue(), true);
      }
    }

    if (message.someDouble != null) {
      for (int i = 0; i < message.someDouble.size(); i++) {
        Double someDouble = (Double) message.someDouble.elementAt(i);
        if (someDouble != null) output.writeDouble(8, someDouble.doubleValue(), true);
      }
    }

    if (message.someLong != null) {
      for (int i = 0; i < message.someLong.size(); i++) {
        Long someLong = (Long) message.someLong.elementAt(i);
        if (someLong != null) output.writeInt64(9, someLong.longValue(), true);
      }
    }
  }