org.grinvin.invariants

Class InvariantValue

Known Direct Subclasses:
BooleanValue, IntegerValue, RealValue

public abstract class InvariantValue
extends java.lang.Object

Wraps the result of an invariant computation and provides a means to represent this result both as a string and an XML element.

Constructor Summary

InvariantValue(String type)
Create a new unitialized value of the given type.
InvariantValue(String type, InvariantComputer computer)
Create a value of the given type which was computed by the given invariant computer.

Method Summary

abstract double
asDouble()
static InvariantValue
fromElement(Element element)
Convert a JDOM-element to an invariant value of the correct class.
String
getComputerVersion()
Invariant
getInvariant()
Return the invariant of which this is a value.
protected void
load(Element element)
Initialize the components of this value from a JDOM-element.
abstract void
loadValue(Element element)
Should be overridden to load the actual value from a JDOM-element.
abstract void
saveValue(Element element)
Should be overridden to save the actual value into a JDOM-element.
Element
toElement()
Converts this value to a JDOM element.
String
toString()
abstract String
toText()
Convert this value to a string, so it can be displayed as part of a GUI.

Constructor Details

InvariantValue

protected InvariantValue(String type)
Create a new unitialized value of the given type. Used by the loader.

InvariantValue

protected InvariantValue(String type,
                         InvariantComputer computer)
Create a value of the given type which was computed by the given invariant computer.

Method Details

asDouble

public abstract double asDouble()

fromElement

public static InvariantValue fromElement(Element element)
            throws IOFormatException,
                   UnknownInvariantException,
                   UnknownInvariantTypeException
Convert a JDOM-element to an invariant value of the correct class.

getComputerVersion

public String getComputerVersion()

getInvariant

public Invariant getInvariant()
Return the invariant of which this is a value.

load

protected void load(Element element)
            throws IOFormatException,
                   UnknownInvariantException,
                   UnknownInvariantTypeException
Initialize the components of this value from a JDOM-element. The element is known to be of type 'invariantvalue'. Delegates to loadValue(Element) to load the actual value.

loadValue

public abstract void loadValue(Element element)
            throws IOFormatException
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.
Parameters:
element - JDOM element, which is known to be of type 'value'
See Also:
load(Element)

saveValue

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

toElement

public Element toElement()

toString

public String toString()

toText

public abstract String toText()
Convert this value to a string, so it can be displayed as part of a GUI.