Class JythonObjectStore

java.lang.Object
edu.wisc.ssec.mcidasv.util.JythonObjectStore

public class JythonObjectStore extends Object
Wraps the application's IdvObjectStore object and provides methods that are safe to use from Jython scripts.

A secondary aim of this class is to be largely API-compatible with java.util.prefs.Preferences.

  • Field Details

  • Constructor Details

  • Method Details

    • newInstance

      public static JythonObjectStore newInstance(McIDASV mcidasv)
      Return a new JythonObjectStore instance.

      Use this method rather than the constructor.

      Parameters:
      mcidasv - McIDAS-V instance that represents current session. Cannot be null.
      Returns:
      New instance of the JythonObjectStore class.
      Throws:
      NullPointerException - if mcidasv is null.
    • remove

      public void remove(String key)
      Removes the value associated with the given key (if any).
      Parameters:
      key - Key whose associated value is to be removed. Cannot be null.
      Throws:
      NullPointerException - if key is null.
    • getObject

      public <T> T getObject(String key, T defaultValue)
      Returns the object associated with the given key. If key does not exist, defaultValue is returned.
      Type Parameters:
      T - Type of object that will be returned.
      Parameters:
      key - Key whose associated object is to be returned. Cannot be null.
      defaultValue - Value to be returned if key is not valid. null is allowed.
      Returns:
      Object associated with key or defaultValue if key is not valid.
      Throws:
      NullPointerException - if key is null.
    • getShort

      public short getShort(String key, short defaultValue)
      Returns the short value associated with the given key. If key does not exist, defaultValue is returned.
      Parameters:
      key - Key whose associated short value is to be returned. Cannot be null.
      defaultValue - Value to be returned if key is not valid.
      Returns:
      short value associated with key or defaultValue if key is not valid.
      Throws:
      NullPointerException - if key is null.
    • getCharacter

      public char getCharacter(String key, char defaultValue)
      Returns the char value associated with the given key. If key does not exist, defaultValue is returned.
      Parameters:
      key - Key whose associated char value is to be returned. Cannot be null.
      defaultValue - Value to be returned if key is not valid.
      Returns:
      char value associated with key or defaultValue if key is not valid.
      Throws:
      NullPointerException - if key is null.
    • getString

      public String getString(String key, String defaultValue)
      Returns the String value associated with the given key. If key does not exist, defaultValue is returned.
      Parameters:
      key - Key whose associated String value is to be returned. Cannot be null.
      defaultValue - Value to be returned if key is not valid.
      Returns:
      String value associated with key or defaultValue if key is not valid.
      Throws:
      NullPointerException - if key is null.
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
      Returns the boolean value associated with the given key. If key does not exist, defaultValue is returned.
      Parameters:
      key - Key whose associated boolean value is to be returned. Cannot be null.
      defaultValue - Value to be returned if key is not valid.
      Returns:
      boolean value associated with key or defaultValue if key is not valid.
      Throws:
      NullPointerException - if key is null.
    • getDouble

      public double getDouble(String key, double defaultValue)
      Returns the double value associated with the given key. If key does not exist, defaultValue is returned.
      Parameters:
      key - Key whose associated double value is to be returned. Cannot be null.
      defaultValue - Value to be returned if key is not valid.
      Returns:
      double value associated with key or defaultValue if key is not valid.
      Throws:
      NullPointerException - if key is null.
    • getFloat

      public float getFloat(String key, float defaultValue)
      Returns the float value associated with the given key. If key does not exist, defaultValue is returned.
      Parameters:
      key - Key whose associated float value is to be returned. Cannot be null.
      defaultValue - Value to be returned if key is not valid.
      Returns:
      float value associated with key or defaultValue if key is not valid.
      Throws:
      NullPointerException - if key is null.
    • getInteger

      public int getInteger(String key, int defaultValue)
      Returns the int value associated with the given key. If key does not exist, defaultValue is returned.
      Parameters:
      key - Key whose associated int value is to be returned. Cannot be null.
      defaultValue - Value to be returned if key is not valid.
      Returns:
      int value associated with key or defaultValue if key is not valid.
      Throws:
      NullPointerException - if key is null.
    • getLong

      public long getLong(String key, long defaultValue)
      Returns the long value associated with the given key. If key does not exist, defaultValue is returned.
      Parameters:
      key - Key whose associated long value is to be returned. Cannot be null.
      defaultValue - Value to be returned if key is not valid.
      Returns:
      long value associated with key or defaultValue if key is not valid.
      Throws:
      NullPointerException - if key is null.
    • putObject

      public <T> void putObject(String key, T value)
      Associates the given key with the given object.
      Type Parameters:
      T - Type of object to store.
      Parameters:
      key - Key to associate with the given value. Cannot be null.
      value - Object to associate with key. Cannot be null.
      Throws:
      NullPointerException - if either key or value is null.
    • putShort

      public void putShort(String key, short value)
      Associates the given key with the given short value.
      Parameters:
      key - Key to associate with the given value. Cannot be null.
      value - short value to associate with key.
      Throws:
      NullPointerException - if either key or value is null.
    • putCharacter

      public void putCharacter(String key, char value)
      Associates the given key with the given char value.
      Parameters:
      key - Key to associate with the given value. Cannot be null.
      value - char value to associate with key.
      Throws:
      NullPointerException - if either key or value is null.
    • putString

      public void putString(String key, String value)
      Associates the given key with the given String value.
      Parameters:
      key - Key to associate with the given value. Cannot be null.
      value - String value to associate with key. Cannot be null.
      Throws:
      NullPointerException - if either key or value is null.
    • putBoolean

      public void putBoolean(String key, boolean value)
      Associates the given key with the given boolean value.
      Parameters:
      key - Key to associate with the given value. Cannot be null.
      value - boolean value to associate with key.
      Throws:
      NullPointerException - if either key or value is null.
    • putDouble

      public void putDouble(String key, double value)
      Associates the given key with the given double value.
      Parameters:
      key - Key to associate with the given value. Cannot be null.
      value - double value to associate with key.
      Throws:
      NullPointerException - if either key or value is null.
    • putFloat

      public void putFloat(String key, float value)
      Associates the given key with the given float value.
      Parameters:
      key - Key to associate with the given value. Cannot be null.
      value - float value to associate with key.
      Throws:
      NullPointerException - if either key or value is null.
    • putInteger

      public void putInteger(String key, int value)
      Associates the given key with the given int value.
      Parameters:
      key - Key to associate with the given value. Cannot be null.
      value - int value to associate with key.
      Throws:
      NullPointerException - if either key or value is null.
    • putLong

      public void putLong(String key, long value)
      Associates the given key with the given long value.
      Parameters:
      key - Key to associate with the given value. Cannot be null.
      value - long value to associate with key.
      Throws:
      NullPointerException - if either key or value is null.
    • keys

      public Set<String> keys()
    • keys

      public Set<String> keys(String substring)
    • items

      public List<org.python.core.PyTuple> items()
    • items

      public List<org.python.core.PyTuple> items(String substring)
    • listKeys

      public String listKeys()
    • listMatchingKeys

      public String listMatchingKeys(String substring)
    • listItems

      public String listItems()
    • listMatchingItems

      public String listMatchingItems(String substring)