com.rubecula.util
Interface Presentable

All Known Subinterfaces:
Replaceable
All Known Implementing Classes:
Expression, Item, Macro, Operator, Symbol

public interface Presentable

This interface defines the linkage between values in the JQuantity package and user interface classes, such as in com.rubecula.spreadsheet. For example, any subclass com.rubecula.jquantity.BaseNumber implements this interface and so can be converted into a Presentation and back again.

Important Note: this interface is a co-class with the abstract class Presentation (each depends on the other).

Version:
$Revision: 1.3 $
Author:
Robin Hillyard

Method Summary
 java.lang.String getType()
          This method is primarily for development purposes: it yields the name of the class of the presentable object or, in some cases, the class of the presentable object indirectly referenced.
 Presentable makePresentableInstance(Presentation presentation)
          Instance method to convert a Presentation into a Presentable.
 Presentation present(AttrMap attributes)
          Convert this Presentable object into a Presentation, according to the set of attributes provided.
 

Method Detail

present

public Presentation present(AttrMap attributes)
                     throws PresentationException
Convert this Presentable object into a Presentation, according to the set of attributes provided.

Parameters:
attributes - a map of the attributes desired for the construction of the new presentation (may be empty).
Returns:
an appropriate instance of Presentation.
Throws:
PresentationException - in case of parsing error.

makePresentableInstance

public Presentable makePresentableInstance(Presentation presentation)
                                    throws PresentationException
Instance method to convert a Presentation into a Presentable. Ideally, this would be a class method, but such a method cannot be defined in an interface. Nor can it be defined in an abstract class with the intention of overriding it in a subclass. Polymorphism just doesn't work that way.
Therefore, the present value (as in fields) of the instance is essentially ignored - only the methods are important.

Parameters:
presentation - of a number to be converted into a Presentable number.
Returns:
a number in the form of a Presentable.
Throws:
PresentationException - in case of parsing error.

getType

public java.lang.String getType()
This method is primarily for development purposes: it yields the name of the class of the presentable object or, in some cases, the class of the presentable object indirectly referenced. The text returned is not necessarily the canonical class name.

Returns:
a representation of the effective class of this object.