ikrs.util
Interface Environment<K,V>

All Superinterfaces:
java.util.Map<K,V>
All Known Subinterfaces:
Session<K,V,U>
All Known Implementing Classes:
AbstractSession, DefaultEnvironment, DefaultSession, EnvironmentDelegation

public interface Environment<K,V>
extends java.util.Map<K,V>

The Environment interface prepares a data structure for nested data environments. The full environment will be a tree like structure with a base environment in the root.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Method Summary
 boolean allowsMultipleChildNames()
          This method indicates if the environment allows multiple names for child environments.
 Environment<K,V> createChild(java.lang.String name)
          This method creates a new child environment and returns it.
 java.util.List<Environment<K,V>> getAllChildren()
          This method simply returns a list containing _all_ children.
 Environment<K,V> getChild(java.lang.String name)
          Get the child environment with the given name; there might be different children with the same name! The method will return the first match then.
 int getChildCount()
          This method returns the number of all children.
 java.util.List<Environment<K,V>> getChildren(java.lang.String name)
          Get *all* children with the given name.
 Environment<K,V> getParent()
          Get the environments parent.
 Environment<K,V> locateChild(Path<java.lang.String> path)
          Locate a child in the environment tree structure.
 void removeAllChildren()
          This method simply removes all children from this environment.
 Environment<K,V> removeChild(java.lang.String name)
          This method removes the child with the given name and returns its old value.
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Method Detail

allowsMultipleChildNames

boolean allowsMultipleChildNames()
This method indicates if the environment allows multiple names for child environments. If this method returns false the method createChild MUST NOT create a new child if there already exists a child with that name.


getParent

Environment<K,V> getParent()
Get the environments parent. If there is no parent the method will return null. Only the root environment has not parent. *


getChild

Environment<K,V> getChild(java.lang.String name)
Get the child environment with the given name; there might be different children with the same name! The method will return the first match then. If no such child exists the method returns null.

Parameters:
name - The child's name (if the child search is case sensitive depends on the actual implementation).
See Also:
DefaultEnvironment

locateChild

Environment<K,V> locateChild(Path<java.lang.String> path)
Locate a child in the environment tree structure. If the environment has multiple children with the same name (if allowed; see allowsMultipleChildNames()) the method returns the child at the most left path (first child in subset). If the path is empty the method returns this environment itself. If a path element cannot be found in the child subsets the method returns null.

Parameters:
path - The path that determines the desired child environment.
Returns:
The child environment that is located at the given path or null if the path is invalid in the environment tree.

getAllChildren

java.util.List<Environment<K,V>> getAllChildren()
This method simply returns a list containing _all_ children.


getChildren

java.util.List<Environment<K,V>> getChildren(java.lang.String name)
Get *all* children with the given name.

Parameters:
name - The child's name (if the child search is case sensitive depends on the actual implementation).
See Also:
DefaultEnvironment

createChild

Environment<K,V> createChild(java.lang.String name)
This method creates a new child environment and returns it. Note A: if allowsMultipleChildNames() returns true, this method always creates a new child. Note B: if allowsMultipleChildNames() returns false, and if a child with the given name already exists there will be no modifications to the environment. In this case the method returns the old child.

Parameters:
name - The child's name.

removeChild

Environment<K,V> removeChild(java.lang.String name)
This method removes the child with the given name and returns its old value. If no such child can be found the method returns null. *

Parameters:
name - The child's name.

removeAllChildren

void removeAllChildren()
This method simply removes all children from this environment. It is not a deep routine, so the inner data of child-environments themselves will not be affected.


getChildCount

int getChildCount()
This method returns the number of all children.