clarion.system
Class Dimension

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<java.lang.Object,Value>
              extended by clarion.system.Dimension
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,Value>

public final class Dimension
extends java.util.LinkedHashMap<java.lang.Object,Value>

This class implements a dimension within CLARION. It extends the LinkedHashMap class.

Usage:

A dimension is a somewhat meaningless thing unless it is filled with values. A coupling of a dimension and a value together is called a dimension-value pair and is the base unit in CLARION for representing information.

Examples of dimension-value pairs:

It is required that you specify a way of identifying the dimension (eg. name, number, etc) when you initialize this class. Once this ID has been set, it cannot be changed. This ID is used as the key for this dimension when it is placed inside a dimension-value collection.

Version:
6.0.4
Author:
Nick Wilson
See Also:
Serialized Form

Field Summary
private  int hash
          The hash for this object.
private  java.lang.Object ID
          Identifies the dimension.
private static long serialVersionUID
           
 
Constructor Summary
Dimension(java.lang.Object id)
          Initializes the dimension and sets the ID of the dimension to the ID specified.
Dimension(java.lang.Object id, java.util.Collection<? extends Value> vals)
          Initializes the dimension with the specified ID and collection of values.
Dimension(java.lang.Object id, java.util.Map<? extends java.lang.Object,? extends Value> map)
          Initializes the dimension with the specified ID and map of values.
 
Method Summary
 boolean checkMatchAll()
          Checks to see if all of the values in a specified dimension are activated.
 Dimension clone()
          Clones the dimension (including all of it's Values).
 boolean equals(java.lang.Object dim)
          Checks to see if the specified object is a dimension and if the ID of the specified dimension is the same as this dimension.
 boolean equalsID(java.lang.Object dim)
          Checks to see if the specified dimension has the same ID as this dimension.
 java.lang.Object getID()
          Gets the ID of this dimension.
 double getMaxActivation()
          Gets the activation level of the value with the highest activation in this dimension.
 int getNumActivatedVals()
          Gets the number of values in this dimension that are at least minimally activated.
 int getNumFullyActivatedVals()
          Gets the number of fully activated values in this dimension.
 int hashCode()
           
 Value put(java.lang.Object key, Value val)
          Puts the value in the dimension as long as the value is not already in the dimension.
 void putAll(java.util.Map<? extends java.lang.Object,? extends Value> map)
          Puts all of the values in the map into the dimension as long as the values are not already in the dimension.
 int size()
          Returns the number of values in the dimension.
 java.lang.String toString()
           
 
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, get, removeEldestEntry
 
Methods inherited from class java.util.HashMap
containsKey, entrySet, isEmpty, keySet, remove, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, entrySet, isEmpty, keySet, remove, values
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

ID

private java.lang.Object ID
Identifies the dimension. A name (in the form of a string) is simply one option for identifying a dimension.


hash

private int hash
The hash for this object. When this item is cloned, so is this hash.

Constructor Detail

Dimension

public Dimension(java.lang.Object id)
Initializes the dimension and sets the ID of the dimension to the ID specified.

Parameters:
id - The ID of the dimension.

Dimension

public Dimension(java.lang.Object id,
                 java.util.Collection<? extends Value> vals)
Initializes the dimension with the specified ID and collection of values.

Parameters:
id - The ID of the dimension.
vals - The values for the dimension.

Dimension

public Dimension(java.lang.Object id,
                 java.util.Map<? extends java.lang.Object,? extends Value> map)
Initializes the dimension with the specified ID and map of values.

Parameters:
id - The ID of the dimension.
map - The map of values for the dimension.
Method Detail

getID

public java.lang.Object getID()
Gets the ID of this dimension.

Returns:
The ID of this dimension.

getNumFullyActivatedVals

public int getNumFullyActivatedVals()
Gets the number of fully activated values in this dimension.

Returns:
The number of fully activated values in this dimension.

getNumActivatedVals

public int getNumActivatedVals()
Gets the number of values in this dimension that are at least minimally activated.

Returns:
The number of activated values in this dimension.

checkMatchAll

public boolean checkMatchAll()
Checks to see if all of the values in a specified dimension are activated.

Returns:
True if every value in the specified dimension is activated, otherwise false.

getMaxActivation

public double getMaxActivation()
Gets the activation level of the value with the highest activation in this dimension.

Returns:
The activation level of the value with the highest activation.

put

public Value put(java.lang.Object key,
                 Value val)
          throws java.lang.IllegalArgumentException
Puts the value in the dimension as long as the value is not already in the dimension. If the value is already in the dimension, this method throws an exception. If the specified key is not the ID of the specified value, this method throws an exception.

Specified by:
put in interface java.util.Map<java.lang.Object,Value>
Overrides:
put in class java.util.HashMap<java.lang.Object,Value>
Parameters:
key - The key with which the specified value is to be associated. This MUST be the ID of the specified value.
val - The value to add to the dimension.
Returns:
The result of putting the value in the dimension. This will always return null (meaning the value did not previously exist in the map). This is because you are not allowed to put a value in a dimension that already contains that value.
Throws:
java.lang.IllegalArgumentException - If the value is already in the dimension or the specified key is not the ID of the specified value.

putAll

public void putAll(java.util.Map<? extends java.lang.Object,? extends Value> map)
Puts all of the values in the map into the dimension as long as the values are not already in the dimension. If any values are already in the dimension, this method throws an exception. If any of the specified keys are not the ID of their respective value, this method throws an exception.

Specified by:
putAll in interface java.util.Map<java.lang.Object,Value>
Overrides:
putAll in class java.util.HashMap<java.lang.Object,Value>
Parameters:
map - The map of values to add.
Throws:
java.lang.IllegalArgumentException - If any values are already in the dimension or any of the specified keys are not the ID of their respective value.

equalsID

public boolean equalsID(java.lang.Object dim)
Checks to see if the specified dimension has the same ID as this dimension.

Parameters:
dim - The dimension whose ID you want to compare to this dimension's ID.
Returns:
True if the specified dimension has the same ID as this dimension, otherwise false.

equals

public boolean equals(java.lang.Object dim)
Checks to see if the specified object is a dimension and if the ID of the specified dimension is the same as this dimension. It also checks to make sure all of the values within the dimension are equal.

Specified by:
equals in interface java.util.Map<java.lang.Object,Value>
Overrides:
equals in class java.util.AbstractMap<java.lang.Object,Value>
Parameters:
dim - The object to compare to this dimension.
Returns:
True if the two dimensions are equal, otherwise false.

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map<java.lang.Object,Value>
Overrides:
hashCode in class java.util.AbstractMap<java.lang.Object,Value>

clone

public Dimension clone()
Clones the dimension (including all of it's Values).

Overrides:
clone in class java.util.HashMap<java.lang.Object,Value>
Returns:
A copy of the dimension.

size

public int size()
Returns the number of values in the dimension.

Specified by:
size in interface java.util.Map<java.lang.Object,Value>
Overrides:
size in class java.util.HashMap<java.lang.Object,Value>

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractMap<java.lang.Object,Value>