com.google.appengine.api.memcache

## Class MemcacheSerialization

- java.lang.Object
- - com.google.appengine.api.memcache.MemcacheSerialization

-     public class MemcacheSerialization
      extends java.lang.Object

  Static serialization helpers shared by `MemcacheServiceImpl` and `LocalMemcacheService`. This class is thread-safe.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `MemcacheSerialization.Flag` Values used as flags on the MemcacheService's values.
    `static class` | `MemcacheSerialization.ValueAndFlags` Tuple of a serialized byte array value and associated flags to interpret that value.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.Object` | `deserialize(byte[] value, int flags)` Deserialize the object, according to its flags.
    `static byte[]` | `makePbKey(java.lang.Object key)` Converts the user's key Object into a byte[] for the MemcacheGetRequest.
    `static MemcacheSerialization.ValueAndFlags` | `serialize(java.lang.Object value)`

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

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

- - ### Field Detail

    - #### USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY

          public static final java.lang.String USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### deserialize

          public static java.lang.Object deserialize(byte[] value,
                                                     int flags)
                                              throws java.lang.ClassNotFoundException,
                                                     java.io.IOException

      Deserialize the object, according to its flags. This would have private visibility, but is also used by LocalMemcacheService for the increment operation.
      Parameters:
        `value` -
        `flags` -
      Returns:
        the Object originally stored
      Throws:
        `java.lang.ClassNotFoundException` - if the object can't be re-instantiated due to being an unlocatable type
        `java.io.IOException` - if the object can't be re-instantiated for some other reason

    - #### makePbKey

          public static byte[] makePbKey(java.lang.Object key)
                                  throws java.io.IOException

      Converts the user's key Object into a byte[] for the MemcacheGetRequest. Because the underlying service has a length limit, we actually use the SHA1 hash of the serialized object as its key if it's not a basic type. For the basic types (that is, `String`, `Boolean`, and the fixed-point numbers), we use a human-readable representation.
      Parameters:
        `key` -
      Returns:
        hash result. For the key `null`, the hash is also `null`.
      Throws:
        `java.io.IOException`

    - #### serialize

          public static MemcacheSerialization.ValueAndFlags serialize(java.lang.Object value)
                                                               throws java.io.IOException

      Parameters:
        `value` -
      Returns:
        the ValueAndFlags containing a serialized representation of the Object and the flags to hint deserialization.
      Throws:
        `java.io.IOException` - for serialization errors, normally due to a non-serializable object type