com.rubecula.jquantity
Class JQuantityPresentation

java.lang.Object
  extended bycom.rubecula.util.Presentation
      extended bycom.rubecula.jquantity.JQuantityPresentation
All Implemented Interfaces:
Auditable, Identifiable, Nameable

public class JQuantityPresentation
extends Presentation
implements Nameable

This class is a string-component representation of a JQuantity.

Version:
$Revision: 1.9 $
Author:
Robin Hillyard

Field Summary
private  java.lang.String _Identifier
          The identifier for this object.
private  NumberPresentation _Imaginary
          The presentation for the imaginary part, if any.
(package private) static java.lang.String _PresentableClass
          This string defines the class which will be used to parse JQuantityPresentations.
private  NumberPresentation _Real
          The presentation for the real part.
private  java.lang.String _Units
          The units part of the JQuantity (or "").
private static char $DelimiterId
          Delimiter to terminate an identifier prefix, if any.
private static char $DelimiterImaginary
          Delimiter to initiate an imaginary part, if any.
private static char $DelimiterUnits
          Delimiter to initiate an units part, if any.
 
Fields inherited from class com.rubecula.util.Presentation
_Appearance, $empty, $Stars
 
Constructor Summary
JQuantityPresentation()
          Empty constructor to create an undefine JQuantityPresentation.
JQuantityPresentation(java.lang.String identifier, NumberPresentation real, NumberPresentation imag, java.lang.String units)
          Primary constructor to create an identified, possibly complex, JQuantityPresentation, optionally with defined Units.
JQuantityPresentation(java.lang.String identifier, java.lang.String real)
          Secondary constructor to create an identified, JQuantityPresentation, optionally with defined Units.
JQuantityPresentation(java.lang.String identifier, java.lang.String real, java.lang.String units)
          Secondary constructor to create an identified, JQuantityPresentation, optionally with defined Units.
JQuantityPresentation(java.lang.String identifier, java.lang.String real, java.lang.String imag, java.lang.String units)
          Secondary constructor to create an identified, possibly complex, JQuantityPresentation, optionally with defined Units.
 
Method Summary
 java.lang.String audit(java.lang.String label)
          Method to return a detailed string from an arithmetical 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 getImag()
           
 java.lang.String getPresentableClass()
          Method to get the name of the corresponding Presentable class for this Presentation.
 NumberPresentation getReal()
           
 java.lang.String getUnitsPart()
           
static void main(java.lang.String[] args)
          Main method for testing this class.
 void setIdentifier(java.lang.String identifier)
          Method to set a specific identifier to an object.
 Presentation setValue(java.lang.String source)
          Fix the value of this Presentation according to the given string s.
 java.lang.String toString(int width)
          Render this Presentation as a String within the width specified.
static JQuantityPresentation valueOf(java.lang.String string)
          Factory method to create a JQuantityPresentation from a String.
 
Methods inherited from class com.rubecula.util.Presentation
audit, audit, parse, toString, updateAppearance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_PresentableClass

static java.lang.String _PresentableClass
This string defines the class which will be used to parse JQuantityPresentations. Note: Currently the value is "com.rubecula.jquantity.Quantity". // TODO Change value to "com.rubecula.jquantity.JQuantity".


$DelimiterId

private static final char $DelimiterId
Delimiter to terminate an identifier prefix, if any.

See Also:
Constant Field Values

$DelimiterImaginary

private static final char $DelimiterImaginary
Delimiter to initiate an imaginary part, if any.

See Also:
Constant Field Values

$DelimiterUnits

private static final char $DelimiterUnits
Delimiter to initiate an units part, if any.

See Also:
Constant Field Values

_Units

private java.lang.String _Units
The units part of the JQuantity (or "").


_Identifier

private java.lang.String _Identifier
The identifier for this object.


_Real

private NumberPresentation _Real
The presentation for the real part.


_Imaginary

private NumberPresentation _Imaginary
The presentation for the imaginary part, if any.

Constructor Detail

JQuantityPresentation

