com.google.protobuf
Class UnknownFieldSet.Builder

java.lang.Object
  extended by com.google.protobuf.UnknownFieldSet.Builder
Enclosing class:
UnknownFieldSet

public static final class UnknownFieldSet.Builder
extends java.lang.Object

Builder for UnknownFieldSets.

Note that this class maintains UnknownFieldSet.Field.Builders for all fields in the set. Thus, adding one element to an existing UnknownFieldSet.Field does not require making a copy. This is important for efficient parsing of unknown repeated fields. However, it implies that UnknownFieldSet.Fields cannot be constructed independently, nor can two UnknownFieldSets share the same Field object.

Use UnknownFieldSet.newBuilder() to construct a Builder.


Method Summary
 UnknownFieldSet.Builder addField(int number, UnknownFieldSet.Field field)
          Add a field to the UnknownFieldSet.
 java.util.Map<java.lang.Integer,UnknownFieldSet.Field> asMap()
          Get all present Fields as an immutable Map.
 UnknownFieldSet build()
          Build the UnknownFieldSet and return it.
 UnknownFieldSet.Builder clear()
          Reset the builder to an empty set.
 boolean hasField(int number)
          Check if the given field number is present in the set.
 UnknownFieldSet.Builder mergeField(int number, UnknownFieldSet.Field field)
          Add a field to the UnknownFieldSet.
 boolean mergeFieldFrom(int tag, CodedInputStream input)
          Parse a single field from input and merge it into this set.
 UnknownFieldSet.Builder mergeFrom(byte[] data)
          Parse data as an UnknownFieldSet and merge it with the set being built.
 UnknownFieldSet.Builder mergeFrom(ByteString data)
          Parse data as an UnknownFieldSet and merge it with the set being built.
 UnknownFieldSet.Builder mergeFrom(CodedInputStream input)
          Parse an entire message from input and merge its fields into this set.
 UnknownFieldSet.Builder mergeFrom(java.io.InputStream input)
          Parse an UnknownFieldSet from input and merge it with the set being built.
 UnknownFieldSet.Builder mergeFrom(UnknownFieldSet other)
          Merge the fields from other into this set.
 UnknownFieldSet.Builder mergeVarintField(int number, int value)
          Convenience method for merging a new field containing a single varint value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

build

public UnknownFieldSet build()
Build the UnknownFieldSet and return it.

Once build() has been called, the Builder will no longer be usable. Calling any method after build() will throw NullPointerException.


clear

public UnknownFieldSet.Builder clear()
Reset the builder to an empty set.


mergeFrom

public UnknownFieldSet.Builder mergeFrom(UnknownFieldSet other)
Merge the fields from other into this set. If a field number exists in both sets, other's values for that field will be appended to the values in this set.


mergeField

public UnknownFieldSet.Builder mergeField(int number,
                                          UnknownFieldSet.Field field)
Add a field to the UnknownFieldSet. If a field with the same number already exists, the two are merged.


mergeVarintField

public UnknownFieldSet.Builder mergeVarintField(int number,
                                                int value)
Convenience method for merging a new field containing a single varint value. This is used in particular when an unknown enum value is encountered.


hasField

public boolean hasField(int number)
Check if the given field number is present in the set.


addField

public UnknownFieldSet.Builder addField(int number,
                                        UnknownFieldSet.Field field)
Add a field to the UnknownFieldSet. If a field with the same number already exists, it is removed.


asMap

public java.util.Map<java.lang.Integer,UnknownFieldSet.Field> asMap()
Get all present Fields as an immutable Map. If more fields are added, the changes may or may not be reflected in this map.


mergeFrom

public UnknownFieldSet.Builder mergeFrom(CodedInputStream input)
                                  throws java.io.IOException
Parse an entire message from input and merge its fields into this set.

Throws:
java.io.IOException

mergeFieldFrom

public boolean mergeFieldFrom(int tag,
                              CodedInputStream input)
                       throws java.io.IOException
Parse a single field from input and merge it into this set.

Parameters:
tag - The field's tag number, which was already parsed.
Returns:
false if the tag is an engroup tag.
Throws:
java.io.IOException

mergeFrom

public UnknownFieldSet.Builder mergeFrom(ByteString data)
                                  throws InvalidProtocolBufferException
Parse data as an UnknownFieldSet and merge it with the set being built. This is just a small wrapper around mergeFrom(CodedInputStream).

Throws:
InvalidProtocolBufferException

mergeFrom

public UnknownFieldSet.Builder mergeFrom(byte[] data)
                                  throws InvalidProtocolBufferException
Parse data as an UnknownFieldSet and merge it with the set being built. This is just a small wrapper around mergeFrom(CodedInputStream).

Throws:
InvalidProtocolBufferException

mergeFrom

public UnknownFieldSet.Builder mergeFrom(java.io.InputStream input)
                                  throws java.io.IOException
Parse an UnknownFieldSet from input and merge it with the set being built. This is just a small wrapper around mergeFrom(CodedInputStream).

Throws:
java.io.IOException


Copyright © 2008. All Rights Reserved.