|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jstatcom.util.FArg
public final class FArg
Since Java 1.5 one should rather use Formatter.format
instead
of this class. However, this one is a bit more tolerant against wrongly specified
input.
Formatting argument class that originally served as an adapter to
PrintfFormat
. whith a more convenient and shorter syntax.
Usage note:
One should use the static method sprintf
and construct a new
FArg
instance to hold parameters. Further arguments can be
appended very C-like with a varargs argument, for example:
FArg.sprintf("%-13s %- 8.4f", "statistic:", 2.345)
PrintfFormat
Constructor Summary | |
---|---|
FArg(double arg)
FArg double constructor. |
|
FArg(int arg)
FArg int constructor. |
|
FArg(java.lang.Object arg)
FArg Object constructor. |
Method Summary | |
---|---|
FArg |
add(double arg)
Adds a new double argument to be formatted. |
FArg |
add(int arg)
Adds a new int argument to be formatted. |
FArg |
add(java.lang.Object arg)
Adds a new Object argument to be formatted. |
java.lang.Object[] |
getArgs()
Gets the stored arguments as an object array that can be used with PrintfFormat.sprintf . |
static java.lang.String |
sprintf(java.lang.String formatString,
FArg args)
A wrapper method for the PrintfFormat.sprintf method. |
static java.lang.String |
sprintf(java.lang.String formatString,
java.lang.Object... args)
A wrapper method for the PrintfFormat.sprintf method with
a convenient vararg argument. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FArg(double arg)
FArg double
constructor.
arg
- double to be formattedpublic FArg(int arg)
FArg int
constructor.
arg
- int to be formattedpublic FArg(java.lang.Object arg)
FArg Object
constructor.
arg
- object to be formattedMethod Detail |
---|
public FArg add(double arg)
double
argument to be formatted.
arg
- the element to be formatted
this
after adding arg
public FArg add(int arg)
int
argument to be formatted.
arg
- the element to be formatted
this
after adding arg
public FArg add(java.lang.Object arg)
Object
argument to be formatted.
arg
- the element to be formatted
this
after adding arg
public java.lang.Object[] getArgs()
PrintfFormat.sprintf
.
public static java.lang.String sprintf(java.lang.String formatString, FArg args)
PrintfFormat.sprintf
method. It
is slightly shorter and that resembles the syntax used by the
com.braju
toolset (by exchanging Format
and
Parameters
with FArg
).
formatString
- the string for formatting args
, see the
PrinfFormat
documentationargs
- the object containing the arguments in the correct order
according to the formatting string
java.lang.IllegalArgumentException
- if (formatString == null || args == null)
PrintfFormat
public static java.lang.String sprintf(java.lang.String formatString, java.lang.Object... args)
PrintfFormat.sprintf
method with
a convenient vararg argument.
formatString
- the string for formatting args
, see the
PrinfFormat
documentationargs
- strings or numbers to be formated
java.lang.IllegalArgumentException
- if (formatString == null)
PrintfFormat
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |