net.sourceforge.cilib.type.types
Class Real

java.lang.Object
  extended by net.sourceforge.cilib.type.types.Numeric
      extended by net.sourceforge.cilib.type.types.Real
All Implemented Interfaces:
Serializable, Comparable<Numeric>, BoundedType, Randomizable, Resetable, Type, Cloneable

public class Real
extends Numeric

Author:
Gary Pampara
See Also:
Serialized Form

Constructor Summary
Real()
          Create the instance with a random value.
Real(double value)
          Create the instance with the given value.
Real(double lower, double upper)
          Create the Real instance with the initial value which is random between lower and upper.
Real(Real copy)
          Copy construtor.
 
Method Summary
 int compareTo(Numeric other)
          
 boolean equals(Object other)
          Compare the specified object with this type for equality.
 boolean getBit()
          Get the value of this Numeric.
 Real getClone()
          Create a cloned copy of the current object and return it.
 int getInt()
          Get the value of this Numeric.
 double getReal()
          Get the value of this Numeric.
 String getRepresentation()
          Get the type representation of this Real object as a string.
 int hashCode()
          Returns the hash code value for this list.
 void randomize(Random random)
          Re-randomize the Real object based on the upper and lower bounds.
 void readExternal(ObjectInput ois)
          Read the Real from the provided ObjectInput.
 void reset()
          Set the value of the Real to a default value of 0.0.
 void set(boolean value)
          Set the value of the Numeric.
 void set(double value)
          Set the value of the Numeric.
 void set(int value)
          Set the value of the Numeric.
 void set(String value)
          Set the value of the Numeric.
 void setBit(boolean value)
          Set the bit value with the provided value.
 void setBit(String value)
          Set the bit value with the provided value.
 void setInt(int value)
          Set the integer value with the provided value.
 void setInt(String value)
          Set the integer value with the provided value.
 void setReal(double value)
          Set the real value with the provided value.
 void setReal(String value)
          Set the real value with the provided value.
 String toString()
          Return a String representation of the Real object.
 void writeExternal(ObjectOutput oos)
          Serialize the Real to the provided ObjectOutput.
 
Methods inherited from class net.sourceforge.cilib.type.types.Numeric
getBounds, setBounds, setBounds
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Real

public Real()
Create the instance with a random value.


Real

public Real(double value)
Create the instance with the given value.

Parameters:
value - The value of the Real.

Real

public Real(double lower,
            double upper)
Create the Real instance with the initial value which is random between lower and upper.

Parameters:
lower - The lower boundary for the random number.
upper - The upper boundary for the random number.

Real

public Real(Real copy)
Copy construtor.

Parameters:
copy - The instance to copy.
Method Detail

getClone

public Real getClone()
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface Type
Specified by:
getClone in interface Cloneable
Specified by:
getClone in class Numeric
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

equals

public boolean equals(Object other)
Compare the specified object with this type for equality. Returns true if and only if the specified object is also an instance of the same type.

Specified by:
equals in interface Type
Overrides:
equals in class Numeric
Parameters:
other - The object to compare.
Returns:
true if equality exists, false otherwise.
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:
  int hashCode = 7;
  Iterator<E> i = list.iterator();
  while (i.hasNext()) {
      E obj = i.next();
      hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
  }
 
This ensures that type1.equals(type2) implies that type1.hashCode()==type2.hashCode() for any two types, type1 and type2, as required by the general contract of Object.hashCode().

Specified by:
hashCode in interface Type
Overrides:
hashCode in class Numeric
Returns:
the hash code value for this list
See Also:
Object.equals(Object), Type.equals(Object)

set

public void set(String value)
Set the value of the Numeric.

Specified by:
set in class Numeric
Parameters:
value - The String value to be parsed.

set

public void set(boolean value)
Set the value of the Numeric.

Specified by:
set in class Numeric
Parameters:
value - The boolean value representing the value for this Type.

set

public void set(double value)
Set the value of the Numeric.

Specified by:
set in class Numeric
Parameters:
value - The double value representing the value for this Type.

set

public void set(int value)
Set the value of the Numeric.

Specified by:
set in class Numeric
Parameters:
value - The int value representing the value for this Type.

getBit

public boolean getBit()
Get the value of this Numeric.

Specified by:
getBit in class Numeric
Returns:
The value of this Numeric as a boolean.

setBit

public void setBit(boolean value)
Set the bit value with the provided value.

Specified by:
setBit in class Numeric
Parameters:
value - The value to set.

setBit

public void setBit(String value)
Set the bit value with the provided value.

Specified by:
setBit in class Numeric
Parameters:
value - The value to set.

getInt

public int getInt()
Get the value of this Numeric.

Specified by:
getInt in class Numeric
Returns:
The value of this Numeric as a int.

setInt

public void setInt(int value)
Set the integer value with the provided value.

Specified by:
setInt in class Numeric
Parameters:
value - The value to set.

setInt

public void setInt(String value)
Set the integer value with the provided value.

Specified by:
setInt in class Numeric
Parameters:
value - The value to set.

getReal

public double getReal()
Get the value of this Numeric.

Specified by:
getReal in class Numeric
Returns:
The value of this Numeric as a double.

setReal

public void setReal(double value)
Set the real value with the provided value.

Specified by:
setReal in class Numeric
Parameters:
value - The value to set.

setReal

public void setReal(String value)
Set the real value with the provided value.

Specified by:
setReal in class Numeric
Parameters:
value - The value to set.

compareTo

public int compareTo(Numeric other)

Specified by:
compareTo in interface Comparable<Numeric>
Specified by:
compareTo in class Numeric

randomize

public void randomize(Random random)
Re-randomize the Real object based on the upper and lower bounds.

Parameters:
random - The Random to use for the randomization.

reset

public void reset()
Set the value of the Real to a default value of 0.0.


toString

public String toString()
Return a String representation of the Real object.

Overrides:
toString in class Object
Returns:
A String representing the object instance.

getRepresentation

public String getRepresentation()
Get the type representation of this Real object as a string.

Specified by:
getRepresentation in class Numeric
Returns:
The String representation of this Type object.

writeExternal

public void writeExternal(ObjectOutput oos)
                   throws IOException
Serialize the Real to the provided ObjectOutput.

Parameters:
oos - The provided ObjectOutput.
Throws:
IOException - if an error occurs.

readExternal

public void readExternal(ObjectInput ois)
                  throws IOException,
                         ClassNotFoundException
Read the Real from the provided ObjectInput.

Parameters:
ois - The provided ObjectInput.
Throws:
IOException - If an IO error occurs.
ClassNotFoundException - If a class cast problem occurs.


Copyright © 2009 CIRG. All Rights Reserved.