|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--com.rubecula.util.Presentation
|
+--com.rubecula.jquantity.NumberPresentation
Public class used primarily for the output of instances of Rational.
| Field Summary | |
(package private) static java.lang.String |
_PresentableClass
This string defines the class which will be used to parse NumberPresentations. |
(package private) static java.lang.String |
$DelimiterExponent
The character which can initiate the exponent. |
(package private) static char |
$DelimiterRadix
The character which can initiate the radix. |
(package private) static char |
$DelimiterRatio
The character which can initiate the radix. |
(package private) static java.lang.String |
$Delimiters
The character which are valid delimiters in a number string. |
static Presentation |
$E
Value of E as a String. |
static Presentation |
$Pi
Value of Pi as a String. |
| Fields inherited from class com.rubecula.util.Presentation |
_Appearance, $empty, $Stars |
| Constructor Summary | |
NumberPresentation(double value)
Secondary Constructor to create a NumberPresentation for a double value, rounded to the standard number of significant figures for a double. |
|
NumberPresentation(double value,
boolean normalize)
Secondary Constructor to create a NumberPresentation for a double value, rounded to the standard number of significant figures for a double. |
|
NumberPresentation(double value,
int halfPlaces,
boolean normalize)
Secondary Constructor to create a NumberPresentation for a double value. |
|
NumberPresentation(IntegerPresentation first,
java.lang.String second,
java.lang.String exponent,
java.lang.String fuzz,
java.lang.String radix)
Primary Constructor to create a NumberPresentation from a set of explicit values. |
|
NumberPresentation(NumberPresentation source)
Constructor to copy a NumberPresentation. |
|
NumberPresentation(java.lang.String string)
Secondary Constructor to create a NumberPresentation for any number from a string. |
|
NumberPresentation(java.lang.String first,
java.lang.String second)
Secondary Constructor to create a NumberPresentation for an exact non-integer value from a string. |
|
NumberPresentation(java.lang.String first,
java.lang.String second,
java.lang.String fuzz)
Primary Constructor to create a NumberPresentation from a set of explicit values. |
|
| Method Summary | |
java.lang.String |
audit()
Method to return a detailed (unlabeled) string from an arithmetical object for debugging purposes. |
void |
audit(java.io.PrintStream out,
java.lang.String label)
Method to output a string from an arithmetical object for debugging purposes. |
java.lang.String |
audit(java.lang.String label)
Method to return a detailed string from an arithmetical object for debugging purposes. |
java.lang.Object |
clone()
Creates and returns a copy of this object. |
(package private) double |
doubleValue()
|
AttrMap |
getAttributes()
Return the attributes with which this presentation was created, or at least the best guess. |
static char |
GetDecimalChar()
Method to get the current integer/fraction delimiter character (the decimal "point"). |
(package private) java.lang.String |
getExponent()
|
(package private) int |
getExponentAsInt()
|
(package private) IntegerPresentation |
getFirst()
|
(package private) java.math.BigDecimal |
getFirstAsBigDecimal()
Return the integer part of this object as a BigDecimal. |
(package private) java.math.BigInteger |
getFirstAsBigInteger()
|
(package private) java.lang.String |
getFirstNet()
|
(package private) java.lang.String |
getFuzzy()
|
int |
getFuzzyAsInt()
Method to figure the precision of this presentation. |
int |
getFuzzyAsModel()
Method to get the error model defined by the fuzzy characters. |
(package private) java.lang.String |
getFuzzyDigits()
|
int |
getFuzzyDigitsAsInt()
|
java.lang.String |
getIdentifier()
Method to get the specific identifier for an object. |
java.lang.String |
getPresentableClass()
Method to get the name of the corresponding Presentable class for this Presentation. |
(package private) java.lang.String |
getRadix()
|
(package private) int |
getRadixAsInt()
|
(package private) java.lang.String |
getSecond()
|
(package private) java.math.BigDecimal |
getSecondAsBigDecimal()
Get the fractional or divisor part of this presentation as a BigDecimal number. |
(package private) java.lang.String |
getSecondNet()
|
(package private) java.lang.String |
getSecondwFuzz()
|
(package private) boolean |
getSignAsBoolean()
|
(package private) boolean |
isInfinite()
Method to determine if this presentation represents an infinite number. |
boolean |
isMutable()
This method indicates whether this particular instance is mutable. |
(package private) static boolean |
isNumeric(java.lang.String s)
|
(package private) boolean |
isRatio()
|
(package private) long |
longValue()
Return this in the form of a long. |
static void |
main(java.lang.String[] args)
Main method for testing this class. |
void |
makeFuzzy(int model,
double boundAbs)
Mutating instance method to set the fuzzy string according to given model and bounds. |
(package private) static int |
MinOffset(int x,
int y)
return the minimum "offset" defined by the two offsets x and y. |
(package private) static java.lang.String |
ModelAsString(int model)
Class method to yield a presentable string for a Fuzzy model. |
int |
normalize()
MUTATING Method to adjust the value of the number and, correspondingly, the value of the exponent. |
protected int |
normalize(int before)
MUTATING Method to adjust the value of the number and, correspondingly, the value of the exponent. |
static void |
SetDecimalChar(char decimalChar)
Method to set the integer/fraction delimiter character (the decimal "point"). |
(package private) void |
setExponent(int exponent)
|
(package private) void |
setExponent(java.lang.String exponent)
|
(package private) void |
setFirst(IntegerPresentation first)
Method to set the value of first as an IntegerPresentation. |
(package private) void |
setFirst(java.lang.String first)
Method to set the first string. |
protected void |
setFuzzy(int halfPlaces)
Method to set the fuzzy part of this according to the number of halfplaces of decimals specified and the string given. |
protected void |
setFuzzy(int halfPlaces,
java.lang.String fuzzy)
Method to set the fuzzy part of this according to the number of halfplaces of decimals specified and the string given. |
(package private) void |
setFuzzy(java.lang.String fuzzy)
|
(package private) void |
setSecond(java.lang.String second)
|
protected void |
setValue(java.lang.String source)
Instance method to set the value of a NumberPresentation from a String. |
java.lang.String |
toString(int width)
Render this Presentation as a String within the width specified. |
| Methods inherited from class com.rubecula.util.Presentation |
parse, toString, updateAppearance |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
static final java.lang.String $Delimiters
static final char $DelimiterRadix
static final char $DelimiterRatio
static final java.lang.String $DelimiterExponent
public static final Presentation $E
public static final Presentation $Pi
static java.lang.String _PresentableClass
| Constructor Detail |
public NumberPresentation(IntegerPresentation first,
java.lang.String second,
java.lang.String exponent,
java.lang.String fuzz,
java.lang.String radix)
throws PresentationException
first - the integer presentation which will form the base of
the new instance (i.e. the sign, integer part, radix and exponent).second - EITHER: the fractional part,
starting with the decimal character (usually ".")
OR: the denominator, starting with "/".exponent - a string representing the exponent, for example "E-2".fuzz - the fuzzy information of the form "*", "*n", or "(nn)".radix - a string representing the radix, for example #8.
PresentationException - in case of parsing error.
public NumberPresentation(java.lang.String first,
java.lang.String second,
java.lang.String fuzz)
throws PresentationException
first - the integer presentation which will form the base of
the new instance (i.e. the sign, integer part, radix and exponent).second - EITHER: the fractional part,
starting with the decimal character (usually ".")
OR: the denominator, starting with "/".fuzz - the fuzzy information of the form "*", "*n", or "(nn)".
PresentationException - in case of parsing error.
public NumberPresentation(java.lang.String first,
java.lang.String second)
throws PresentationException
first - the integer presentation which will form the base of the
new instance (i.e. the sign, integer part, radix and exponent).second - the denominator or fractional part
(including the initial separator).
PresentationException - in case of parsing error.
public NumberPresentation(java.lang.String string)
throws PresentationException
string - the presentation which defines the new instance.
PresentationException - in case of parsing error.
public NumberPresentation(double value,
int halfPlaces,
boolean normalize)
throws PresentationException
value - the double whose value we wish to present.halfPlaces - twice the number of significant figures to which the
presentation should be rounded.normalize - true if the presentation should be normalized.
PresentationException - in case of parsing error.
public NumberPresentation(double value,
boolean normalize)
throws PresentationException
value - the double whose value we wish to present.normalize - true if the presentation should be normalized.
PresentationException - in case of parsing error.
public NumberPresentation(double value)
throws PresentationException
value - the double whose value we wish to present.
PresentationException - in case of parsing error.
public NumberPresentation(NumberPresentation source)
throws PresentationException
source - the fuzzy presentation which is to be copied.
PresentationException - in case of parsing error.| Method Detail |
public static void main(java.lang.String[] args)
args - String[] : the command line options.public static void SetDecimalChar(char decimalChar)
decimalChar - the character to be used to separate integers from
fractional parts of a string.public static char GetDecimalChar()
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.ObjectPresentationException - : NumberPresentation not Cloneable
(should be impossible)
java.lang.CloneNotSupportedException - if superclass cannot clone.Cloneable
public void makeFuzzy(int model,
double boundAbs)
throws PresentationException
model - the error model required.boundAbs - the absolute bounds required.
PresentationException - invalid model.
protected final void setValue(java.lang.String source)
throws PresentationException
source - the string representing all aspects of this value.
The format of the string is:
[-+] [0-9]* [[.] [0-9]*] ['*'|'['[0-9]*']'] ['#'[0-9]*] ['E'[0-9]*]
PresentationExceptionpublic int getFuzzyAsInt()
getFuzzyAsInt in interface FuzzyPresentablepublic int getFuzzyDigitsAsInt()
getFuzzyDigitsAsInt in interface FuzzyPresentablepublic int getFuzzyAsModel()
getFuzzyAsModel in interface FuzzyPresentable
protected final void setFuzzy(int halfPlaces,
java.lang.String fuzzy)
throws PresentationException
halfPlaces - the precision desired in terms of half-places of decimals.fuzzy - the characters defining the fuzzy data.
PresentationException
protected final void setFuzzy(int halfPlaces)
throws PresentationException
halfPlaces - the precision desired in terms of half-places of decimals.
PresentationException - in case of parsing error.
protected int normalize(int before)
throws PresentationException
before - the number of non-zero digits required to precede the decimal
point character.
PresentationException - if not possible to normalize.
public int normalize()
throws PresentationException
PresentationException - if not possible to normalize.final java.lang.String getSecond()
final java.lang.String getSecondwFuzz()
final java.lang.String getSecondNet()
final java.lang.String getFuzzy()
public java.lang.String getPresentableClass()
getPresentableClass in class Presentation_PresentableClass.public java.lang.String audit(java.lang.String label)
audit in interface Auditablelabel - String: the label to associate with the data
public void audit(java.io.PrintStream out,
java.lang.String label)
audit in interface Auditableaudit in class Presentationout - the print stream to which audit string is to be sent.label - the label to attach to the data.public java.lang.String audit()
audit in interface Auditableaudit in class Presentation
public AttrMap getAttributes()
throws PresentationException
getAttributes in class PresentationPresentationExceptionpublic boolean isMutable()
isMutable in interface Mutable
public java.lang.String toString(int width)
throws PresentationException
toString in class Presentationwidth - the max. number of characters within which to output the presentation.
PresentationException - negative width.final double doubleValue()
final java.lang.String getFuzzyDigits()
final java.math.BigDecimal getSecondAsBigDecimal()
final java.math.BigDecimal getFirstAsBigDecimal()
final void setFirst(IntegerPresentation first)
first - the IntegerPresentation to be used for the first part of this
presentation.
final void setFirst(java.lang.String first)
throws PresentationException
first - the String representing the first part, either the integer part or the numerator.
PresentationException - in case of parsing error.final void setSecond(java.lang.String second)
second - the String representing the fraction part or denominator,
including the separator.
May be empty.final void setFuzzy(java.lang.String fuzzy)
fuzzy - the String representing the fuzzy part (may be empty).final void setExponent(java.lang.String exponent)
exponent - the String representing the exponent part (may be empty).final void setExponent(int exponent)
exponent - an integer representing the exponent part.final IntegerPresentation getFirst()
final java.lang.String getFirstNet()
final java.lang.String getRadix()
final java.lang.String getExponent()
public java.lang.String getIdentifier()
getIdentifier in interface Identifiablestatic java.lang.String ModelAsString(int model)
model - the model value (Fuzzy.$DistUniform, etc.).
final boolean isInfinite()
final boolean isRatio()
final boolean getSignAsBoolean()
final java.math.BigInteger getFirstAsBigInteger()
final int getRadixAsInt()
final int getExponentAsInt()
final long longValue()
static int MinOffset(int x,
int y)
x - an offset into a string (or -1 for no argument).y - an offset into a string (or -1 for no argument).
static boolean isNumeric(java.lang.String s)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||