Class Configuration

java.lang.Object
jsyntaxpane.util.Configuration
All Implemented Interfaces:
Map<String,String>

public class Configuration extends Object implements Map<String,String>
Wrapper around the Properties class with supprt for Heirarchical confogurations and more functionality. Except for the getXXXX methods, all other Map Interface methods operate on the current (non-parent) collection and do NOT touch the parent.
  • Field Details

    • EMPTY_LIST

      public static final String[] EMPTY_LIST
    • COMMA_SEPARATOR

      public static final Pattern COMMA_SEPARATOR
  • Constructor Details

    • Configuration

      public Configuration(Class theClass, Configuration parent)
      Creates a new COnfiguration that uses parent as its parent Configuration.
      Parameters:
      theClass -
      parent -
    • Configuration

      public Configuration(Class theClass)
      Creates an empty Configuration
      Parameters:
      theClass -
  • Method Details

    • getString

      public String getString(String key)
      Get a string from this object or one of its parents. If nothing is found, null is returned. If the Regex ${key} is found, then it is replaced by the value of that key within this (or parent's) map. Special COnstructs in ${}:
    • class_path will be replaced by the name of the Configuration (usually ClassName) with "." replaced by "/", and then converted to all lowercase
    • class_simpleName
    • is replaced by class.SimpleName
      Parameters:
      key -
      Returns:
    • getString

      public String getString(String key, String defaultValue)
      Returns a non-null value either by traversing the current and parent(s) map, or returning the defaultValue
      Parameters:
      key -
      defaultValue -
      Returns:
      Throws:
      NullPointerException - if defaultValue is null
    • getInteger

      public int getInteger(String key, int Default)
      Gets an integer from the properties. If number cannot be found or if it cannot be decoded, the default is returned The integer is decoded using {@link Integer.decode(String)}
      Parameters:
      key -
      Default -
      Returns:
    • getPropertyList

      public String[] getPropertyList(String key)
      Returns a String[] of the comma separated items in the value. Does NOT return null. If the key is not found, then an empty string array is returned. So the return of this method can always be used directly in a foreach loop
      Parameters:
      key -
      Returns:
      non-null String[]
    • getBoolean

      public boolean getBoolean(String key, boolean Default)
      Returns a boolean from the configuration
      Parameters:
      key -
      Default -
      Returns:
    • getColor

      public Color getColor(String key, Color Default)
      return the Color that has the given key or the Default
      Parameters:
      key -
      Default -
      Returns:
    • putAll

      public void putAll(Map config)
      Specified by:
      putAll in interface Map<String,String>
    • stringPropertyNames

      public Set<String> stringPropertyNames()
      Returns ALL property names from this Configuration's parents and this Configuration. As usual, parents are added first so they are overriden by children.
      Returns:
      Set of all String keys in this and parents
    • put

      public String put(String key, String value)
      Specified by:
      put in interface Map<String,String>
    • size

      public int size()
      Specified by:
      size in interface Map<String,String>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<String,String>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<String,String>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<String,String>
    • get

      public String get(Object key)
      Specified by:
      get in interface Map<String,String>
    • remove

      public String remove(Object key)
      Specified by:
      remove in interface Map<String,String>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<String,String>
    • keySet

      public Set<String> keySet()
      Specified by:
      keySet in interface Map<String,String>
    • values

      public Collection<String> values()
      Specified by:
      values in interface Map<String,String>
    • entrySet

      public Set<Map.Entry<String,String>> entrySet()
      Specified by:
      entrySet in interface Map<String,String>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getKeys

      public Set<Configuration.StringKeyMatcher> getKeys(Pattern pattern)
      Obtain a set of all keys (and parent's keys) that match the given pattern. If no keys match, then an empty set is returned. Use this instead of the stringPropertyNames()
      Parameters:
      pattern -
      Returns: