public final class Any extends GeneratedMessage implements AnyOrBuilder
google.protobuf.Any
`Any` contains an arbitrary serialized message along with a URL that describes the type of the serialized message. The proto runtimes and/or compiler will eventually provide utilities to pack/unpack Any values (projected Q1/15). # JSON The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: package google.profile; message Person { string first_name = 1; string last_name = 2; } { "@type": "type.googleapis.com/google.profile.Person", "firstName": <string>, "lastName": <string> } If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the the `@type` field. Example (for message [google.protobuf.Duration][google.protobuf.Duration]): { "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" }
Modifier and Type | Class and Description |
---|---|
static class |
Any.Builder
Protobuf type
google.protobuf.Any |
GeneratedMessage.BuilderParent, GeneratedMessage.ExtendableBuilder<MessageType extends GeneratedMessage.ExtendableMessage,BuilderType extends GeneratedMessage.ExtendableBuilder>, GeneratedMessage.ExtendableMessage<MessageType extends GeneratedMessage.ExtendableMessage>, GeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>, GeneratedMessage.FieldAccessorTable, GeneratedMessage.GeneratedExtension<ContainingType extends Message,Type>
Modifier and Type | Field and Description |
---|---|
static Parser<Any> |
PARSER |
static int |
TYPE_URL_FIELD_NUMBER |
static int |
VALUE_FIELD_NUMBER |
alwaysUseFieldBuilders, unknownFields
memoizedSize
memoizedHashCode
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares the specified object with this message for equality.
|
static Any |
getDefaultInstance() |
Any |
getDefaultInstanceForType()
Get an instance of the type with no fields set.
|
static Descriptors.Descriptor |
getDescriptor() |
Parser<Any> |
getParserForType()
Gets the parser for a message of the same type as this message.
|
int |
getSerializedSize()
Get the number of bytes required to encode this message.
|
String |
getTypeUrl()
optional string type_url = 1; |
ByteString |
getTypeUrlBytes()
optional string type_url = 1; |
UnknownFieldSet |
getUnknownFields()
Get the
UnknownFieldSet for this message. |
ByteString |
getValue()
optional bytes value = 2; |
int |
hashCode()
Returns the hash code value for this message.
|
protected GeneratedMessage.FieldAccessorTable |
internalGetFieldAccessorTable()
Get the FieldAccessorTable for this type.
|
boolean |
isInitialized()
Returns true if all required fields in the message and all embedded
messages are set, false otherwise.
|
static Any.Builder |
newBuilder() |
static Any.Builder |
newBuilder(Any prototype) |
Any.Builder |
newBuilderForType()
Constructs a new builder for a message of the same type as this message.
|
protected Any.Builder |
newBuilderForType(GeneratedMessage.BuilderParent parent) |
static Any |
parseDelimitedFrom(InputStream input) |
static Any |
parseDelimitedFrom(InputStream input,
ExtensionRegistryLite extensionRegistry) |
static Any |
parseFrom(byte[] data) |
static Any |
parseFrom(byte[] data,
ExtensionRegistryLite extensionRegistry) |
static Any |
parseFrom(ByteString data) |
static Any |
parseFrom(ByteString data,
ExtensionRegistryLite extensionRegistry) |
static Any |
parseFrom(CodedInputStream input) |
static Any |
parseFrom(CodedInputStream input,
ExtensionRegistryLite extensionRegistry) |
static Any |
parseFrom(InputStream input) |
static Any |
parseFrom(InputStream input,
ExtensionRegistryLite extensionRegistry) |
Any.Builder |
toBuilder()
Constructs a builder initialized with the current message.
|
void |
writeTo(CodedOutputStream output)
Serializes the message and writes it to
output . |
getAllFields, getDescriptorForType, getField, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, hasField, hasOneof, internalGetMapField, makeExtensionsImmutable, newFileScopedGeneratedExtension, newFileScopedGeneratedExtension, newMessageScopedGeneratedExtension, newMessageScopedGeneratedExtension, parseUnknownField, writeReplace
findInitializationErrors, getInitializationErrorString, hashFields, toString
addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeTo
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
findInitializationErrors, getAllFields, getDescriptorForType, getField, getInitializationErrorString, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, hasField, hasOneof
toByteArray, toByteString, writeDelimitedTo, writeTo
public static final int TYPE_URL_FIELD_NUMBER
public static final int VALUE_FIELD_NUMBER
public final UnknownFieldSet getUnknownFields()
MessageOrBuilder
UnknownFieldSet
for this message.getUnknownFields
in interface MessageOrBuilder
getUnknownFields
in class GeneratedMessage
public static final Descriptors.Descriptor getDescriptor()
protected GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
GeneratedMessage
internalGetFieldAccessorTable
in class GeneratedMessage
public String getTypeUrl()
optional string type_url = 1;
A URL/resource name whose content describes the type of the serialized message. For URLs which use the schema `http`, `https`, or no schema, the following restrictions and interpretations apply: * If no schema is provided, `https` is assumed. * The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). * An HTTP GET on the URL must yield a [google.protobuf.Type][google.protobuf.Type] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Schemas other than `http`, `https` (or the empty schema) might be used with implementation specific semantics. Types originating from the `google.*` package namespace should use `type.googleapis.com/full.type.name` (without schema and path). A type service will eventually become available which serves those URLs (projected Q2/15).
getTypeUrl
in interface AnyOrBuilder
public ByteString getTypeUrlBytes()
optional string type_url = 1;
A URL/resource name whose content describes the type of the serialized message. For URLs which use the schema `http`, `https`, or no schema, the following restrictions and interpretations apply: * If no schema is provided, `https` is assumed. * The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). * An HTTP GET on the URL must yield a [google.protobuf.Type][google.protobuf.Type] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Schemas other than `http`, `https` (or the empty schema) might be used with implementation specific semantics. Types originating from the `google.*` package namespace should use `type.googleapis.com/full.type.name` (without schema and path). A type service will eventually become available which serves those URLs (projected Q2/15).
getTypeUrlBytes
in interface AnyOrBuilder
public ByteString getValue()
optional bytes value = 2;
Must be valid serialized data of the above specified type.
getValue
in interface AnyOrBuilder
public final boolean isInitialized()
MessageLiteOrBuilder
isInitialized
in interface MessageLiteOrBuilder
isInitialized
in class GeneratedMessage
public void writeTo(CodedOutputStream output) throws IOException
MessageLite
output
. This does not
flush or close the stream.writeTo
in interface MessageLite
writeTo
in class GeneratedMessage
IOException
public int getSerializedSize()
MessageLite
getSerializedSize
in interface MessageLite
getSerializedSize
in class GeneratedMessage
public boolean equals(Object obj)
Message
true
if the given object is a message of the same type (as
defined by getDescriptorForType()
) and has identical values for
all of its fields. Subclasses must implement this; inheriting
Object.equals()
is incorrect.equals
in interface Message
equals
in class AbstractMessage
obj
- object to be compared for equality with this messagetrue
if the specified object is equal to this messagepublic int hashCode()
Message
Object.hashCode()
is incorrect.hashCode
in interface Message
hashCode
in class AbstractMessage
Map.hashCode()
public static Any parseFrom(ByteString data) throws InvalidProtocolBufferException
InvalidProtocolBufferException
public static Any parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
InvalidProtocolBufferException
public static Any parseFrom(byte[] data) throws InvalidProtocolBufferException
InvalidProtocolBufferException
public static Any parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
InvalidProtocolBufferException
public static Any parseFrom(InputStream input) throws IOException
IOException
public static Any parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws IOException
IOException
public static Any parseDelimitedFrom(InputStream input) throws IOException
IOException
public static Any parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws IOException
IOException
public static Any parseFrom(CodedInputStream input) throws IOException
IOException
public static Any parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws IOException
IOException
public Any.Builder newBuilderForType()
MessageLite
newBuilderForType
in interface Message
newBuilderForType
in interface MessageLite
public static Any.Builder newBuilder()
public static Any.Builder newBuilder(Any prototype)
public Any.Builder toBuilder()
MessageLite
toBuilder
in interface Message
toBuilder
in interface MessageLite
protected Any.Builder newBuilderForType(GeneratedMessage.BuilderParent parent)
newBuilderForType
in class GeneratedMessage
public static Any getDefaultInstance()
public Parser<Any> getParserForType()
MessageLite
getParserForType
in interface Message
getParserForType
in interface MessageLite
getParserForType
in class GeneratedMessage
public Any getDefaultInstanceForType()
MessageLiteOrBuilder
getDefaultInstance()
method of generated message classes in that
this method is an abstract method of the MessageLite
interface
whereas getDefaultInstance()
is a static method of a specific
class. They return the same thing.getDefaultInstanceForType
in interface MessageLiteOrBuilder
getDefaultInstanceForType
in interface MessageOrBuilder
Copyright © 2008–2015 Google. All rights reserved.