Package org.infinispan.protostream
Interface UnknownFieldSet
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
UnknownFieldSetImpl
public interface UnknownFieldSet extends Serializable
UnknownFieldSetkeeps track of fields seen during parsing of a protocol message but whose field numbers are not recognized by the user provided marshallers (are never requested by them). This usually occurs when new fields are added to a message type and then messages containing those fields are read by old versions of software that was built before the new fields were added.This is also used to handle the case when fields are requested in a different order than they were written to the stream (lowers performance but still works). In this case all fields that are encountered while parsing the stream up to the point where the requested field is finally encountered are cached/buffered in this data structure.
Instances of UnknownFieldSet are never to be created by the user. They will be created by the library and handed over to the message marshaller via the
UnknownFieldSetHandlermechanism. Instances are serializable according to Java serialization.- Since:
- 1.0
- Author:
- anistor@redhat.com
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <A> AconsumeTag(int tag)Reads and removes a field value from the set.booleanhasTag(int tag)Checks if a tag is present.booleanisEmpty()Checks if there are any fields in this set.voidputVarintField(int tag, int value)Convenience method for merging a new field containing a single varint value.voidreadAllFields(TagReader input)Parse an entire message frominputand merge its fields into this set.booleanreadSingleField(int tag, TagReader input)Parse a single field frominputand merge it into this set.voidwriteTo(TagWriter output)Writes all fields from this set to theoutputstream.
-
-
-
Method Detail
-
isEmpty
boolean isEmpty()
Checks if there are any fields in this set.
-
readAllFields
void readAllFields(TagReader input) throws IOException
Parse an entire message frominputand merge its fields into this set.- Throws:
IOException
-
readSingleField
boolean readSingleField(int tag, TagReader input) throws IOExceptionParse a single field frominputand merge it into this set.- Parameters:
tag- The field's tag number, which was already parsed (tag contains both field id and wire type).- Returns:
falseif the tag is an end group tag.- Throws:
IOException
-
putVarintField
void putVarintField(int tag, 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.- Parameters:
tag- the field tag (containing both field id and wire type).
-
writeTo
void writeTo(TagWriter output) throws IOException
Writes all fields from this set to theoutputstream.- Throws:
IOException
-
consumeTag
<A> A consumeTag(int tag)
Reads and removes a field value from the set. The field is specified as a tag value composed of the numeric id of the field and the wire type. It's possible that the tag has repeated values; in that case the first one is returned.- Type Parameters:
A- The expected type of the tag value.- Parameters:
tag- the field tag (containing both field id and wire type).- Returns:
- the first seen value or null if the tag was not found.
-
hasTag
boolean hasTag(int tag)
Checks if a tag is present.- Parameters:
tag- the field tag (containing both field id and wire type).- Returns:
- true if present, false otherwise
-
-