org.grinvin.invariants

Class RealValue


public class RealValue
extends InvariantValue

Invariant type which allows real values, including positive and negative infinity and undefined values. Identified by the string real.

Constructor Summary

RealValue(double value, InvariantComputer computer)
Create an object of this type with the given value which is computed by the given computer.

Method Summary

double
asDouble()
Return the actual value as a real number.
void
loadValue(Element element)
Should be overridden to load the actual value from a JDOM-element.
static RealValue
negativeInfinity(InvariantComputer computer)
Return an object of this type representing negative infinity.
static RealValue
positiveInfinity(InvariantComputer computer)
Return an object of this type representing positive infinity.
void
saveValue(Element element)
Should be overridden to save the actual value into a JDOM-element.
String
toText()
Convert this value to a string, so it can be displayed as part of a GUI.
static RealValue
undefinedValue(InvariantComputer computer)
Return an object of this type representing an undefined value.

Methods inherited from class org.grinvin.invariants.InvariantValue

asDouble, fromElement, getComputerVersion, getInvariant, load, loadValue, saveValue, toElement, toString, toText

Constructor Details

RealValue

public RealValue(double value,
                 InvariantComputer computer)
Create an object of this type with the given value which is computed by the given computer.

Method Details

asDouble

public double asDouble()
Return the actual value as a real number. An undefined value is represented by Double.NaN.
Overrides:
asDouble in interface InvariantValue

loadValue

public void loadValue(Element element)
Should be overridden to load the actual value from a JDOM-element. Clients should throw an IOFormatException when element is not in the correct format.
Overrides:
loadValue in interface InvariantValue
Parameters:
element - JDOM element, which is known to be of type 'value'

negativeInfinity

public static RealValue negativeInfinity(InvariantComputer computer)
Return an object of this type representing negative infinity.
Parameters:
computer - Invariant computer which calculated this value.

positiveInfinity

public static RealValue positiveInfinity(InvariantComputer computer)
Return an object of this type representing positive infinity.
Parameters:
computer - Invariant computer which calculated this value.

saveValue

public void saveValue(Element element)
Should be overridden to save the actual value into a JDOM-element.
Overrides:
saveValue in interface InvariantValue
Parameters:
element - JDOM element, which is of type 'value'

toText

public String toText()
Convert this value to a string, so it can be displayed as part of a GUI.
Overrides:
toText in interface InvariantValue

undefinedValue

public static RealValue undefinedValue(InvariantComputer computer)
Return an object of this type representing an undefined value.
Parameters:
computer - Invariant computer which calculated this value.