com.googlecode.sarasvati.env
Interface ReadEnv

All Known Subinterfaces:
Env
All Known Implementing Classes:
MapEnv, NestedEnv, NestedReadEnv, TokenSetMemberEnvAdapter

public interface ReadEnv

A ReadEnv is a container for attributes that can be read but not changed. The attributes are likely all stored as strings, to allow simple database storage, but they may be retrieved as a specified type, if an AttributeConverter for that type has been registered (via AttributeConverters.setConverterForType(Class, AttributeConverter)).

Author:
Paul Lorenz

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.
 boolean hasAttribute(String name)
          Checks if the given attribute is present.
 

Method Detail

getAttribute

String getAttribute(String name)
Gets an attribute as a String. If there is no value set for the attribute, null will be returned.

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

<T> T getAttribute(String name,
                   Class<T> type)
Returns the given attribute, transformed into the given type.

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

<T> T getAttribute(String name,
                   Class<T> type,
                   T defaultValue)
Returns the given attribute, transformed into the given type. If no value is set, return the given default.

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

boolean hasAttribute(String name)
Checks if the given attribute is present.

Parameters:
name - Name of the attribute to check for
Returns:
True if the given attribute is present, false otherwise.

getAttributeNames

Iterable<String> getAttributeNames()
Returns an Iterable of attribute names.

Returns:
Iterable of attribute names