Package jsyntaxpane.util
Class Configuration
- java.lang.Object
-
- jsyntaxpane.util.Configuration
-
- All Implemented Interfaces:
java.util.Map<java.lang.String,java.lang.String>
public class Configuration extends java.lang.Object implements java.util.Map<java.lang.String,java.lang.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConfiguration.StringKeyMatcherUtility class to hold data forgetKeys(java.util.regex.Pattern)method.
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.PatternCOMMA_SEPARATORstatic java.lang.String[]EMPTY_LIST
-
Constructor Summary
Constructors Constructor Description Configuration(java.lang.Class theClass)Creates an empty ConfigurationConfiguration(java.lang.Class theClass, Configuration parent)Creates a new COnfiguration that uses parent as its parent Configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object value)java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>>entrySet()java.lang.Stringget(java.lang.Object key)booleangetBoolean(java.lang.String key, boolean Default)Returns a boolean from the configurationjava.awt.ColorgetColor(java.lang.String key, java.awt.Color Default)return the Color that has the given key or the DefaultintgetInteger(java.lang.String key, int Default)Gets an integer from the properties.java.util.Set<Configuration.StringKeyMatcher>getKeys(java.util.regex.Pattern pattern)Obtain a set of all keys (and parent's keys) that match the given pattern.java.lang.String[]getPropertyList(java.lang.String key)Returns a String[] of the comma separated items in the value.java.lang.StringgetString(java.lang.String key)Get a string from this object or one of its parents.java.lang.StringgetString(java.lang.String key, java.lang.String defaultValue)Returns a non-null value either by traversing the current and parent(s) map, or returning the defaultValuebooleanisEmpty()java.util.Set<java.lang.String>keySet()java.lang.Stringput(java.lang.String key, java.lang.String value)voidputAll(java.util.Map config)java.lang.Stringremove(java.lang.Object key)intsize()java.util.Set<java.lang.String>stringPropertyNames()Returns ALL property names from this Configuration's parents and this Configuration.java.lang.StringtoString()java.util.Collection<java.lang.String>values()
-
-
-
Constructor Detail
-
Configuration
public Configuration(java.lang.Class theClass, Configuration parent)Creates a new COnfiguration that uses parent as its parent Configuration.- Parameters:
theClass-parent-
-
Configuration
public Configuration(java.lang.Class theClass)
Creates an empty Configuration- Parameters:
theClass-
-
-
Method Detail
-
getString
public java.lang.String getString(java.lang.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_pathwill be replaced by the name of the Configuration (usually ClassName) with "." replaced by "/", and then converted to all lowercase is replaced by class.SimpleNameclass_simpleName- Parameters:
key-- Returns:
-
getString
public java.lang.String getString(java.lang.String key, java.lang.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:
java.lang.NullPointerException- if defaultValue is null
-
getInteger
public int getInteger(java.lang.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 java.lang.String[] getPropertyList(java.lang.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(java.lang.String key, boolean Default)Returns a boolean from the configuration- Parameters:
key-Default-- Returns:
-
getColor
public java.awt.Color getColor(java.lang.String key, java.awt.Color Default)return the Color that has the given key or the Default- Parameters:
key-Default-- Returns:
-
putAll
public void putAll(java.util.Map config)
- Specified by:
putAllin interfacejava.util.Map<java.lang.String,java.lang.String>
-
stringPropertyNames
public java.util.Set<java.lang.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 java.lang.String put(java.lang.String key, java.lang.String value)- Specified by:
putin interfacejava.util.Map<java.lang.String,java.lang.String>
-
size
public int size()
- Specified by:
sizein interfacejava.util.Map<java.lang.String,java.lang.String>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Map<java.lang.String,java.lang.String>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKeyin interfacejava.util.Map<java.lang.String,java.lang.String>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValuein interfacejava.util.Map<java.lang.String,java.lang.String>
-
get
public java.lang.String get(java.lang.Object key)
- Specified by:
getin interfacejava.util.Map<java.lang.String,java.lang.String>
-
remove
public java.lang.String remove(java.lang.Object key)
- Specified by:
removein interfacejava.util.Map<java.lang.String,java.lang.String>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Map<java.lang.String,java.lang.String>
-
keySet
public java.util.Set<java.lang.String> keySet()
- Specified by:
keySetin interfacejava.util.Map<java.lang.String,java.lang.String>
-
values
public java.util.Collection<java.lang.String> values()
- Specified by:
valuesin interfacejava.util.Map<java.lang.String,java.lang.String>
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
- Specified by:
entrySetin interfacejava.util.Map<java.lang.String,java.lang.String>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getKeys
public java.util.Set<Configuration.StringKeyMatcher> getKeys(java.util.regex.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 thestringPropertyNames()- Parameters:
pattern-- Returns:
-
-