clarion.system
Class DimensionValueCollection

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,Dimension>
              extended by clarion.system.DimensionValueCollection
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,Dimension>
Direct Known Subclasses:
AbstractChunk, GeneralizedConditionChunk

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

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

Usage:

This class represents the base collection for representing information in the CLARION Library. It is used and referenced heavily throughout the system. Contained within a dimension-value collection are dimension-value pairs.

A dimension-value collection can be used for any of the following:

Note that while we specify this class as containing "dimension-value pairs", it technically only contains dimension (which in turn contains values).

Known Subclasses:

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

Field Summary
private  int hash
          The hash for this object.
private static long serialVersionUID
           
 
Constructor Summary
DimensionValueCollection()
          Initializes a dimension-value collection.
DimensionValueCollection(java.util.Collection<? extends Dimension> dims)
          Initializes a dimension-value collection with the collection of dimensions specified.
DimensionValueCollection(java.util.Map<? extends java.lang.Object,? extends Dimension> map)
          Initializes the dimension-value collection with the map of dimensions.
 
Method Summary
 DimensionValueCollection clone()
          Clones the dimension-value collection (including all of it's dimensions).
 boolean containsKeys(java.lang.Object DVCollection)
          Checks to see if the specified object is a dimension-value collection and that all of the keys within the specified dimension-value collection are specified within this collection.
 boolean equals(java.lang.Object DVCollection)
          Checks to see if the specified object is a dimension-value collection and that all of the dimensions within the specified collection are equal to the dimensions in this collection.
 int getNumDVPairs()
          Gets the number of dimension-value pairs.
 java.util.Collection<Value> getValueCollection()
          Gets a collection containing all of the values within the dimension-value collection.
 int hashCode()
           
 Dimension put(java.lang.Object key, Dimension dim)
          Puts the dimension into the dimension-value collection as long as the dimension is not already in the dimension-value collection.
 void putAll(java.util.Map<? extends java.lang.Object,? extends Dimension> map)
          Puts all of the dimensions in the map into the dimension-value collection as long as the dimensions are not already in the dimension-value collection.
 int size()
          Returns the number of dimensions in the dimension-value collection.
 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

hash

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

Constructor Detail

DimensionValueCollection

public DimensionValueCollection()
Initializes a dimension-value collection.


DimensionValueCollection

public DimensionValueCollection(java.util.Collection<? extends Dimension> dims)
Initializes a dimension-value collection with the collection of dimensions specified.

Parameters:
dims - The dimensions for the collection.

DimensionValueCollection

public DimensionValueCollection(java.util.Map<? extends java.lang.Object,? extends Dimension> map)
Initializes the dimension-value collection with the map of dimensions.

Parameters:
map - The map of dimensions for the dimension-value collection.
Method Detail

getNumDVPairs

public int getNumDVPairs()
Gets the number of dimension-value pairs.

Returns:
The number of dimension-value pairs.

put

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

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

putAll

public void putAll(java.util.Map<? extends java.lang.Object,? extends Dimension> map)
Puts all of the dimensions in the map into the dimension-value collection as long as the dimensions are not already in the dimension-value collection. If the specified map extends from type AbstractChunk, this method will add the values from any dimensions within that chunk that are already in this collection to the appropriate dimension within this collection as long as the value is not already contained within that dimension.

Specified by:
putAll in interface java.util.Map<java.lang.Object,Dimension>
Overrides:
putAll in class java.util.HashMap<java.lang.Object,Dimension>
Parameters:
map - The map of dimensions to add.

equals

public boolean equals(java.lang.Object DVCollection)
Checks to see if the specified object is a dimension-value collection and that all of the dimensions within the specified collection are equal to the dimensions in this collection.

Specified by:
equals in interface java.util.Map<java.lang.Object,Dimension>
Overrides:
equals in class java.util.AbstractMap<java.lang.Object,Dimension>
Parameters:
DVCollection - The collection to compare to this collection.
Returns:
True if the two collections are equal, otherwise false.

containsKeys

public boolean containsKeys(java.lang.Object DVCollection)
Checks to see if the specified object is a dimension-value collection and that all of the keys within the specified dimension-value collection are specified within this collection.

Parameters:
DVCollection - The collection to compare to this collection.
Returns:
True if this collection contains all of the keys from the specified collection, otherwise false.

getValueCollection

public java.util.Collection<Value> getValueCollection()
Gets a collection containing all of the values within the dimension-value collection. The values in the collection returned will not be associated with any dimensions. Therefore this method should only be used if you intend on making changes to / accessing information from all values in the dimension-value collection regardless of their dimension.

Most often within the CLARION Library this method is used to deliver the values of a dimension-value collection in a vector format for the input layer of an implicit module.

Returns:
A collection containing all the values within the dimension-value collection.

hashCode

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

clone

public DimensionValueCollection clone()
Clones the dimension-value collection (including all of it's dimensions).

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

size

public int size()
Returns the number of dimensions in the dimension-value collection.

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

toString

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