JADE v6.1

com.dautelle.math.numbers
Class RealtimeNumber

java.lang.Object
  extended byjava.lang.Number
      extended bycom.dautelle.math.numbers.RealtimeNumber
All Implemented Interfaces:
Operable, Realtime, Representable, java.io.Serializable
Direct Known Subclasses:
Complex, Float32, Float64, Integer32, Integer64, LargeInteger, Quantity, Rational, Real

public abstract class RealtimeNumber
extends java.lang.Number
implements Operable, Realtime, Representable, java.io.Serializable

This class provides a default implementation of the Realtime interface for objects of type java.lang.Number.

Instances of this class should be created using a RealtimeNumber.Factory.

Instances of this class are immutable. But like any real-time object, instances allocated in a pool context must be exported if referenced after exiting the pool context.

Version:
6.0, February 1, 2004
Author:
Jean-Marie Dautelle
See Also:
Serialized Form

Nested Class Summary
protected static class RealtimeNumber.Factory
          This abstract class represents the factory responsible for the creation of RealtimeNumber instances.
 
Constructor Summary
protected RealtimeNumber()
          Default constructor.
 
Method Summary
protected  java.lang.Object clone()
          Overrides the clone method to ensure that the copy references the heap pool.
 java.lang.Object export()
          Exports this object out of the current pool context.
 boolean isLocalObject()
          Indicates if this object is an object local to the current pool context.
 boolean isPoolObject()
          Indicates if this object belongs to a pool (stack allocated object).
 Operable pow(int exp)
          Returns this Operable number raised at the specified exponent.
protected  void recycle()
          Recycles this object.
 java.lang.Object toHeap()
          Moves this object to the heap.
 
Methods inherited from class java.lang.Number
byteValue, doubleValue, floatValue, intValue, longValue, shortValue
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.dautelle.math.Operable
opposite, plus, reciprocal, times
 
Methods inherited from interface com.dautelle.xml.Representable
toXml
 

Constructor Detail

RealtimeNumber

protected RealtimeNumber()
Default constructor.

Method Detail

pow

public Operable pow(int exp)
Returns this Operable number raised at the specified exponent.

Parameters:
exp - the exponent.
Returns:
thisexp

isLocalObject

public final boolean isLocalObject()
Indicates if this object is an object local to the current pool context. Operations on local objects do not require synchronization as these objects are accessible to the current thread only.

Note: Due to the "export" rule, non-local objects cannot refer to local object.

Returns:
true if this object belongs to the current pool context; false otherwise.

isPoolObject

public final boolean isPoolObject()
Indicates if this object belongs to a pool (stack allocated object).

Note: Due to the "export" rule, heap objects cannot refer to pool object.

Returns:
true if this object belongs to a pool; false if this object belongs to the heap.

recycle

protected void recycle()
Recycles this object. This method should only be called when it can be asserted that this object is not going to be referenced anymore. This method affects only local objects and has no effect on heap objects or objects allocated outside of the current pool context. Recycling is limited to this object and its internal and has no effect on any shared member.


export

public java.lang.Object export()
Description copied from interface: Realtime
Exports this object out of the current pool context. Realtime members are exported as well (recursion). This method affects only objects belonging to the current pool context. To avoid pool depletion, a "free" object from the outer pool is moved to replace the object being exported.

Specified by:
export in interface Realtime
Returns:
this

toHeap

public java.lang.Object toHeap()
Description copied from interface: Realtime
Moves this object to the heap. Realtime members are moved to the heap as well (recursion). This method affects only objects belonging to a pool context (current or not).

Specified by:
toHeap in interface Realtime
Returns:
this

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Overrides the clone method to ensure that the copy references the heap pool.

Returns:
this object's clone allocated on the heap.
Throws:
java.lang.CloneNotSupportedException

JADE v6.1

Copyright © 2004 Jean-Marie Dautelle.