Class KeyValNameSpace

java.lang.Object
com.tccc.kos.commons.core.service.keyval.KeyValNameSpace

public class KeyValNameSpace extends Object
Wrapper around KeyValService that binds all accesses to a particular namespace.
Version:
2023-09-06
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    exists(String name)
    Return true if the specified key exists.
    get(String name)
    Get the value of the specified key.
    <T> T
    get(String name, Class<T> clazz)
    Get the value of the specified key and convert the string to an instance of the specified type.
    Return all key/val pairs in this name space.
    <T> Map<String,T>
    getAll(Class<T> clazz)
    Return all key/val pairs in this name space as instance of the specified class.
    Return all keys in this name space.
    byte[]
    Get the value of the specified key as a blob.
    Return the name space name.
    void
    remove(String name)
    Remove the specified key/val.
    void
    Remove all the key/vals in this name space.
    void
    set(String name, String val)
    Set the value of the specified key.
    void
    set(String name, String val, boolean encrypted)
    Set the value of the specified key with optional encryption.
    void
    setBlob(String name, byte[] val)
    Set the value of the specified key to the specified blob.
    void
    setBlob(String ns, String name, byte[] val, boolean encrypted)
    Set the value of the specified key to the specified blob with optional encryption.
    void
    setObj(String name, Object val)
    Set the value of the specified key to the json of the specified value object.
    void
    setObj(String name, Object val, boolean encrypted)
    Set the value of the specified key to the json of the specified value object with optional encryption.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • set

      public void set(String name, String val, boolean encrypted)
      Set the value of the specified key with optional encryption.
      Parameters:
      name - the key name
      val - the value
      encrypted - if true, encrypt the value
    • set

      public void set(String name, String val)
      Set the value of the specified key.
      Parameters:
      name - the key name
      val - the value
    • setObj

      public void setObj(String name, Object val)
      Set the value of the specified key to the json of the specified value object.
      Parameters:
      name - the key name
      val - the object to convert to json and store
    • setObj

      public void setObj(String name, Object val, boolean encrypted)
      Set the value of the specified key to the json of the specified value object with optional encryption.
      Parameters:
      name - the key name
      val - the object to convert to json and store
      encrypted - if true, encrypt value in the database
    • setBlob

      public void setBlob(String name, byte[] val)
      Set the value of the specified key to the specified blob.
      Parameters:
      name - the key name
      val - the array of bytes to store
    • setBlob

      public void setBlob(String ns, String name, byte[] val, boolean encrypted)
      Set the value of the specified key to the specified blob with optional encryption.
      Parameters:
      name - the key name
      val - the object to convert to json and store
      encrypted - if true, encrypt the data in storage
    • exists

      public boolean exists(String name)
      Return true if the specified key exists.
      Parameters:
      name - the key name
    • get

      public String get(String name)
      Get the value of the specified key. If the value is encrypted it will automatically be decrypted.
      Parameters:
      name - the key name
    • get

      public <T> T get(String name, Class<T> clazz) throws Exception
      Get the value of the specified key and convert the string to an instance of the specified type. If the value is encrypted it will automatically be decrypted.
      Parameters:
      name - the key name
      clazz - the type to convert the value to
      Throws:
      Exception
    • getBlob

      public byte[] getBlob(String name) throws Exception
      Get the value of the specified key as a blob. This is only valid for fetching values that were stored using setBlob() .
      Parameters:
      name - the key name
      Throws:
      Exception
    • remove

      public void remove(String name)
      Remove the specified key/val.
      Parameters:
      name - the key name
    • getAllKeys

      public Set<String> getAllKeys()
      Return all keys in this name space.
    • getAll

      public Map<String,String> getAll()
      Return all key/val pairs in this name space.
    • getAll

      public <T> Map<String,T> getAll(Class<T> clazz)
      Return all key/val pairs in this name space as instance of the specified class.
    • removeAll

      public void removeAll()
      Remove all the key/vals in this name space.
    • getNameSpace

      public String getNameSpace()
      Return the name space name.