public JQuantityPresentation(java.lang.String identifier,
                             NumberPresentation real,
                             NumberPresentation imag,
                             java.lang.String units)
Primary constructor to create an identified, possibly complex, JQuantityPresentation, optionally with defined Units.

Parameters:
identifier - a String to be used to identify this presentation.
real - a NumberPresentation representing the real part of this presentation.
imag - a NumberPresentation representing the imaginary part of this presentation.
units - a String to represent the units (may be "").

JQuantityPresentation

public JQuantityPresentation(java.lang.String identifier,
                             java.lang.String real,
                             java.lang.String imag,
                             java.lang.String units)
                      throws PresentationException
Secondary constructor to create an identified, possibly complex, JQuantityPresentation, optionally with defined Units.

Parameters:
identifier - a String to be used to identify this presentation.
real - a string representing the real part of this presentation.
imag - a string representing the imaginary part of this presentation.
units - a String to represent the units (may be "").
Throws:
PresentationException

JQuantityPresentation

public JQuantityPresentation(java.lang.String identifier,
                             java.lang.String real,
                             java.lang.String units)
                      throws PresentationException
Secondary constructor to create an identified, JQuantityPresentation, optionally with defined Units.

Parameters:
identifier - a String to be used to identify this presentation.
real - a String representing the real part of this presentation (see ValuePresentation).
units - a String to represent the units (or null).
Throws:
PresentationException

JQuantityPresentation

public JQuantityPresentation(java.lang.String identifier,
                             java.lang.String real)
                      throws PresentationException
Secondary constructor to create an identified, JQuantityPresentation, optionally with defined Units.

Parameters:
identifier - a String to be used to identify this presentation.
real - a String representing the real part of this presentation (see ValuePresentation).
Throws:
PresentationException

JQuantityPresentation

public JQuantityPresentation()
Empty constructor to create an undefine JQuantityPresentation.

Method Detail

valueOf

public static JQuantityPresentation valueOf(java.lang.String string)
                                     throws PresentationException
Factory method to create a JQuantityPresentation from a String.

Parameters:
string - the string from which to create the JQuantityPresentation.
Returns:
the new JQuantityPresentation.
Throws:
PresentationException

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.

setValue

public Presentation setValue(java.lang.String source)
                      throws PresentationException
Fix the value of this Presentation according to the given string s. The details of what is created will vary according to the implementer and the string itself.

Parameters:
source - the string representing all aspects of this value. The format of the string is:
[Identifier ':'] ValuePresentation ['i' ValuePresentation ] ['@' Units]
where:
Identifier
represents a string which will be used when the Presentation is audited;
ValuePresentation
represents a
Returns:
a newly-minted JQuantityPresentation with value defined by source.
Throws:
PresentationException
See Also:
either the (required) real part or the (optional) imaginary part.
Units
the name of the Units

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)
Render this Presentation as a String within the width specified.

Specified by:
toString in class Presentation
Parameters:
width - the max. number of characters within which to output the presentation.
Returns:
a representation (rendering) of this Presentation.

setIdentifier

public void setIdentifier(java.lang.String identifier)
Method to set a specific identifier to an object.

Specified by:
setIdentifier in interface Nameable
Parameters:
identifier - String: the identifier to associate with the object

getIdentifier

public java.lang.String getIdentifier()
Method to get the specific identifier for an object.

Specified by:
getIdentifier in interface Identifiable
Returns:
"<" value ">"

audit

public java.lang.String audit(java.lang.String label)
Method to return a detailed string from an arithmetical object for debugging purposes.

Specified by:
audit in interface Auditable
Parameters:
label - String: the label to associate with the data
Returns:
the detailed string.

getReal

public NumberPresentation getReal()
Returns:
the String representing the integer part, derived directly from the original string.

getImag

public NumberPresentation getImag()
Returns:
the String representing the integer part, derived directly from the original string.

getUnitsPart

public java.lang.String getUnitsPart()
Returns:
the String representing the integer part, derived directly from the original string.

main

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

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