jasi.sim.basic.element
Class ElementAdapter

java.lang.Object
  extended by jasi.sim.basic.element.ElementAdapter

public final class ElementAdapter
extends java.lang.Object

Basic implementation of methods and behavior for all simulation elements. This class can be used, when simulation can not extend the class ElementBean

See Also:
AbstractElementBean

Constructor Summary
ElementAdapter()
          Construct a simulation element.
ElementAdapter(Element element, Id id)
          Construct a simulation element.
 
Method Summary
 Element acceptDelete(Element element)
          Delete that simulation element.
 int compareTo(Element element, Element e)
          Compares that object with the specified object for order.
 Elements elements()
          Get the listener for property changes and element manager of this element.
 boolean equals(Element element, java.lang.Object o)
          Indicates whether some other object is "equal to" that element.
<T> T
get(Element element, java.lang.String property, T value)
          Inform this element's listener about a property request.
 Id getId()
          Retrieve the element's ID.
 SimValue getKey()
          Returns this simulation element external key.
 int hashCode(Element element)
          Returns a hash code value for the object.
 boolean isDeleted()
          Check the existence of this element.
<T> boolean
set(Element element, java.lang.String property, T value)
          Inform that element's listener about a property change.
 void setElements(Elements elements)
          Set the listener for property changes and element manager of this element.
 void setId(Element element, Id id)
          Set the element's ID.
 void setKey(Element element, SimValue key)
          Set this simulation element external key.
 java.lang.String toString(Element element)
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementAdapter

public ElementAdapter()
Construct a simulation element.


ElementAdapter

public ElementAdapter(Element element,
                      Id id)
Construct a simulation element.

Parameters:
element - That element.
id - The simulation element's ID.
Method Detail

acceptDelete

public Element acceptDelete(Element element)
                     throws ElementAlreadyDeletedException
Delete that simulation element. This method should be called, when it is correct to delete this element. This element will be removed from the list of all simulation elements.

Parameters:
element - The simulation element.
Returns:
The deleted simulation element.
Throws:
ElementAlreadyDeletedException - The element has already been deleted previously.

setElements

public void setElements(Elements elements)
Set the listener for property changes and element manager of this element.

Parameters:
elements - The property change listener and element manager.

elements

public Elements elements()
Get the listener for property changes and element manager of this element.

Returns:
The property change listener and element manager.

set

public <T> boolean set(Element element,
                       java.lang.String property,
                       T value)
Inform that element's listener about a property change.

Type Parameters:
T - The value type.
Parameters:
element - That element.
property - The property that has changed.
value - The new value of that property.
Returns:
True, if it is allowed to change this property.

get

public <T> T get(Element element,
                 java.lang.String property,
                 T value)
Inform this element's listener about a property request.

Type Parameters:
T - The property type.
Parameters:
element - That element.
property - The property that was requested.
value - The value of that property.
Returns:
True, if it is allowed to read this property.

hashCode

public int hashCode(Element element)
Returns a hash code value for the object. This method is supported for the benefit of hash tables.

Parameters:
element - That element.
Returns:
A hash code value for this object.

equals

public boolean equals(Element element,
                      java.lang.Object o)
Indicates whether some other object is "equal to" that element. This method compares the events' time, priority and ID.

Parameters:
element - That element.
o - That object which is compared with this object.
Returns:
True, if this object is the same as that object.

compareTo

public int compareTo(Element element,
                     Element e)
Compares that object with the specified object for order. Implementation of Comparable interface. The elements are compared in the order of their IDs.

Parameters:
element - That element.
e - The element to be compared.
Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

toString

public java.lang.String toString(Element element)
Returns a string representation of this object.

Parameters:
element - That element.
Returns:
The string.

isDeleted

public boolean isDeleted()
Check the existence of this element. This method returns true, if the delete-method has been invoked before.

Returns:
True, if element has been deleted.

setKey

public void setKey(Element element,
                   SimValue key)
Set this simulation element external key. The external key will not change, if already set before. It is used as marker for this simulation element when communicating with external components.

Parameters:
element - That element.
key - The external key.
Throws:
java.lang.IllegalStateException - Whenever key is already set.

getKey

public SimValue getKey()
Returns this simulation element external key.

Returns:
The external key. This method returns null, when key is not set previously.

setId

public void setId(Element element,
                  Id id)
Set the element's ID. Each simulation element obtains during its registration a unique, increasing number for identification. If ID is already set, it will not be changed.

Parameters:
element - That element.
id - The ID.

getId

public Id getId()
Retrieve the element's ID. Each simulation element obtains during its registration a unique, increasing number for identification.

Returns:
The ID. This method returns null, when ID is not set previously.