jasi.sim.basic.element
Class AbstractElementBean

java.lang.Object
  extended by jasi.sim.basic.value.AbstractSimValueType
      extended by jasi.sim.basic.value.AbstractComparableObject<Element>
          extended by jasi.sim.basic.element.AbstractElementBean
All Implemented Interfaces:
Element, SimObject, ExtendedComparable<Element>, SimValue, java.io.Serializable, java.lang.Comparable<Element>
Direct Known Subclasses:
AbstractActivityBean, AirplaneHandler, BinaryRelationHandler, ComplexElementHandler, FlightHandler, MultiRelationHandler, SimpleMovingElementHandler

public abstract class AbstractElementBean
extends AbstractComparableObject<Element>
implements Element

Basic implementation of methods and behavior for all simulation elements.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface jasi.sim.basic.element.Element
COMPARATOR
 
Constructor Summary
protected AbstractElementBean()
          Construct a simulation element.
protected AbstractElementBean(Id id)
          Construct a simulation element for a given ID.
 
Method Summary
protected  Element acceptDelete()
          Delete this simulation element.
 int compareTo(Element e)
          Compares this object with the specified object for order.
 Element delete()
          Delete this simulation element from the simulation.
protected  Elements elements()
          Get the listener for property changes and element manager of this element.
 boolean equals(java.lang.Object o)
          Indicates whether some other object is "equal to" this one.
protected
<T> T
get(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()
          Returns a hash code value for the object.
 boolean isDeleted()
          Check the existence of this element.
 void registered(Elements elements)
          Set the listener for property changes and element manager of this element.
protected
<T> boolean
set(java.lang.String property, T value)
          Inform this element's listener about a property change.
 void setId(Id id)
          Set the element's ID.
 void setKey(SimValue key)
          Set this simulation element external key.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class jasi.sim.basic.value.AbstractComparableObject
isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class jasi.sim.basic.value.AbstractSimValueType
getContent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractElementBean

protected AbstractElementBean()
Construct a simulation element.


AbstractElementBean

protected AbstractElementBean(Id id)
Construct a simulation element for a given ID.

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

delete

public Element delete()
               throws DeleteNotSupportedException
Delete this simulation element from the simulation. All subclasses should either accept its deletion or throw an exception, if the deletion of this simulation element is not supported. The default implementation will throw an exception.

Specified by:
delete in interface Element
Returns:
The deleted simulation element.
Throws:
DeleteNotSupportedException - This simulation element can not be deleted.
See Also:
acceptDelete()

acceptDelete

protected final Element acceptDelete()
                              throws ElementAlreadyDeletedException
Delete this 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.

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

registered

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

Specified by:
registered in interface Element
Parameters:
elements - The property change listener and element manager.

elements

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

Returns:
The property change listener and element manager.

set

protected final <T> boolean set(java.lang.String property,
                                T value)
Inform this element's listener about a property change.

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

get

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

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

hashCode

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

Overrides:
hashCode in class java.lang.Object
Returns:
A hash code value for this object.

equals

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

Overrides:
equals in class java.lang.Object
Parameters:
o - That object which is compared with this object.
Returns:
True, if this object is the same as that object.

compareTo

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

Specified by:
compareTo in interface java.lang.Comparable<Element>
Specified by:
compareTo in class AbstractComparableObject<Element>
Parameters:
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.
See Also:
Comparable.compareTo(Object)

toString

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

Overrides:
toString in class java.lang.Object
Returns:
The string.

isDeleted

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

Specified by:
isDeleted in interface Element
Returns:
True, if element has been deleted.

setKey

public final void setKey(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.

Specified by:
setKey in interface Element
Parameters:
key - The external key.

getKey

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

Specified by:
getKey in interface Element
Returns:
The external key. This method returns null, when key is not set previously.

setId

public final void setId(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.

Specified by:
setId in interface SimObject
Parameters:
id - The ID.
Throws:
IdAlreadySetException - Whenever ID is already set.

getId

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

Specified by:
getId in interface SimObject
Returns:
The ID. This method returns null, when ID is not set previously.