com.guiseframework.platform
Class AbstractEnvironment

java.lang.Object
  extended by com.guiseframework.platform.AbstractEnvironment
All Implemented Interfaces:
Environment
Direct Known Subclasses:
DefaultEnvironment

public class AbstractEnvironment
extends java.lang.Object
implements Environment

An abstract implementation of the platform user local environment.

Author:
Garret Wilson

Constructor Summary
AbstractEnvironment()
           
 
Method Summary
 java.util.Map<java.lang.String,java.lang.Object> getProperties()
          Returns the available environment properties as a read-only map of property names and values.
<T> T
getProperty(java.lang.String name)
          Retrieves an environment property by its name.
<T> T
getProperty(java.lang.String name, T defaultValue)
          Retrieves an environment property by its name, returning a default value if no value is available.
<T> T
getRequiredProperty(java.lang.String name)
          Retrieves a required environment property by its name, throwing an exception if the value is missing.
 boolean hasProperty(java.lang.String name)
          Determines if an environment property exists.
 void removeProperty(java.lang.String name)
          Removes the property specified by the given name.
 void setProperties(java.util.Map<java.lang.String,java.lang.Object> map)
          Sets multiple environment properties.
 void setProperty(java.lang.String name, java.lang.Object value)
          Sets an environment property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractEnvironment

public AbstractEnvironment()
Method Detail

hasProperty

public boolean hasProperty(java.lang.String name)
Determines if an environment property exists.

Specified by:
hasProperty in interface Environment
Parameters:
name - The name of the property to check.
Returns:
true if the environment has the given property.

getProperty

public <T> T getProperty(java.lang.String name)
Retrieves an environment property by its name. A ClassCastException will eventually be thrown if the given value is not the generic type requested.

Specified by:
getProperty in interface Environment
Type Parameters:
T - The type of property value expected.
Parameters:
name - The name of the property to retrieve.
Returns:
The property value, or null if there is no such property.

getProperty

public <T> T getProperty(java.lang.String name,
                         T defaultValue)
Retrieves an environment property by its name, returning a default value if no value is available. A ClassCastException will eventually be thrown if the given value is not the generic type requested.

Specified by:
getProperty in interface Environment
Type Parameters:
T - The type of property value expected.
Parameters:
name - The name of the property to retrieve.
defaultValue - The value to return if no such property is available, or null if there is no default value.
Returns:
The property value, or the provided default value if there is no such property.

getRequiredProperty

public <T> T getRequiredProperty(java.lang.String name)
Retrieves a required environment property by its name, throwing an exception if the value is missing. A ClassCastException will eventually be thrown if the given value is not the generic type requested.

Specified by:
getRequiredProperty in interface Environment
Type Parameters:
T - The type of property value expected.
Parameters:
name - The name of the property to retrieve.
Returns:
The property value.
Throws:
java.lang.IllegalStateException - if no such property exists.

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Sets an environment property.

Specified by:
setProperty in interface Environment
Parameters:
name - The name of the property.
value - The value to associate with the name.
Throws:
java.lang.IllegalArgumentException - if the given property cannot be set to the given value or cannot be changed.

setProperties

public void setProperties(java.util.Map<java.lang.String,java.lang.Object> map)
Sets multiple environment properties.

Specified by:
setProperties in interface Environment
Parameters:
map - The map of property names and values to set.
Throws:
java.lang.IllegalArgumentException - if the given property cannot be set to the given value or cannot be changed.

removeProperty

public void removeProperty(java.lang.String name)
Removes the property specified by the given name.

Specified by:
removeProperty in interface Environment
Parameters:
name - The name of the property to remove.
Throws:
java.lang.IllegalArgumentException - if the given property cannot be removed.

getProperties

public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Returns the available environment properties as a read-only map of property names and values.

Specified by:
getProperties in interface Environment
Returns:
The available environment properties.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.