view
Class TextFormat

java.lang.Object
  extended by view.TextFormat

public class TextFormat
extends Object

Class to provide formating routines for integers and doubles. Calling the format(int) method with a value of 3.1415926536 yields the following output:

   format(val)                                     >3.14159<
   format(val, 3.e-8)                              >3.14159265<
   format(val,7)                                   >3.1415927<
   format(val,13, 5)                               >      3.14159<
   format(val,13, 5, false)                        >      3.14159<
   format(val,18,6,true,true,true,false)           >3.1415930000000000<
   format(val,18,6, false,true, false, false)      >00000000003.141593<
   format(val,18,6, false,true, false, true)       >+0000000003.141593<
   format(val,18,0,true,false,false,false,false)   >                 3<
   


Field Summary
private static String COMMA
           
 
Constructor Summary
TextFormat()
           
 
Method Summary
static String dup(char what, int howoften)
          Returns a String containing howoften representations of char what.
static String format(double num)
           
static String format(double num, boolean suppress)
           
static String format(double num, double prec)
           
static String format(double num, double prec, boolean suppress)
           
static String format(double num, int prec)
           
static String format(double num, int prec, boolean suppress)
           
static String format(double num, int len, int prec)
           
static String format(double num, int len, int prec, boolean suppress)
           
static String format(double num, int len, int prec, boolean suppress, boolean zero)
           
static String format(double num, int len, int prec, boolean suppress, boolean zero, boolean rpad, boolean plus)
           
static String format(double num, int len, int prec, boolean suppress, boolean zero, boolean rpad, boolean plus, boolean coma)
           
static String format(int num)
           
static String format(int num, int len)
           
static String format(int num, int len, boolean zero)
           
static String format(int num, int len, boolean zero, boolean rpad, boolean plus)
           
static String format(long num)
           
static String format(long num, int len)
           
static String format(long num, int len, boolean zero)
           
static String format(long num, int len, boolean zero, boolean rpad, boolean plus)
           
protected static String getPad(boolean zero)
           
static double getRound(double num)
           
static double getRound(double num, int prec)
           
protected static String getSign(double num, boolean plus)
           
static String leftPadTo(String what, int len)
          Returns a string with the minimal given length, left-padded with spaces.
static String leftString(String arg, int left)
          Returns a String of length left, starting from arg index 0.
static void main(String[] arg)
           
static String rightPadTo(String what, int len)
          Returns a string with the minimal given length, right-padded with spaces.
static String rightString(String arg, int right)
          Returns the last right characters of arg as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMA

private static final String COMMA
See Also:
Constant Field Values
Constructor Detail

TextFormat

public TextFormat()
Method Detail

dup

public static String dup(char what,
                         int howoften)
Returns a String containing howoften representations of char what.


leftString

public static String leftString(String arg,
                                int left)
Returns a String of length left, starting from arg index 0.


rightString

public static String rightString(String arg,
                                 int right)
Returns the last right characters of arg as a String.


rightPadTo

public static final String rightPadTo(String what,
                                      int len)
Returns a string with the minimal given length, right-padded with spaces.


leftPadTo

public static final String leftPadTo(String what,
                                     int len)
Returns a string with the minimal given length, left-padded with spaces.


format

public static String format(int num)

format

public static String format(long num)

format

public static String format(int num,
                            int len)

format

public static String format(long num,
                            int len)

format

public static String format(int num,
                            int len,
                            boolean zero)

format

public static String format(long num,
                            int len,
                            boolean zero)

format

public static String format(int num,
                            int len,
                            boolean zero,
                            boolean rpad,
                            boolean plus)

getSign

protected static String getSign(double num,
                                boolean plus)

getPad

protected static String getPad(boolean zero)

format

public static String format(long num,
                            int len,
                            boolean zero,
                            boolean rpad,
                            boolean plus)

getRound

public static double getRound(double num)

getRound

public static double getRound(double num,
                              int prec)

format

public static String format(double num)

format

public static String format(double num,
                            boolean suppress)

format

public static String format(double num,
                            double prec)

format

public static String format(double num,
                            double prec,
                            boolean suppress)

format

public static String format(double num,
                            int prec)

format

public static String format(double num,
                            int prec,
                            boolean suppress)

format

public static String format(double num,
                            int len,
                            int prec)

format

public static String format(double num,
                            int len,
                            int prec,
                            boolean suppress)

format

public static String format(double num,
                            int len,
                            int prec,
                            boolean suppress,
                            boolean zero)

format

public static String format(double num,
                            int len,
                            int prec,
                            boolean suppress,
                            boolean zero,
                            boolean rpad,
                            boolean plus)

format

public static String format(double num,
                            int len,
                            int prec,
                            boolean suppress,
                            boolean zero,
                            boolean rpad,
                            boolean plus,
                            boolean coma)

main

public static void main(String[] arg)