com.rubecula.jquantity
Class ValuePresentation

java.lang.Object
  extended bycom.rubecula.util.Presentation
      extended bycom.rubecula.jquantity.MutablePresentation
          extended bycom.rubecula.jquantity.ValuePresentation
All Implemented Interfaces:
Auditable, java.lang.Cloneable, Identifiable, Mutable

public class ValuePresentation
extends MutablePresentation

Presentation class to deal with value objects.

Since:
V_0_2
Version:
$Revision: 1.13 $ // TODO This should not directly refer to Value or Rational.
Author:
Robin Hillyard

Field Summary
(package private)  NumberPresentation _Number
          A NumberPresentation representing the number part of this value.
(package private) static java.lang.String _PresentableClass
          This string defines the class which will be used to parse NumberPresentations.
(package private)  java.lang.String _Type
          A String representing the type of this value.
static char $Shriek
          The character value "!".
 
Fields inherited from class com.rubecula.jquantity.MutablePresentation
 
Fields inherited from class com.rubecula.util.Presentation
_Appearance, $empty, $Stars
 
Constructor Summary
ValuePresentation(NumberPresentation number, java.lang.String type)
          Primary constructor to create a value presentation from a NumberPresentation and a type string.
 
Method Summary
 java.lang.String audit(java.lang.String label)
          Method to return a detailed string from an object for debugging purposes.
 AttrMap getAttributes()
          Return the attributes with which this presentation was created, or at least the best guess.
 java.lang.String getIdentifier()
          Method to get the specific identifier for an object.
 NumberPresentation getNumber()
           
 java.lang.String getPresentableClass()
          Method to get the name of the corresponding Presentable class for this Presentation.
 java.lang.String getType()
           
 boolean isMutable()
          This method indicates whether this particular instance is mutable.
static void main(java.lang.String[] args)
          Main method for testing this class.
 java.lang.String toString(int width)
          Render this Presentation as a String with the given width limitation.
static ValuePresentation valueOf(java.lang.String value)
          Factory method to create a new instance of ValuePresentation from a string value.
 
Methods inherited from class com.rubecula.jquantity.MutablePresentation
audit, audit, setConstant
 
Methods inherited from class com.rubecula.util.Presentation
parse, toString, updateAppearance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

$Shriek

public static final char $Shriek
The character value "!".

See Also:
Constant Field Values

_PresentableClass

static java.lang.String _PresentableClass
This string defines the class which will be used to parse NumberPresentations.


_Number

NumberPresentation _Number
A NumberPresentation representing the number part of this value.


_Type

java.lang.String _Type
A String representing the type of this value.

Constructor Detail

ValuePresentation

public ValuePresentation(NumberPresentation number,
                         java.lang.String type)
                  throws PresentationException
Primary constructor to create a value presentation from a NumberPresentation and a type string.

Parameters:
number - the NumberPresentation.
type - the type as a string (without the "!").
Throws:
PresentationException - if parsing problem.
Method Detail

main

public static void main(java.lang.String[] args)
Main method for testing this class.

Parameters:
args - String[] : the command line options.

valueOf

public static ValuePresentation valueOf(java.lang.String value)
                                 throws PresentationException
Factory method to create a new instance of ValuePresentation from a string value.

Parameters:
value - the string in the form: number@units where number can be formed into a NumberPresentation and where units is a recognized units name.
Returns:
a new ValuePresentation as appropriate.
Throws:
PresentationException

getAttributes

public AttrMap getAttributes()
                      throws PresentationException
Return the attributes with which this presentation was created, or at least the best guess.

Specified by:
getAttributes in class Presentation
Returns:
a map of attributes used to render this Presentation. Currently returns an empty map.
Throws:
PresentationException

toString

public java.lang.String toString(int width)
                          throws PresentationException
Render this Presentation as a String with the given width limitation.

Specified by:
toString in class Presentation
Parameters:
width - the maximum number of characters allowed for depiction of this presentation.
Returns:
a representation (rendering) of this Presentation.
Throws:
PresentationException - when width is insufficient.

getPresentableClass

public java.lang.String getPresentableClass()
Method to get the name of the corresponding Presentable class for this Presentation.

Specified by:
getPresentableClass in class Presentation
Returns:
_PresentableClass.

audit

public java.lang.String audit(java.lang.String label)
Description copied from interface: Auditable
Method to return a detailed string from an object for debugging purposes.

Parameters:
label - the label to associate with the data. If label is non-null, a more detailed audit will be returned (this normally occurs only at the top level).
Returns:
the detailed string.

getIdentifier

public java.lang.String getIdentifier()
Description copied from interface: Identifiable
Method to get the specific identifier for an object.

Returns:
the identifier.

isMutable

public boolean isMutable()
This method indicates whether this particular instance is mutable.

Specified by:
isMutable in interface Mutable
Overrides:
isMutable in class MutablePresentation
Returns:
true.

getNumber

public NumberPresentation getNumber()

getType

public java.lang.String getType()