|
|||||||||||
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.
// TODO Needs ordering and ensure conformance to conventions.
Field Summary | |
private boolean |
_Constant
|
(package private) static java.lang.String |
_PresentableClass
This string defines the class which will be used to parse NumberPresentations. |
private IntegerPresentation |
_PresentationFirst
The First part of the string, usually the integer or the numerator. |
private java.lang.String |
_StringExponent
The exponent part of the string, including the "E" character or whatever. |
private java.lang.String |
_StringFuzzy
The offset of the Fuzzy part of the string. |
private java.lang.String |
_StringRadix
The Radix as a string, including the "#" character (or empty). |
private java.lang.String |
_StringSecond
The Second part of the string (including the integer-fraction delimiter - usuall a "." in English speaking countries, or a "," in Franco-German countries); or the "/" separator between numerator and denominator. |
private static char |
$DecimalChar
Class field: integer/fraction delimiter. |
(package private) static java.lang.String |
$DelimiterExponent
The character which can initiate the exponent. |
private static java.lang.String |
$DelimiterFuzzy
The list of characters which can precede (or constitute) fuzzy info. |
(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. |
private static java.lang.String |
$Ellipsis
The character(s) which represent the fact that there are repeating zeroes at this point. // TODO Check this explanation. |
private static Range |
$Exp
|
private static Range |
$Fuzzy
|
static Presentation |
$Pi
Value of Pi as a String. |
private static Range |
$Radix
|
static java.lang.String |
$S_E
|
static java.lang.String |
$S_PI
|
private static Range |
$Separator
|
private static Range |
$Sign
The following index values must always correspond to the positions in the $Delimiters string above. |
private static int |
RADIX_DECIMAL
The default radix: value = 10. |
Fields inherited from class com.rubecula.util.Presentation |
_Appearance, $empty, $Stars |
Constructor Summary | |
private |
NumberPresentation()
Null constructor. |
|
NumberPresentation(double value,
boolean normalize)
Secondary Constructor to create a NumberPresentation for a double value which is considered to be exact. |
|
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(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. |
private void |
moveDecimalPoint(int rightWardPlaces)
Method to adjust the value of the number and, correspondingly, the value of the exponent. |
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. |
private Range |
rangeDecimalPoint()
Method to test if the decimal point can be moved. |
Mutable |
setConstant()
This method sets this instance to be a constant, i.e. immutable. |
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)
|
private void |
setRadix(java.lang.String radix)
|
(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. |
private static NumberPresentation |
valueOf(java.lang.String string)
|
Methods inherited from class com.rubecula.util.Presentation |
audit, audit, parse, toString, updateAppearance |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String $S_E
public static final java.lang.String $S_PI
private static final Range $Sign
private static final Range $Separator
private static final Range $Fuzzy
private static final Range $Radix
private static final Range $Exp
static final java.lang.String $Delimiters
static final char $DelimiterRadix
static final char $DelimiterRatio
static final java.lang.String $DelimiterExponent
private static final java.lang.String $DelimiterFuzzy
private static final java.lang.String $Ellipsis
public static final Presentation $E
public static final Presentation $Pi
static java.lang.String _PresentableClass
private boolean _Constant
private static int RADIX_DECIMAL
private static char $DecimalChar
private IntegerPresentation _PresentationFirst
private java.lang.String _StringSecond
private java.lang.String _StringFuzzy
private java.lang.String _StringRadix
private java.lang.String _StringExponent
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.
// TODO when the halfPlaces is set to a critical number, Gaussian model
values are not presented correctly (problem may not be in this module).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(NumberPresentation source) throws PresentationException
source
- the fuzzy presentation which is to be copied.
PresentationException
- in case of parsing error.private NumberPresentation()
Method Detail |
private static NumberPresentation valueOf(java.lang.String string)
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
PresentationException
- : 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]*]
PresentationException
public int getFuzzyAsInt()
getFuzzyAsInt
in interface FuzzyPresentable
public int getFuzzyDigitsAsInt()
getFuzzyDigitsAsInt
in interface FuzzyPresentable
public 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.private Range rangeDecimalPoint()
private void moveDecimalPoint(int rightWardPlaces) throws PresentationException
rightWardPlaces
- the number of places the decimal point is to be moved toward the right.;
a negative number denotes that the point be moved by abs(rightWardPlaces) to the left.
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 Auditable
label
- String: the label to associate with the data
public AttrMap getAttributes() throws PresentationException
getAttributes
in class Presentation
PresentationException
public boolean isMutable()
isMutable
in interface Mutable
public Mutable setConstant()
Mutable
setConstant
in interface Mutable
public java.lang.String toString(int width) throws PresentationException
toString
in class Presentation
width
- 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) throws PresentationException
second
- the String representing the fraction part or denominator,
including the separator.
May be empty.
PresentationException
final void setFuzzy(java.lang.String fuzzy)
fuzzy
- the String representing the fuzzy part (may be empty).private void setRadix(java.lang.String radix)
radix
- the String representing the radix 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 Identifiable
static 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 |