com.jaxfront.core.jep
Class SPrintF
java.lang.Object
org.nfunk.jep.function.PostfixMathCommand
com.jaxfront.core.jep.JaxfrontMathCommand
com.jaxfront.core.jep.SPrintF
- All Implemented Interfaces:
- org.nfunk.jep.function.PostfixMathCommandI
public class SPrintF
- extends JaxfrontMathCommand
DecimalFormat is for formatting decimal numbers with usage of a patterns.
Symbol Meaning 0 a digit # a digit, zero shows as absent . placeholder for
decimal separator , placeholder for grouping separator. E separates mantissa
and exponent for exponential formats. ; separates formats. - default negative
prefix. % multiply by 100 and show as percentage ‰ multiply by 1000 and show
as per mille ¤ currency sign; replaced by currency symbol; if doubled,
replaced by international currency symbol. If present in a pattern, the
monetary decimal separator is used instead of the decimal separator. X any
other characters can be used in the prefix or suffix ' used to quote special
characters in a prefix or suffix.
Notes
If there is no explicit negative subpattern, - is prefixed to the positive
form. That is, "0.00" alone is equivalent to "0.00;-0.00". If there is an
explicit negative subpattern, it serves only to specify the negative prefix
and suffix; the number of digits, minimal digits, and other characteristics
are all the same as the positive pattern. That means that "#,##0.0#;(#)" has
precisely the same result as "#,##0.0#;(#,##0.0#)".
The exponent character must be immediately followed by one or more digit
characters. Example: "0.###E0". The number of digit characters after the
exponent character gives the minimum exponent digit count; there is no
maximum. Negative exponents are denoted using the same prefix and/or suffix
specified for the number itself. The minimum number of integer digits is
achieved by adjusting the exponent. The maximum number of integer digits, if
any, specifies the exponent grouping. For example, 12345 is formatted using
"##0.###E0" as "12.345E3".
Illegal patterns, such as "#.#.#" or mixing '_' and '*' in the same pattern,
will cause an IllegalArgumentException to be thrown. From the message of
IllegalArgumentException, you can find the place in the string where the
error occurred.
The grouping separator is commonly used for thousands, but in some countries
for ten-thousands. The interval is a constant number of digits between the
grouping characters, such as 100,000,000 or 1,0000,0000. If you supply a
pattern with multiple grouping characters, the interval between the last one
and the end of the integer is the one that is used. So "#,##,###,####" ==
"######,####" == "##,####,####".
- Version:
- 1.60
Constructor Summary |
SPrintF()
Constructor. |
Method Summary |
java.lang.String |
dispatch(java.lang.Object value,
java.lang.String pattern)
|
java.lang.String |
format(ArrayResult values,
java.lang.String pattern)
|
java.lang.String |
format(java.lang.Double value,
java.lang.String pattern)
|
java.lang.String |
format(java.lang.Integer value,
java.lang.String pattern)
|
java.lang.String |
format(java.lang.Long value,
java.lang.String pattern)
|
java.lang.String |
format(java.lang.Object[] values,
java.lang.String pattern)
|
java.lang.String |
format(java.lang.Object value,
java.lang.String pattern)
|
java.lang.String |
format(java.lang.String value,
java.lang.String pattern)
Method format calls the java.text.DecimalFormat class with the given
parameters. |
void |
run(MathEvaluator.MathCommunicator communicator,
java.util.Stack stack)
|
Methods inherited from class org.nfunk.jep.function.PostfixMathCommand |
getNumberOfParameters, getRootNode, run, setCurNumberOfParameters |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SPrintF
public SPrintF()
- Constructor.
format
public java.lang.String format(java.lang.String value,
java.lang.String pattern)
- Method format calls the java.text.DecimalFormat class with the given
parameters.
- Parameters:
number
- pattern
-
- Returns:
- String
format
public java.lang.String format(java.lang.Double value,
java.lang.String pattern)
format
public java.lang.String format(java.lang.Integer value,
java.lang.String pattern)
format
public java.lang.String format(java.lang.Long value,
java.lang.String pattern)
format
public java.lang.String format(java.lang.Object value,
java.lang.String pattern)
format
public java.lang.String format(java.lang.Object[] values,
java.lang.String pattern)
format
public java.lang.String format(ArrayResult values,
java.lang.String pattern)
dispatch
public java.lang.String dispatch(java.lang.Object value,
java.lang.String pattern)
run
public void run(MathEvaluator.MathCommunicator communicator,
java.util.Stack stack)
throws org.nfunk.jep.ParseException
- Specified by:
run
in class JaxfrontMathCommand
- Throws:
org.nfunk.jep.ParseException
- See Also:
org.nfunk.jep.function.PostfixMathCommandI#run(Stack)