|
|||||||||
| Home >> All >> jreceiver >> util >> [ text overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
jreceiver.util.text
Class CompactFormat

java.lang.Objectjreceiver.util.text.CompactFormat
- public final class CompactFormat
- extends java.lang.Object
format a number in a brief and human-friendly manner
E.g., shortens 2362352523L to "2.6G"
Other examples of output: 1.8G, 997M, 3.0T, 1.3K, 342
TODO: add a 3,956K option like can be found in Windows explorer.
TODO: determine if localization can or should be done.
- Version:
- $Revision: 1.2 $ $Date: 2002/12/29 00:44:08 $
| Field Summary | |
static short |
DEFAULT_BLOCK_SIZE
represents a 'kilo' |
private static java.lang.String |
SUFFIXES
the suffixes to use for every step of blocksize |
| Constructor Summary | |
CompactFormat()
|
|
| Method Summary | |
protected static java.lang.String |
fmt(short kilos,
short val,
short remainder,
boolean is_negative,
int blocksize)
perform the final format |
static java.lang.String |
format(long n)
Format a long value to a human-friendly format. |
static java.lang.String |
format(long n,
int blocksize)
Format a long value to a human-friendly format. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
DEFAULT_BLOCK_SIZE
public static final short DEFAULT_BLOCK_SIZE
- represents a 'kilo'
- See Also:
- Constant Field Values
SUFFIXES
private static final java.lang.String SUFFIXES
- the suffixes to use for every step of blocksize
- See Also:
- Constant Field Values
| Constructor Detail |
CompactFormat
public CompactFormat()
| Method Detail |
format
public static java.lang.String format(long n)
- Format a long value to a human-friendly format.
For example, it shortens an unwieldy 2362352523L to "2.4G"
Other examples of output: 1.8G, -2.1G, 997M, 3.0T, 1.3K, 342
Note that the default blocksize of 1024 is used.
format
public static java.lang.String format(long n, int blocksize)
- Format a long value to a human-friendly format.
For example, it shortens an unwieldy 2362352523L to "2.4G"
Other examples of output: 1.8G, -2.1G, 997M, 3.0T, 1.3K, 342
fmt
protected static java.lang.String fmt(short kilos, short val, short remainder, boolean is_negative, int blocksize)
- perform the final format
e.g., 4,046,000,000 => 4.046 => "4.1G" if blocksize is 1000
Note that this only supports a single digit after the decimal place.
Note that an extra decimal of precision will only be included if the value is less than 100.
More flexibility could be added in the future.
|
|||||||||
| Home >> All >> jreceiver >> util >> [ text overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
jreceiver.util.text.CompactFormat