All Packages Class Hierarchy This Package Previous Next Index
Class guinea.util.ExpandPath
java.lang.Object
|
+----guinea.util.ExpandPath
- public class ExpandPath
- extends Object
- implements ExpandPathHook
A class that expands variables in string as in UNIX-shell variable
expansion. It is for use for expanding file names but can be used
to expand any string also.
Objects may also registered as hooks to the path expander to add
new variables depending on context.
Variable Index
- ·
defVars
- Default variables for expansion.
- ·
undefinedVar
-
Constructor Index
- ·
ExpandPath()
- Construct a new variable expander.
- ·
ExpandPath(Dictionary)
- Construct a new variable expander.
Method Index
- ·
addExpandHook(ExpandPathHook)
- Add an expander hook.
- ·
callHooks(String, Dictionary)
- Look for a value for a variable in added hooks.
- ·
expand(String)
- Expand variables in string.
- ·
expand(String, Dictionary)
- Expand variables in string.
- ·
expand(String, Dictionary, ParsePosition, char)
- Expand string with variables.
- ·
expandVar(String, Dictionary)
- Expand variable as in zsh-shell variable expansion.
- ·
expandVariableValue(String, Dictionary, ExpandPath)
- Get value of a variable.
- ·
getNextChar(String, ParsePosition)
- Get next character from string.
- ·
getVarValue(String, Dictionary)
- Get value of a variable.
- ·
isEmpty(String)
- Test whether a string is empty.
- ·
main(String[])
-
- ·
removeExpandHook(ExpandPathHook)
- Remove an expander hook.
Variables
·
undefinedVar
public static final Object undefinedVar
·
defVars
protected Dictionary defVars
- Default variables for expansion.
Constructors
·
ExpandPath
public ExpandPath()
- Construct a new variable expander. No default variables are set.
·
ExpandPath
public ExpandPath(Dictionary vars)
- Construct a new variable expander.
- Parameters:
- vars - Default variables for expansion.
Methods
·
expand
public String expand(String path)
- Expand variables in string. Default variables are used as
expansion variables.
- Parameters:
- path - A string to expand.
- Returns:
- The path with variables in it expanded.
- See Also:
- defVars
·
expand
public String expand(String path,
Dictionary vars)
- Expand variables in string.
- Parameters:
- path - A string to expand.
- vars - Variables.
- Returns:
- The path with variables in it expanded.
·
expand
protected String expand(String path,
Dictionary vars,
ParsePosition pos,
char endChar)
- Expand string with variables.
- Parameters:
- path - String to process.
- vars - Variables used for substitution.
- pos - Current position on the path.
- endChar - Character that marks the end of current
variable block.
·
getVarValue
protected String getVarValue(String varName,
Dictionary vars)
- Get value of a variable. Looks for a value for the variable
in this order: calls expand hooks, look up variable in
vars, handles variables named HOME,
CWD, USER, looks for a value in system
properties.
- Parameters:
- varName - Name of variable.
- vars - A table of variable values.
- Returns:
- Get value of variable. If value not found, returns
null
.
- See Also:
- getProperty
·
expandVar
protected String expandVar(String varName,
Dictionary vars)
- Expand variable as in zsh-shell variable expansion.
- Parameters:
- varName - Variable name or a variable spec.
- vars - Variables.
- Returns:
- Expanded variable.
·
isEmpty
protected static final boolean isEmpty(String s)
- Test whether a string is empty.
- Parameters:
- s - String to test.
- Returns:
-
True
if s is null or the length of s is
zero. Otherwise returns false
.
·
getNextChar
protected char getNextChar(String str,
ParsePosition pos)
- Get next character from string. Current position is taken
from the pos parameter which is also incremented when
next character is taken.
- Parameters:
- str - A string where to get the current character.
- pos - Position of the current character.
- Returns:
- The character in the string at position
pos.
·
addExpandHook
public synchronized void addExpandHook(ExpandPathHook hook)
- Add an expander hook.
- Parameters:
- hook - A path expander hook.
·
removeExpandHook
public synchronized boolean removeExpandHook(ExpandPathHook hook)
- Remove an expander hook.
- Parameters:
- hook - A path expander hook.
- Returns:
-
True
if hook was included in this
expander's hook list, false
if not.
·
callHooks
protected String callHooks(String varName,
Dictionary vars)
- Look for a value for a variable in added hooks. Hooks are
called until a hook returns a value.
- Parameters:
- varName - Variable name.
- vars - Default variables.
- Returns:
- Value of variable or
null
if no value was
found.
·
expandVariableValue
public String expandVariableValue(String varName,
Dictionary vars,
ExpandPath expander)
- Get value of a variable. This is used to add another path
expander as a hook to another.
- Parameters:
- varName - A variable name to expand.
- vars - A dictionary of values.
- expander - The path expander object that called this
hook.
- Returns:
- A variable's value as a string or
null
if
variable has no value or is unknown to this hook object.
·
main
public static void main(String args[]) throws Exception
All Packages Class Hierarchy This Package Previous Next Index