de.hunsicker.jalopy.storage
Class Environment

java.lang.Object
  |
  +--de.hunsicker.jalopy.storage.Environment

public final class Environment
extends java.lang.Object

Provides access to global and local environment variables (key/value pairs).

This class is thread-safe.

Since:
1.0b8
Version:
$Revision: 1.3.2.6 $
Author:
Marco Hunsicker

Nested Class Summary
static class Environment.Variable
          Represents a local environment variable.
 
Method Summary
 Environment copy()
          Returns a copy of this object.
static Environment getInstance()
          Returns an instance of this class.
 java.lang.String interpolate(java.lang.String str)
          Performs variable interpolation for the given input string.
 void set(java.lang.String variable, java.lang.Object value)
          Sets the given variable to the given value.
 java.lang.String toString()
          Returns a string representation of this object.
 void unset(java.lang.String variable)
          Unsets (removes) the given variable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static Environment getInstance()
Returns an instance of this class. This method is guarantueed to return a unique instance for each thread that invokes it.

Returns:
An instance of this class.

copy

public Environment copy()
Returns a copy of this object.

Returns:
a copy of this object.

interpolate

public java.lang.String interpolate(java.lang.String str)
Performs variable interpolation for the given input string. All environment variable expressions (\$[a-zA-Z_][a-zA-Z0-9_.]+\$, e.g. $fileName$ or $author$) in the given string are replaced with their corresponding environment value.

Parameters:
str - string to perform variable interpolation for.
Returns:
The input str with all variables interpolated.
See Also:
set(java.lang.String, java.lang.Object)

set

public void set(java.lang.String variable,
                java.lang.Object value)
Sets the given variable to the given value.

Parameters:
variable - variable name. Valid variable names have the form [a-zA-Z_][a-zA-Z0-9_.]+
value - value to associate.
See Also:
unset(java.lang.String)

toString

public java.lang.String toString()
Returns a string representation of this object. The string representation consists of a list of key-value mappings in no particular order.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this object.

unset

public void unset(java.lang.String variable)
Unsets (removes) the given variable

Parameters:
variable - variable name.
See Also:
set(java.lang.String, java.lang.Object)


Copyright © 1997-2005 Jalopy. All Rights Reserved.