All Packages  Class Hierarchy  This Package  Previous  Next  Index


Class Acme.Fmt

java.lang.Object
   |
   +----Acme.Fmt

public class Fmt
extends Object
Some simple single-arg sprintf-like routines.

It is apparently impossible to declare a Java method that accepts variable numbers of any type of argument. You can declare it to take Objects, but numeric variables and constants are not in fact Objects.

However, using the built-in string concatenation, it's almost as convenient to make a series of single-argument formatting routines.

Fmt can format the following types:

byte short int long float double char String Object
For each type there is a set of overloaded methods, each returning a formatted String. There's the plain formatting version:
 Fmt.fmt( x )
 
There's a version specifying a minimum field width:
 Fmt.fmt( x, minWidth )
 
And there's a version that takes flags:
 Fmt.fmt( x, minWidth, flags )
 
Currently available flags are:
 Fmt.ZF - zero-fill
 Fmt.LJ - left justify
 Fmt.HX - hexadecimal
 Fmt.OC - octal
 
The HX and OC flags imply unsigned output.

For doubles and floats, there's a significant-figures parameter before the flags:

 Fmt.fmt( d )
 Fmt.fmt( d, minWidth )
 Fmt.fmt( d, minWidth, sigFigs )
 Fmt.fmt( d, minWidth, sigFigs, flags )
 

Fetch the software.
Fetch the entire Acme package.


Similar classes:


Variable Index

 o HX
Hexadecimal.
 o LJ
Left justify.
 o OC
Octal.
 o ZF
Zero-fill.

Constructor Index

 o Fmt()

Method Index

 o doubleToString(double)
Improved version of Double.toString(), returns more decimal places. Deprecated.
 o fmt(byte)
 o fmt(byte, int)
 o fmt(byte, int, int)
 o fmt(char)
 o fmt(char, int)
 o fmt(char, int, int)
 o fmt(double)
 o fmt(double, int)
 o fmt(double, int, int)
 o fmt(double, int, int, int)
 o fmt(float)
 o fmt(float, int)
 o fmt(float, int, int)
 o fmt(float, int, int, int)
 o fmt(int)
 o fmt(int, int)
 o fmt(int, int, int)
 o fmt(long)
 o fmt(long, int)
 o fmt(long, int, int)
 o fmt(Object)
 o fmt(Object, int)
 o fmt(Object, int, int)
 o fmt(short)
 o fmt(short, int)
 o fmt(short, int, int)
 o fmt(String)
 o fmt(String, int)
 o fmt(String, int, int)

Variables

 o ZF
 public static final int ZF
Zero-fill.

 o LJ
 public static final int LJ
Left justify.

 o HX
 public static final int HX
Hexadecimal.

 o OC
 public static final int OC
Octal.

Constructors

 o Fmt
 public Fmt()

Methods

 o fmt
 public static String fmt(byte b)
 o fmt
 public static String fmt(byte b,
                          int minWidth)
 o fmt
 public static String fmt(byte b,
                          int minWidth,
                          int flags)
 o fmt
 public static String fmt(short s)
 o fmt
 public static String fmt(short s,
                          int minWidth)
 o fmt
 public static String fmt(short s,
                          int minWidth,
                          int flags)
 o fmt
 public static String fmt(int i)
 o fmt
 public static String fmt(int i,
                          int minWidth)
 o fmt
 public static String fmt(int i,
                          int minWidth,
                          int flags)
 o fmt
 public static String fmt(long l)
 o fmt
 public static String fmt(long l,
                          int minWidth)
 o fmt
 public static String fmt(long l,
                          int minWidth,
                          int flags)
 o fmt
 public static String fmt(float f)
 o fmt
 public static String fmt(float f,
                          int minWidth)
 o fmt
 public static String fmt(float f,
                          int minWidth,
                          int sigFigs)
 o fmt
 public static String fmt(float f,
                          int minWidth,
                          int sigFigs,
                          int flags)
 o fmt
 public static String fmt(double d)
 o fmt
 public static String fmt(double d,
                          int minWidth)
 o fmt
 public static String fmt(double d,
                          int minWidth,
                          int sigFigs)
 o fmt
 public static String fmt(double d,
                          int minWidth,
                          int sigFigs,
                          int flags)
 o fmt
 public static String fmt(char c)
 o fmt
 public static String fmt(char c,
                          int minWidth)
 o fmt
 public static String fmt(char c,
                          int minWidth,
                          int flags)
 o fmt
 public static String fmt(Object o)
 o fmt
 public static String fmt(Object o,
                          int minWidth)
 o fmt
 public static String fmt(Object o,
                          int minWidth,
                          int flags)
 o fmt
 public static String fmt(String s)
 o fmt
 public static String fmt(String s,
                          int minWidth)
 o fmt
 public static String fmt(String s,
                          int minWidth,
                          int flags)
 o doubleToString
 public static String doubleToString(double d)
Note: doubleToString() is deprecated.

Improved version of Double.toString(), returns more decimal places.

The JDK 1.0.2 version of Double.toString() returns only six decimal places on some systems. In JDK 1.1 full precision is returned on all platforms.

See Also:
toString

All Packages  Class Hierarchy  This Package  Previous  Next  Index

ACME Java  ACME Labs