Documentation of 'com.jstatcom.util.FArg' Java class
FArg
com.jstatcom.util

Class FArg



  • public final class FArg
    extends java.lang.Object
    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)

    See Also:
    PrintfFormat
    • Constructor Summary

      Constructors 
      Constructor and Description
      FArg(double arg)
      FArg double constructor.
      FArg(int arg)
      FArg int constructor.
      FArg(java.lang.Object arg)
      FArg Object constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      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)
      The String.format method should be used instead.
      static java.lang.String sprintf(java.lang.String formatString, java.lang.Object... args)
      The String.format method should be used instead.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FArg

        public FArg(double arg)
        FArg double constructor.
        Parameters:
        arg - double to be formatted
      • FArg

        public FArg(int arg)
        FArg int constructor.
        Parameters:
        arg - int to be formatted
      • FArg

        public FArg(java.lang.Object arg)
        FArg Object constructor.
        Parameters:
        arg - object to be formatted
    • Method Detail

      • add

        public FArg add(double arg)
        Adds a new double argument to be formatted.
        Parameters:
        arg - the element to be formatted
        Returns:
        this after adding arg
      • add

        public FArg add(int arg)
        Adds a new int argument to be formatted.
        Parameters:
        arg - the element to be formatted
        Returns:
        this after adding arg
      • add

        public FArg add(java.lang.Object arg)
        Adds a new Object argument to be formatted.
        Parameters:
        arg - the element to be formatted
        Returns:
        this after adding arg
      • getArgs

        public java.lang.Object[] getArgs()
        Gets the stored arguments as an object array that can be used with PrintfFormat.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 the 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).
        Parameters:
        formatString - the string for formatting args, see the PrinfFormat documentation
        args - 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 the PrintfFormat.sprintf method with a convenient vararg argument.
        Parameters:
        formatString - the string for formatting args, see the PrinfFormat documentation
        args - 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

You see the box below because you did not login.