org.eclipse.ocl
Class LazyExtentMap<CLS,E>

java.lang.Object
  extended by org.eclipse.ocl.LazyExtentMap<CLS,E>
All Implemented Interfaces:
java.util.Map<CLS,java.util.Set<E>>

public abstract class LazyExtentMap<CLS,E>
extends java.lang.Object
implements java.util.Map<CLS,java.util.Set<E>>

A self-populating map that lazily creates the extent of a class when asked for it.

Note that this implementation violates the contract of the Map API as follows:

In practice, this does not matter because this map is only used for providing class extents to the OCL engine, and it only does look-up by key. Moreover, this isn't strictly a violation of any contract because there is no way to distinguish this behaviour from concurrent updates.

See the Environment class for a description of the generic type parameters of this class.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
LazyExtentMap(EObject context)
          Initializes me with the context element of an OCL expression evaluation.
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set<java.util.Map.Entry<CLS,java.util.Set<E>>> entrySet()
           
 boolean equals(java.lang.Object obj)
           
 java.util.Set<E> get(java.lang.Object key)
          Lazily computes the extent of the specified class key.
 int hashCode()
           
 boolean isEmpty()
           
protected abstract  boolean isInstance(CLS cls, E element)
          Implemented by subclasses to determine whether the specified element is an instance of the specified class, according to the metamodel semantics implemented by the environment that created this extent map.
 java.util.Set<CLS> keySet()
           
 java.util.Set<E> put(CLS key, java.util.Set<E> value)
           
 void putAll(java.util.Map<? extends CLS,? extends java.util.Set<E>> t)
           
 java.util.Set<E> remove(java.lang.Object key)
           
 int size()
           
 java.lang.String toString()
           
 java.util.Collection<java.util.Set<E>> values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LazyExtentMap

public LazyExtentMap(EObject context)
Initializes me with the context element of an OCL expression evaluation. I discover the scope of the model from this element.

Parameters:
context - my context element
Method Detail

get

public java.util.Set<E> get(java.lang.Object key)
Lazily computes the extent of the specified class key.

Specified by:
get in interface java.util.Map<CLS,java.util.Set<E>>
Parameters:
key - a class in the model

isInstance

protected abstract boolean isInstance(CLS cls,
                                      E element)
Implemented by subclasses to determine whether the specified element is an instance of the specified class, according to the metamodel semantics implemented by the environment that created this extent map.

Parameters:
cls - a class in the model
element - a potential run-time (M0) instance of that class
Returns:
true if this element is an instance of the given class; false otherwise

clear

public void clear()
Specified by:
clear in interface java.util.Map<CLS,java.util.Set<E>>

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<CLS,java.util.Set<E>>

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map<CLS,java.util.Set<E>>

entrySet

public java.util.Set<java.util.Map.Entry<CLS,java.util.Set<E>>> entrySet()
Specified by:
entrySet in interface java.util.Map<CLS,java.util.Set<E>>

equals

public boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Map<CLS,java.util.Set<E>>
Overrides:
equals in class java.lang.Object

hashCode

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

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<CLS,java.util.Set<E>>

keySet

public java.util.Set<CLS> keySet()
Specified by:
keySet in interface java.util.Map<CLS,java.util.Set<E>>

put

public java.util.Set<E> put(CLS key,
                            java.util.Set<E> value)
Specified by:
put in interface java.util.Map<CLS,java.util.Set<E>>

putAll

public void putAll(java.util.Map<? extends CLS,? extends java.util.Set<E>> t)
Specified by:
putAll in interface java.util.Map<CLS,java.util.Set<E>>

remove

public java.util.Set<E> remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<CLS,java.util.Set<E>>

size

public int size()
Specified by:
size in interface java.util.Map<CLS,java.util.Set<E>>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

values

public java.util.Collection<java.util.Set<E>> values()
Specified by:
values in interface java.util.Map<CLS,java.util.Set<E>>

Copyright 2002, 2007 IBM Corporation and others.
All Rights Reserved.