gpt4 book ai didi

com.google.protobuf.nano.WireFormatNano.getTagFieldNumber()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 07:59:05 28 4
gpt4 key购买 nike

本文整理了Java中com.google.protobuf.nano.WireFormatNano.getTagFieldNumber()方法的一些代码示例,展示了WireFormatNano.getTagFieldNumber()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WireFormatNano.getTagFieldNumber()方法的具体详情如下:
包路径:com.google.protobuf.nano.WireFormatNano
类名称:WireFormatNano
方法名:getTagFieldNumber

WireFormatNano.getTagFieldNumber介绍

[英]Given a tag value, determines the field number (the upper 29 bits).
[中]给定一个标记值,确定字段号(上限29位)。

代码示例

代码示例来源:origin: IvanVolosyuk/diskusage

/**
 * Checks if there is a value stored for the specified extension in this
 * message.
 */
public final boolean hasExtension(Extension<M, ?> extension) {
  if (unknownFieldData == null) {
    return false;
  }
  FieldData field = unknownFieldData.get(WireFormatNano.getTagFieldNumber(extension.tag));
  return field != null;
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

protected int computeSingularSerializedSize(Object value) {
  // This implementation is for message/group extensions.
  int fieldNumber = WireFormatNano.getTagFieldNumber(tag);
  switch (type) {
    case TYPE_GROUP:
      MessageNano groupValue = (MessageNano) value;
      return CodedOutputByteBufferNano.computeGroupSize(fieldNumber, groupValue);
    case TYPE_MESSAGE:
      MessageNano messageValue = (MessageNano) value;
      return CodedOutputByteBufferNano.computeMessageSize(fieldNumber, messageValue);
    default:
      throw new IllegalArgumentException("Unknown type " + type);
  }
}

代码示例来源:origin: IvanVolosyuk/diskusage

protected int computeSingularSerializedSize(Object value) {
  // This implementation is for message/group extensions.
  int fieldNumber = WireFormatNano.getTagFieldNumber(tag);
  switch (type) {
    case TYPE_GROUP:
      MessageNano groupValue = (MessageNano) value;
      return CodedOutputByteBufferNano.computeGroupSize(fieldNumber, groupValue);
    case TYPE_MESSAGE:
      MessageNano messageValue = (MessageNano) value;
      return CodedOutputByteBufferNano.computeMessageSize(fieldNumber, messageValue);
    default:
      throw new IllegalArgumentException("Unknown type " + type);
  }
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

/**
 * Gets the value stored in the specified extension of this message.
 */
public final <T> T getExtension(Extension<M, T> extension) {
  if (unknownFieldData == null) {
    return null;
  }
  FieldData field = unknownFieldData.get(WireFormatNano.getTagFieldNumber(extension.tag));
  return field == null ? null : field.getValue(extension);
}

代码示例来源:origin: IvanVolosyuk/diskusage

/**
 * Gets the value stored in the specified extension of this message.
 */
public final <T> T getExtension(Extension<M, T> extension) {
  if (unknownFieldData == null) {
    return null;
  }
  FieldData field = unknownFieldData.get(WireFormatNano.getTagFieldNumber(extension.tag));
  return field == null ? null : field.getValue(extension);
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

protected Object readData(CodedInputByteBufferNano input) {
  // This implementation is for message/group extensions.
  Class<?> messageType = repeated ? clazz.getComponentType() : clazz;
  try {
    switch (type) {
      case TYPE_GROUP:
        MessageNano group = (MessageNano) messageType.newInstance();
        input.readGroup(group, WireFormatNano.getTagFieldNumber(tag));
        return group;
      case TYPE_MESSAGE:
        MessageNano message = (MessageNano) messageType.newInstance();
        input.readMessage(message);
        return message;
      default:
        throw new IllegalArgumentException("Unknown type " + type);
    }
  } catch (InstantiationException e) {
    throw new IllegalArgumentException(
        "Error creating instance of class " + messageType, e);
  } catch (IllegalAccessException e) {
    throw new IllegalArgumentException(
        "Error creating instance of class " + messageType, e);
  } catch (IOException e) {
    throw new IllegalArgumentException("Error reading extension field", e);
  }
}

代码示例来源:origin: IvanVolosyuk/diskusage

protected Object readData(CodedInputByteBufferNano input) {
  // This implementation is for message/group extensions.
  Class<?> messageType = repeated ? clazz.getComponentType() : clazz;
  try {
    switch (type) {
      case TYPE_GROUP:
        MessageNano group = (MessageNano) messageType.newInstance();
        input.readGroup(group, WireFormatNano.getTagFieldNumber(tag));
        return group;
      case TYPE_MESSAGE:
        MessageNano message = (MessageNano) messageType.newInstance();
        input.readMessage(message);
        return message;
      default:
        throw new IllegalArgumentException("Unknown type " + type);
    }
  } catch (InstantiationException e) {
    throw new IllegalArgumentException(
        "Error creating instance of class " + messageType, e);
  } catch (IllegalAccessException e) {
    throw new IllegalArgumentException(
        "Error creating instance of class " + messageType, e);
  } catch (IOException e) {
    throw new IllegalArgumentException("Error reading extension field", e);
  }
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

protected void writeSingularData(Object value, CodedOutputByteBufferNano out) {
  // This implementation is for message/group extensions.
  try {
    out.writeRawVarint32(tag);
    switch (type) {
      case TYPE_GROUP:
        MessageNano groupValue = (MessageNano) value;
        int fieldNumber = WireFormatNano.getTagFieldNumber(tag);
        out.writeGroupNoTag(groupValue);
        // The endgroup tag must be included in the data payload.
        out.writeTag(fieldNumber, WireFormatNano.WIRETYPE_END_GROUP);
        break;
      case TYPE_MESSAGE:
        MessageNano messageValue = (MessageNano) value;
        out.writeMessageNoTag(messageValue);
        break;
      default:
        throw new IllegalArgumentException("Unknown type " + type);
    }
  } catch (IOException e) {
    // Should not happen
    throw new IllegalStateException(e);
  }
}

代码示例来源:origin: IvanVolosyuk/diskusage

protected void writeSingularData(Object value, CodedOutputByteBufferNano out) {
  // This implementation is for message/group extensions.
  try {
    out.writeRawVarint32(tag);
    switch (type) {
      case TYPE_GROUP:
        MessageNano groupValue = (MessageNano) value;
        int fieldNumber = WireFormatNano.getTagFieldNumber(tag);
        out.writeGroupNoTag(groupValue);
        // The endgroup tag must be included in the data payload.
        out.writeTag(fieldNumber, WireFormatNano.WIRETYPE_END_GROUP);
        break;
      case TYPE_MESSAGE:
        MessageNano messageValue = (MessageNano) value;
        out.writeMessageNoTag(messageValue);
        break;
      default:
        throw new IllegalArgumentException("Unknown type " + type);
    }
  } catch (IOException e) {
    // Should not happen
    throw new IllegalStateException(e);
  }
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

/**
 * Sets the value of the specified extension of this message.
 */
public final <T> M setExtension(Extension<M, T> extension, T value) {
  int fieldNumber = WireFormatNano.getTagFieldNumber(extension.tag);
  if (value == null) {
    if (unknownFieldData != null) {
      unknownFieldData.remove(fieldNumber);
      if (unknownFieldData.isEmpty()) {
        unknownFieldData = null;
      }
    }
  } else {
    FieldData field = null;
    if (unknownFieldData == null) {
      unknownFieldData = new FieldArray();
    } else {
      field = unknownFieldData.get(fieldNumber);
    }
    if (field == null) {
      unknownFieldData.put(fieldNumber, new FieldData(extension, value));
    } else {
      field.setValue(extension, value);
    }
  }
  @SuppressWarnings("unchecked") // Generated code should guarantee type safety
  M typedThis = (M) this;
  return typedThis;
}

代码示例来源:origin: IvanVolosyuk/diskusage

/**
 * Sets the value of the specified extension of this message.
 */
public final <T> M setExtension(Extension<M, T> extension, T value) {
  int fieldNumber = WireFormatNano.getTagFieldNumber(extension.tag);
  if (value == null) {
    if (unknownFieldData != null) {
      unknownFieldData.remove(fieldNumber);
      if (unknownFieldData.isEmpty()) {
        unknownFieldData = null;
      }
    }
  } else {
    FieldData field = null;
    if (unknownFieldData == null) {
      unknownFieldData = new FieldArray();
    } else {
      field = unknownFieldData.get(fieldNumber);
    }
    if (field == null) {
      unknownFieldData.put(fieldNumber, new FieldData(extension, value));
    } else {
      field.setValue(extension, value);
    }
  }
  @SuppressWarnings("unchecked") // Generated code should guarantee type safety
  M typedThis = (M) this;
  return typedThis;
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

return false;  // This wasn't an unknown field, it's an end-group tag.
int fieldNumber = WireFormatNano.getTagFieldNumber(tag);
int endPos = input.getPosition();
byte[] bytes = input.getData(startPos, endPos - startPos);

代码示例来源:origin: IvanVolosyuk/diskusage

skipMessage();
checkLastTagWas(
 WireFormatNano.makeTag(WireFormatNano.getTagFieldNumber(tag),
           WireFormatNano.WIRETYPE_END_GROUP));
return true;

代码示例来源:origin: WeAreFairphone/FP2-Launcher

skipMessage();
checkLastTagWas(
 WireFormatNano.makeTag(WireFormatNano.getTagFieldNumber(tag),
           WireFormatNano.WIRETYPE_END_GROUP));
return true;

代码示例来源:origin: IvanVolosyuk/diskusage

return false;  // This wasn't an unknown field, it's an end-group tag.
int fieldNumber = WireFormatNano.getTagFieldNumber(tag);
int endPos = input.getPosition();
byte[] bytes = input.getData(startPos, endPos - startPos);

代码示例来源:origin: IvanVolosyuk/diskusage

@Override
protected final int computeSingularSerializedSize(Object value) {
  int fieldNumber = WireFormatNano.getTagFieldNumber(tag);
  switch (type) {
    case TYPE_DOUBLE:

代码示例来源:origin: WeAreFairphone/FP2-Launcher

@Override
protected final int computeSingularSerializedSize(Object value) {
  int fieldNumber = WireFormatNano.getTagFieldNumber(tag);
  switch (type) {
    case TYPE_DOUBLE:

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com