Class PropertyStorageAdapter

java.lang.Object
com.gigaspaces.client.storage_adapters.PropertyStorageAdapter
Direct Known Subclasses:
AbstractAesAdapter, BinaryAdapter, ZipAdapter

public abstract class PropertyStorageAdapter extends Object
Base class for adapting space properties values before storing them in space or after retrieving them.
Since:
15.2
Author:
Niv Ingberg
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected byte[]
    Helper method for decoding a base64-encoded string to a byte array.
    protected String
    base64Encode(byte[] bytes)
    Helper method for encoding a byte array to a base64-encoded string.
    protected Object
    deserialize(byte[] data)
    Helper method for deserializing a byte array to a serializable object.
    abstract Object
    Triggered when a property value arrives from the space and is about to be injected in the user's object.
    Returns a name used for display in monitoring tools.
    Returns the class of the values which will be stored in the space.
    protected byte[]
    Helper method for serializing a serializable object to a byte array.
    boolean
    Indicates whether equality matching is supported.
    boolean
    Indicates whether ordered matching is supported.
    protected BinaryWrapper
    toBinaryWrapper(byte[] bytes)
    Default factory for wrapping a byte array in a container for space storage.
    abstract Object
    toSpace(Object value)
    Triggered when a property value is retrieved from the user's object and is about to be sent to the space.
    protected byte[]
    unwrapBinary(Object spaceValue)
    Helper method for unwrapping a byte array from its container object.
    protected Object
    unzip(byte[] data)
    Helper method for uncompressing and deserializing a byte array to a serializable object.
    boolean
    Determines if binary content should be stored in the space as a string in base64 encoding.
    protected Object
    wrapBinary(byte[] data)
    Helper method for wrapping a byte array in a container object for space storage.
    protected byte[]
    zip(Object value)
    Helper method for serializing and compressing a serializable object to a byte array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PropertyStorageAdapter

      public PropertyStorageAdapter()
  • Method Details

    • toSpace

      public abstract Object toSpace(Object value) throws IOException
      Triggered when a property value is retrieved from the user's object and is about to be sent to the space.
      Parameters:
      value - The original property value
      Returns:
      The value which should be stored in space
      Throws:
      IOException - Thrown when processing the property value fails.
    • fromSpace

      public abstract Object fromSpace(Object value) throws IOException, ClassNotFoundException
      Triggered when a property value arrives from the space and is about to be injected in the user's object.
      Parameters:
      value - The value which was stored in the space
      Returns:
      The value which should be set in the user's object.
      Throws:
      IOException - Thrown when processing the property value fails.
      ClassNotFoundException - Thrown when processing the property value fails due to a class loading issue.
    • getName

      public String getName()
      Returns a name used for display in monitoring tools.
    • getStorageClass

      public Class<?> getStorageClass()
      Returns the class of the values which will be stored in the space.
    • supportsEqualsMatching

      public boolean supportsEqualsMatching()
      Indicates whether equality matching is supported. Defaults to false. Storage adapters who support equality should override this to true.
    • supportsOrderedMatching

      public boolean supportsOrderedMatching()
      Indicates whether ordered matching is supported. Defaults to false. Storage adapters who support order should override this to true.
    • useBase64Wrapper

      public boolean useBase64Wrapper()
      Determines if binary content should be stored in the space as a string in base64 encoding. Defaults to false.
    • serialize

      protected byte[] serialize(Object value) throws IOException
      Helper method for serializing a serializable object to a byte array.
      Throws:
      IOException
    • deserialize

      protected Object deserialize(byte[] data) throws IOException, ClassNotFoundException
      Helper method for deserializing a byte array to a serializable object.
      Throws:
      IOException
      ClassNotFoundException
    • zip

      protected byte[] zip(Object value) throws IOException
      Helper method for serializing and compressing a serializable object to a byte array.
      Throws:
      IOException
    • unzip

      protected Object unzip(byte[] data) throws IOException, ClassNotFoundException
      Helper method for uncompressing and deserializing a byte array to a serializable object.
      Throws:
      IOException
      ClassNotFoundException
    • wrapBinary

      protected Object wrapBinary(byte[] data)
      Helper method for wrapping a byte array in a container object for space storage.
    • unwrapBinary

      protected byte[] unwrapBinary(Object spaceValue)
      Helper method for unwrapping a byte array from its container object.
    • toBinaryWrapper

      protected BinaryWrapper toBinaryWrapper(byte[] bytes)
      Default factory for wrapping a byte array in a container for space storage.
    • base64Encode

      protected String base64Encode(byte[] bytes)
      Helper method for encoding a byte array to a base64-encoded string.
    • base64Decode

      protected byte[] base64Decode(String s)
      Helper method for decoding a base64-encoded string to a byte array.