com.darwinsys.util
Class VariableMap
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<java.lang.String,java.lang.String>
com.darwinsys.util.VariableMap
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.String>
public class VariableMap
- extends java.util.HashMap<java.lang.String,java.lang.String>
A HashMap with Variable substitution, using ${key} syntax.
VariableMap both holds variables and performs substitution
on a string using all held variables matched by ${varName}.
Supports java.beans PropertyChange notification so other parts
of an application can be notified of any variable values that change.
- See Also:
- Serialized Form
Method Summary |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
|
int |
getIntVar(java.lang.String key)
|
int |
getIntVar(java.lang.String key,
int defaultValue)
|
java.lang.String |
getVar(java.lang.String key)
|
java.lang.String |
getVar(java.lang.String key,
java.lang.String defaultValue)
|
java.lang.String |
put(java.lang.String key,
java.lang.String value)
Minimal property change notification |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener liszt)
|
void |
setIntVar(java.lang.String key,
int value)
|
void |
setVar(java.lang.String key,
java.lang.String value)
|
java.lang.String |
substVars(java.lang.String inString)
Substitute all variables in a given string; does not change
the contents of this Map in any way. |
Methods inherited from class java.util.HashMap |
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
VariableMap
public VariableMap()
VariableMap
public VariableMap(int initialCapacity,
float loadFactor)
VariableMap
public VariableMap(int initialCapacity)
VariableMap
public VariableMap(java.util.Map<java.lang.String,java.lang.String> m)
setVar
public void setVar(java.lang.String key,
java.lang.String value)
getVar
public java.lang.String getVar(java.lang.String key)
setIntVar
public void setIntVar(java.lang.String key,
int value)
getVar
public java.lang.String getVar(java.lang.String key,
java.lang.String defaultValue)
getIntVar
public int getIntVar(java.lang.String key)
getIntVar
public int getIntVar(java.lang.String key,
int defaultValue)
substVars
public java.lang.String substVars(java.lang.String inString)
- Substitute all variables in a given string; does not change
the contents of this Map in any way.
Note that the input string MUST NOT contain \ or $ characters (except
in the variable substitution context) unless you
really understand what you're doing.
Example input: lookFor(${USER})
If USER variable in map contains PIE, the result will be
lookFor(PIE).
- Parameters:
inString
-
- Returns:
- The string after substitution
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener liszt)
put
public java.lang.String put(java.lang.String key,
java.lang.String value)
- Minimal property change notification
- Specified by:
put
in interface java.util.Map<java.lang.String,java.lang.String>
- Overrides:
put
in class java.util.HashMap<java.lang.String,java.lang.String>
- See Also:
HashMap.put(java.lang.Object, java.lang.Object)
Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.