org.apache.thrift.protocol

## Class TProtocolUtil

- java.lang.Object
- - org.apache.thrift.protocol.TProtocolUtil

-     public class TProtocolUtil
      extends java.lang.Object

  Utility class with static methods for interacting with protocol data streams.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TProtocolUtil()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static TProtocolFactory` | `guessProtocolFactory(byte[] data, TProtocolFactory fallback)` Attempt to determine the protocol used to serialize some data.
    `static void` | `setMaxSkipDepth(int depth)` Specifies the maximum recursive depth that the skip function will traverse before throwing a TException.
    `static void` | `skip(TProtocol prot, byte type)` Skips over the next data element from the provided input TProtocol object.
    `static void` | `skip(TProtocol prot, byte type, int maxDepth)` Skips over the next data element from the provided input TProtocol object.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TProtocolUtil

          public TProtocolUtil()

  - ### Method Detail

    - #### setMaxSkipDepth

          public static void setMaxSkipDepth(int depth)

      Specifies the maximum recursive depth that the skip function will traverse before throwing a TException. This is a global setting, so any call to skip in this JVM will enforce this value.
      Parameters:
        `depth` - the maximum recursive depth. A value of 2 would allow the skip function to skip a structure or collection with basic children, but it would not permit skipping a struct that had a field containing a child struct. A value of 1 would only allow skipping of simple types and empty structs/collections.

    - #### skip

          public static void skip(TProtocol prot,
                  byte type)
                           throws TException

      Skips over the next data element from the provided input TProtocol object.
      Parameters:
        `prot` - the protocol object to read from
        `type` - the next value will be interpreted as this TType value.
      Throws:
        `TException`

    - #### skip

          public static void skip(TProtocol prot,
                  byte type,
                  int maxDepth)
                           throws TException

      Skips over the next data element from the provided input TProtocol object.
      Parameters:
        `prot` - the protocol object to read from
        `type` - the next value will be interpreted as this TType value.
        `maxDepth` - this function will only skip complex objects to this recursive depth, to prevent Java stack overflow.
      Throws:
        `TException`

    - #### guessProtocolFactory

          public static TProtocolFactory guessProtocolFactory(byte[] data,
                                              TProtocolFactory fallback)

      Attempt to determine the protocol used to serialize some data. The guess is based on known specificities of supported protocols. In some cases, no guess can be done, in that case we return the fallback TProtocolFactory. To be certain to correctly detect the protocol, the first encoded field should have a field id < 256
      Parameters:
        `data` - The serialized data to guess the protocol for.
        `fallback` - The TProtocol to return if no guess can be made.
      Returns:
        a Class implementing TProtocolFactory which can be used to create a deserializer.