org.eclipse.ocl.examples.pivot
Class AbstractBasicEnvironment

java.lang.Object
  extended by org.eclipse.ocl.examples.pivot.AbstractBasicEnvironment
All Implemented Interfaces:
Adaptable, BasicEnvironment, Customizable
Direct Known Subclasses:
AbstractEnvironment

public abstract class AbstractBasicEnvironment
extends java.lang.Object
implements BasicEnvironment

Partial implementation of the BasicEnvironment interface, providing default behaviours for most features.

Since:
1.2

Constructor Summary
protected AbstractBasicEnvironment(BasicEnvironment parent)
          Initializes me with the specified parent environment, which should be of the same type as me.
 
Method Summary
protected  java.util.Map<Option<?>,java.lang.Object> basicGetOptions()
           
 java.util.Map<Option<?>,java.lang.Object> clearOptions()
          Clears all options.
<T> T
getAdapter(java.lang.Class<T> adapterType)
          The abstract environment implementation is adaptable.
 java.util.Map<Option<?>,java.lang.Object> getOptions()
          Obtains a copy of my map of options.
 BasicEnvironment getParent()
           
<T> T
getValue(Option<T> option)
          Obtains the value of the specified option's setting in the my options map.
 boolean isEnabled(Option<java.lang.Boolean> option)
          Queries whether the specified boolean-valued option is enabled.
<T> void
putOptions(java.util.Map<? extends Option<T>,? extends T> options)
          Adds options to apply to my behaviour.
<T> T
removeOption(Option<T> option)
          Removes the specified option.
<T> java.util.Map<Option<T>,T>
removeOptions(java.util.Collection<Option<T>> options)
          Removes the specified options.
<T> void
setOption(Option<T> option, T value)
          Add an option to apply to my behaviour.
protected  void setParent(BasicEnvironment parent)
          Assigns me a parent environment after construction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBasicEnvironment

protected AbstractBasicEnvironment(BasicEnvironment parent)
Initializes me with the specified parent environment, which should be of the same type as me.

Parameters:
parent - an environment of the same type as me (or null)
Method Detail

getAdapter

public <T> T getAdapter(java.lang.Class<T> adapterType)
The abstract environment implementation is adaptable. The default implementation adapts to and interface actually implemented by the receiver in addition to the ProblemHandler interface.

Subclasses may override or extend this implementation.

Specified by:
getAdapter in interface Adaptable
Type Parameters:
T - the requested adapter interface
Parameters:
adapterType - the requested adapter interface
Returns:
an instance of the requested interface, or null if this environment does not adapt to it

getParent

public BasicEnvironment getParent()

setParent

protected void setParent(BasicEnvironment parent)
Assigns me a parent environment after construction. It is not advisable to set the parent to null if I previously had one.

Parameters:
parent - my new parent

basicGetOptions

protected java.util.Map<Option<?>,java.lang.Object> basicGetOptions()

getOptions

public java.util.Map<Option<?>,java.lang.Object> getOptions()
Description copied from interface: Customizable
Obtains a copy of my map of options. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

Specified by:
getOptions in interface Customizable
Returns:
the map of options

setOption

public <T> void setOption(Option<T> option,
                          T value)
Description copied from interface: Customizable
Add an option to apply to my behaviour.

Specified by:
setOption in interface Customizable
Parameters:
option - the option
value - the option's value

putOptions

public <T> void putOptions(java.util.Map<? extends Option<T>,? extends T> options)
Description copied from interface: Customizable
Adds options to apply to my behaviour.

Specified by:
putOptions in interface Customizable
Parameters:
options - the options

removeOption

public <T> T removeOption(Option<T> option)
Description copied from interface: Customizable
Removes the specified option.

Specified by:
removeOption in interface Customizable
Parameters:
option - the option to remove
Returns:
the former value of the option

removeOptions

public <T> java.util.Map<Option<T>,T> removeOptions(java.util.Collection<Option<T>> options)
Description copied from interface: Customizable
Removes the specified options.

Specified by:
removeOptions in interface Customizable
Parameters:
options - the options to remove
Returns:
the former values of the options

clearOptions

public java.util.Map<Option<?>,java.lang.Object> clearOptions()
Description copied from interface: Customizable
Clears all options.

Specified by:
clearOptions in interface Customizable
Returns:
the former values of the options

isEnabled

public boolean isEnabled(Option<java.lang.Boolean> option)
Description copied from interface: Customizable
Queries whether the specified boolean-valued option is enabled. This method essentially just puts a nice "is" name on boolean options. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

Specified by:
isEnabled in interface Customizable
Parameters:
option - an option
Returns:
whether the option is enabled

getValue

public <T> T getValue(Option<T> option)
Description copied from interface: Customizable
Obtains the value of the specified option's setting in the my options map. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

Specified by:
getValue in interface Customizable
Parameters:
option - the option to query
Returns:
value of the option