|
sharkysoft.com | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sharkysoft.printf.engine.StringFormatter
com.sharkysoft.printf.engine.NumberFormatter
Formats numbers.
A NumberFormatter
formats numbers in a field by adjusting
their precision and padding them as necessary, according to criteria selected
by the client. Properties control various formatting constraints, such as
field width, justification style, padding characters, and so on.
Because applications that format numeric values frequently format multiple values with the same criteria, this class is designed to "remember" selected formatting properties so that the settings they can be reused with each subsequent formatting request. This approach minimizes the number of parameters that must be passed with each formatting call and results in more efficient execution for large formatting jobs.
NumberFormatter
extends StringFormatter
with abstract
number formatting constraints that are common to IntegerFormatter
and
RealFormatter
. This class does not actually implement any of the
specific numeric formatting rules, but leaves that work to the
subclasses.
IntegerFormatter
,
RealFormatter
Field Summary | |
protected int |
mnRadix
Radix. |
protected int |
mnSigDigits
Significant digits. |
protected java.lang.String |
msNegPrefix
Negative prefix. |
protected java.lang.String |
msNegSuffix
Negative suffix. |
protected java.lang.String |
msPosPrefix
Positive prefix. |
protected java.lang.String |
msPosSuffix
Positive suffix. |
protected java.lang.String |
msZeroPrefix
Zero prefix. |
protected java.lang.String |
msZeroSuffix
Zero suffix. |
protected boolean |
mzUpperCase
Upper case/lower case. |
Fields inherited from class com.sharkysoft.printf.engine.StringFormatter |
mcPadChar, mnAlignment, mnCropping, mnFieldWidth |
Constructor Summary | |
protected |
NumberFormatter()
Default constructor. |
Method Summary | |
java.lang.String |
getNegPrefix()
Retrieves NegPrefix property. |
java.lang.String |
getNegSuffix()
Retrieves NegSuffix property. |
java.lang.String |
getPosPrefix()
Retrieves PosPrefix property. |
java.lang.String |
getPosSuffix()
Retrieves PosSuffix property. |
int |
getRadix()
Retrieves Radix property. |
int |
getSigDigits()
Retrieves SigDigits property. |
boolean |
getUpperCase()
Retrieves UpperCase property. |
java.lang.String |
getZeroPrefix()
Retrieves ZeroPrefix property. |
java.lang.String |
getZeroSuffix()
Retrieves ZeroSuffix property. |
void |
setNegPrefix(java.lang.String isNegPrefix)
Updates NegPrefix property. |
void |
setNegSuffix(java.lang.String isNegSuffix)
Updates NegSuffix property. |
void |
setPosPrefix(java.lang.String isPosPrefix)
Updates PosPrefix property. |
void |
setPosSuffix(java.lang.String isPosSuffix)
Updates PosSuffix property. |
void |
setRadix(int inRadix)
Updates Radix property. |
void |
setSigDigits(int inSigDigits)
Updates SigDigits property. |
void |
setUpperCase(boolean izUpperCase)
Updates UpperCase property. |
void |
setZeroPrefix(java.lang.String isZeroPrefix)
Updates ZeroPrefix property. |
void |
setZeroSuffix(java.lang.String isZeroSuffix)
Updates ZeroSuffix property. |
Methods inherited from class com.sharkysoft.printf.engine.StringFormatter |
format, format, getAlignment, getCropping, getFieldWidth, getPadChar, setAlignment, setCropping, setFieldWidth, setPadChar, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected int mnRadix
Details: Property Radix
is the output radix (numeric
base) for stringified numbers. For example, a value of 16 indicates that
the value will be represented in hexadecimal. This value may not be set
to values less than 2 or greater than 36. Default value: 10.
getRadix()
,
setRadix(int)
protected boolean mzUpperCase
Details: Property UpperCase
determines whether upper
or lower case letters will be used when property Radix
is
greater than 10. If this property is true
, upper case letters
will be used. If this property is false
, lower case letters
will be used. The default value for this property is
false
.
getUpperCase()
,
setUpperCase(boolean)
protected int mnSigDigits
Details: Property SigDigits
constrains the number of
significant digits to express in the output, so that the value will be
rounded if necessary. Setting this value to 0 indicates that all digits
are considered significant. This constraint may conflict with the
MaxRightDigits property in RealFormatter
. Default value: 0.
getSigDigits()
,
setSigDigits(int)
protected java.lang.String msPosPrefix
Details: Property PosPrefix
is the string that
precedes positive values. This property may not be null
.
Default value: "".
getPosPrefix()
,
setPosPrefix(String)
protected java.lang.String msPosSuffix
Details: Property PosSuffix
is the string that
follows positive values. This property may not be null
.
Default value: "".
getPosSuffix()
,
setPosSuffix(String)
protected java.lang.String msZeroPrefix
Details: Property ZeroPrefix
is the string that
precedes zero values. This property may not be null
. Default
value: "".
getZeroPrefix()
,
setZeroPrefix(String)
protected java.lang.String msZeroSuffix
Details: Property ZeroSuffix
is the string that
follows zero values. This property may not be null
. Default
value: "".
getZeroSuffix()
,
setZeroSuffix(String)
protected java.lang.String msNegPrefix
Details: Property NegPrefix
is the string that
precedes negative values. This property may not be null
.
Default value: "-".
getNegPrefix()
,
setNegPrefix(String)
protected java.lang.String msNegSuffix
Details: Property NegSuffix
is the string that
follows negative values. This property may not be null
.
Default value: "".
getNegSuffix()
,
setNegSuffix(String)
Constructor Detail |
protected NumberFormatter()
Method Detail |
public int getRadix()
mnRadix
public void setRadix(int inRadix)
inRadix
- new valuemnRadix
public boolean getUpperCase()
mzUpperCase
public void setUpperCase(boolean izUpperCase)
izUpperCase
- new valuemzUpperCase
public int getSigDigits()
mnSigDigits
public void setSigDigits(int inSigDigits)
inSigDigits
- new valuemnSigDigits
public java.lang.String getPosPrefix()
msPosPrefix
public void setPosPrefix(java.lang.String isPosPrefix)
isPosPrefix
- new valuemsPosPrefix
public java.lang.String getPosSuffix()
msPosSuffix
public void setPosSuffix(java.lang.String isPosSuffix)
isPosSuffix
- new valuemsPosSuffix
public java.lang.String getZeroPrefix()
msZeroPrefix
public void setZeroPrefix(java.lang.String isZeroPrefix)
isZeroPrefix
- new valuemsZeroPrefix
public java.lang.String getZeroSuffix()
msZeroSuffix
public void setZeroSuffix(java.lang.String isZeroSuffix)
isZeroSuffix
- new valuemsZeroSuffix
public java.lang.String getNegPrefix()
msNegPrefix
public void setNegPrefix(java.lang.String isNegPrefix)
isNegPrefix
- new valuemsNegPrefix
public java.lang.String getNegSuffix()
msNegSuffix
public void setNegSuffix(java.lang.String isNegSuffix)
isNegSuffix
- new valuemsNegSuffix
|
sharkysoft.com | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997-2004 Sharkysoft (sharkysoft.com). All rights reserved.