com.jstatcom.util
Class FArg
- java.lang.Object
-
- com.jstatcom.util.FArg
-
public final class FArg extends java.lang.ObjectSince Java 1.5 one should rather useFormatter.formatinstead 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 methodsprintfand construct a newFArginstance 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)- See Also:
PrintfFormat
-
-
Constructor Summary
Constructors Constructor and Description FArg(double arg)FArg doubleconstructor.FArg(int arg)FArg intconstructor.FArg(java.lang.Object arg)FArg Objectconstructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description FArgadd(double arg)Adds a newdoubleargument to be formatted.FArgadd(int arg)Adds a newintargument to be formatted.FArgadd(java.lang.Object arg)Adds a newObjectargument to be formatted.java.lang.Object[]getArgs()Gets the stored arguments as an object array that can be used withPrintfFormat.sprintf.static java.lang.Stringsprintf(java.lang.String formatString, FArg args)The String.format method should be used instead.static java.lang.Stringsprintf(java.lang.String formatString, java.lang.Object... args)The String.format method should be used instead.
-
-
-
Constructor Detail
-
FArg
public FArg(double arg)
FArg doubleconstructor.- Parameters:
arg- double to be formatted
-
FArg
public FArg(int arg)
FArg intconstructor.- Parameters:
arg- int to be formatted
-
FArg
public FArg(java.lang.Object arg)
FArg Objectconstructor.- Parameters:
arg- object to be formatted
-
-
Method Detail
-
add
public FArg add(double arg)
Adds a newdoubleargument to be formatted.- Parameters:
arg- the element to be formatted- Returns:
thisafter addingarg
-
add
public FArg add(int arg)
Adds a newintargument to be formatted.- Parameters:
arg- the element to be formatted- Returns:
thisafter addingarg
-
add
public FArg add(java.lang.Object arg)
Adds a newObjectargument to be formatted.- Parameters:
arg- the element to be formatted- Returns:
thisafter addingarg
-
getArgs
public java.lang.Object[] getArgs()
Gets the stored arguments as an object array that can be used withPrintfFormat.sprintf.- Returns:
- the object array
-
sprintf
public static java.lang.String sprintf(java.lang.String formatString, FArg args)The String.format method should be used instead. A wrapper method for thePrintfFormat.sprintfmethod. It is slightly shorter and that resembles the syntax used by thecom.brajutoolset (by exchangingFormatandParameterswithFArg).- Parameters:
formatString- the string for formattingargs, see thePrinfFormatdocumentationargs- the object containing the arguments in the correct order according to the formatting string- Returns:
- the formatted string
- Throws:
java.lang.IllegalArgumentException-if (formatString == null || args == null)- See Also:
PrintfFormat
-
sprintf
public static java.lang.String sprintf(java.lang.String formatString, java.lang.Object... args)The String.format method should be used instead. A wrapper method for thePrintfFormat.sprintfmethod with a convenient vararg argument.- Parameters:
formatString- the string for formattingargs, see thePrinfFormatdocumentationargs- strings or numbers to be formated- Returns:
- the formatted string
- Throws:
java.lang.IllegalArgumentException-if (formatString == null)- See Also:
PrintfFormat
-
-
DMelt 3.0 © DataMelt by jWork.ORG