com.googlecode.sarasvati.impl
Class NestedEnv

java.lang.Object
  extended by com.googlecode.sarasvati.impl.NestedEnv
All Implemented Interfaces:
Env, ReadEnv

public class NestedEnv
extends Object
implements Env


Constructor Summary
NestedEnv(Env outerEnv, Env innerEnv)
           
 
Method Summary
 String getAttribute(String name)
          Gets an attribute as a String.
<T> T
getAttribute(String name, Class<T> type)
          Returns the given attribute, transformed into the given type.
<T> T
getAttribute(String name, Class<T> type, T defaultValue)
          Returns the given attribute, transformed into the given type.
 Iterable<String> getAttributeNames()
          Returns an Iterable of attribute names.
 Object getTransientAttribute(String name)
          Returns the value associated with the given named transient attribute.
 Iterable<String> getTransientAttributeNames()
          Returns an Iterable of transient attribute names.
 boolean hasAttribute(String name)
          Checks if the given attribute is present.
 boolean hasTransientAttribute(String name)
          Returns true if this transient attribute exists in the environment and false otherwise.
 void importEnv(Env env)
          Imports the given env into the outer env
 void removeAttribute(String name)
          Unsets any attribute with the given name.
 void removeTransientAttribute(String name)
          Remove the given attribute from the environment.
 void setAttribute(String name, Object value)
          Sets the attribute of the given name to the given value.
 void setAttribute(String name, String value)
          Sets the attribute of the given name to the given string value.
 void setTransientAttribute(String name, Object value)
          Set a transient attribute of the environment.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NestedEnv

public NestedEnv(Env outerEnv,
                 Env innerEnv)
Method Detail

getAttributeNames

public Iterable<String> getAttributeNames()
Description copied from interface: ReadEnv
Returns an Iterable of attribute names.

Specified by:
getAttributeNames in interface ReadEnv
Returns:
Iterable of attribute names

getAttribute

public String getAttribute(String name)
Description copied from interface: ReadEnv
Gets an attribute as a String. If there is no value set for the attribute, null will be returned.

Specified by:
getAttribute in interface ReadEnv
Parameters:
name - The name of the attribute to get
Returns:
The value of attribute or null if no value is set for the attribute.

getAttribute

public <T> T getAttribute(String name,
                          Class<T> type)
Description copied from interface: ReadEnv
Returns the given attribute, transformed into the given type.

Specified by:
getAttribute in interface ReadEnv
Type Parameters:
T - The type which the attribute should be returned as.
Parameters:
name - The name of the attribute to get.
type - The class type which the attribute should be transformed to.
Returns:
The attribute value, or null if no value is set for the attribute.

getAttribute

public <T> T getAttribute(String name,
                          Class<T> type,
                          T defaultValue)
Description copied from interface: ReadEnv
Returns the given attribute, transformed into the given type. If no value is set, return the given default.

Specified by:
getAttribute in interface ReadEnv
Type Parameters:
T - The type which the attribute should be returned as.
Parameters:
name - The name of the attribute to get.
type - The class type which the attribute should be transformed to.
defaultValue - The value to return if no value is set.
Returns:
The attribute value, or null if no value is set for the attribute.

hasAttribute

public boolean hasAttribute(String name)
Description copied from interface: ReadEnv
Checks if the given attribute is present.

Specified by:
hasAttribute in interface ReadEnv
Parameters:
name - Name of the attribute to check for
Returns:
True if the given attribute is present, false otherwise.

removeAttribute

public void removeAttribute(String name)
Description copied from interface: Env
Unsets any attribute with the given name.

Specified by:
removeAttribute in interface Env
Parameters:
name - The name of the attribute to remove

setAttribute

public void setAttribute(String name,
                         String value)
Description copied from interface: Env
Sets the attribute of the given name to the given string value.

Specified by:
setAttribute in interface Env
Parameters:
name - The name of the attribute to set.
value - The value to set the attribute to

setAttribute

public void setAttribute(String name,
                         Object value)
Description copied from interface: Env
Sets the attribute of the given name to the given value.

Specified by:
setAttribute in interface Env
Parameters:
name - The name of the attribute to set.
value - The value to set the attribute to

setTransientAttribute

public void setTransientAttribute(String name,
                                  Object value)
Description copied from interface: Env
Set a transient attribute of the environment. The attribute will only be in the environment as long as the associated GraphProcess or NodeToken instance is in memory. In other words, these attributes will not be persisted to whatever the backing store is.
If a transient value already existed for the given name, the value will be overwritten
In the case of a memory back implementation, these transient attributes will have the same lifetime as other attributes.

Specified by:
setTransientAttribute in interface Env
Parameters:
name - The name of the attribute
value - The value of the attribute

hasTransientAttribute

public boolean hasTransientAttribute(String name)
Description copied from interface: Env
Returns true if this transient attribute exists in the environment and false otherwise.

Specified by:
hasTransientAttribute in interface Env
Parameters:
name - The transient attribute name
Returns:
True if the given transient attribute exists in this environment

getTransientAttribute

public Object getTransientAttribute(String name)
Description copied from interface: Env
Returns the value associated with the given named transient attribute.

Specified by:
getTransientAttribute in interface Env
Parameters:
name - The attribute name
Returns:
The attribute value, or null if a value has not been set.

removeTransientAttribute

public void removeTransientAttribute(String name)
Description copied from interface: Env
Remove the given attribute from the environment.

Specified by:
removeTransientAttribute in interface Env
Parameters:
name - The attribute name

getTransientAttributeNames

public Iterable<String> getTransientAttributeNames()
Description copied from interface: Env
Returns an Iterable of transient attribute names.

Specified by:
getTransientAttributeNames in interface Env
Returns:
Iterable of transient attribute names

importEnv

public void importEnv(Env env)
Imports the given env into the outer env

Specified by:
importEnv in interface Env
Parameters:
env - The environment to copy