JavaView® v2.00.a4 Debug

jv.thirdParty.fmt
Class Fmt

java.lang.Object
  |
  +--jv.thirdParty.fmt.Fmt

public class Fmt
extends java.lang.Object

Fmt - some simple single-arg sprintf-like routines Copyright (C) 1996 by Jef Poskanzer . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Visit the ACME Labs Java page for up-to-date versions of this and other fine Java utilities: http://www.acme.com/java/ 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:


Field Summary
static int HX
          Flag Hexadecimal.
static int LJ
          Flag Left justify.
static int OC
          Flag Octal.
static int ZF
          Flag Zero-fill.
 
Constructor Summary
Fmt()
           
 
Method Summary
static java.lang.String doubleToString(double d)
          Deprecated.  
static java.lang.String fmt(byte b)
           
static java.lang.String fmt(byte b, int minWidth)
           
static java.lang.String fmt(byte b, int minWidth, int flags)
           
static java.lang.String fmt(char c)
           
static java.lang.String fmt(char c, int minWidth)
           
static java.lang.String fmt(char c, int minWidth, int flags)
           
static java.lang.String fmt(double d)
           
static java.lang.String fmt(double d, int minWidth)
           
static java.lang.String fmt(double d, int minWidth, int sigFigs)
           
static java.lang.String fmt(double d, int minWidth, int sigFigs, int flags)
           
static java.lang.String fmt(float f)
           
static java.lang.String fmt(float f, int minWidth)
           
static java.lang.String fmt(float f, int minWidth, int sigFigs)
           
static java.lang.String fmt(float f, int minWidth, int sigFigs, int flags)
           
static java.lang.String fmt(int i)
           
static java.lang.String fmt(int i, int minWidth)
           
static java.lang.String fmt(int i, int minWidth, int flags)
           
static java.lang.String fmt(long l)
           
static java.lang.String fmt(long l, int minWidth)
           
static java.lang.String fmt(long l, int minWidth, int flags)
           
static java.lang.String fmt(java.lang.Object o)
           
static java.lang.String fmt(java.lang.Object o, int minWidth)
           
static java.lang.String fmt(java.lang.Object o, int minWidth, int flags)
           
static java.lang.String fmt(short s)
          short
static java.lang.String fmt(short s, int minWidth)
           
static java.lang.String fmt(short s, int minWidth, int flags)
           
static java.lang.String fmt(java.lang.String s)
           
static java.lang.String fmt(java.lang.String s, int minWidth)
           
static java.lang.String fmt(java.lang.String s, int minWidth, int flags)
           
static void main(java.lang.String[] args)
          Test program.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZF

public static final int ZF
Flag Zero-fill.

LJ

public static final int LJ
Flag Left justify.

HX

public static final int HX
Flag Hexadecimal.

OC

public static final int OC
Flag Octal.
Constructor Detail

Fmt

public Fmt()
Method Detail

fmt

public static java.lang.String fmt(byte b)

fmt

public static java.lang.String fmt(byte b,
                                   int minWidth)

fmt

public static java.lang.String fmt(byte b,
                                   int minWidth,
                                   int flags)

fmt

public static java.lang.String fmt(short s)
short

fmt

public static java.lang.String fmt(short s,
                                   int minWidth)

fmt

public static java.lang.String fmt(short s,
                                   int minWidth,
                                   int flags)

fmt

public static java.lang.String fmt(int i)

fmt

public static java.lang.String fmt(int i,
                                   int minWidth)

fmt

public static java.lang.String fmt(int i,
                                   int minWidth,
                                   int flags)

fmt

public static java.lang.String fmt(long l)

fmt

public static java.lang.String fmt(long l,
                                   int minWidth)

fmt

public static java.lang.String fmt(long l,
                                   int minWidth,
                                   int flags)

fmt

public static java.lang.String fmt(float f)

fmt

public static java.lang.String fmt(float f,
                                   int minWidth)

fmt

public static java.lang.String fmt(float f,
                                   int minWidth,
                                   int sigFigs)

fmt

public static java.lang.String fmt(float f,
                                   int minWidth,
                                   int sigFigs,
                                   int flags)

fmt

public static java.lang.String fmt(double d)

fmt

public static java.lang.String fmt(double d,
                                   int minWidth)

fmt

public static java.lang.String fmt(double d,
                                   int minWidth,
                                   int sigFigs)

fmt

public static java.lang.String fmt(double d,
                                   int minWidth,
                                   int sigFigs,
                                   int flags)

fmt

public static java.lang.String fmt(char c)

fmt

public static java.lang.String fmt(char c,
                                   int minWidth)

fmt

public static java.lang.String fmt(char c,
                                   int minWidth,
                                   int flags)

fmt

public static java.lang.String fmt(java.lang.Object o)

fmt

public static java.lang.String fmt(java.lang.Object o,
                                   int minWidth)

fmt

public static java.lang.String fmt(java.lang.Object o,
                                   int minWidth,
                                   int flags)

fmt

public static java.lang.String fmt(java.lang.String s)

fmt

public static java.lang.String fmt(java.lang.String s,
                                   int minWidth)

fmt

public static java.lang.String fmt(java.lang.String s,
                                   int minWidth,
                                   int flags)

doubleToString

public static java.lang.String doubleToString(double d)
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:
java.lang.Double#toString

main

public static void main(java.lang.String[] args)
Test program.

JavaView® v2.00.a4 Debug

The software JavaView® is copyright protected. All Rights Reserved.