com.darwinsys.util
Class ScaledNumberFormat
java.lang.Object
java.text.Format
com.darwinsys.util.ScaledNumberFormat
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable
- public class ScaledNumberFormat
- extends java.text.Format
Format numbers scaled for human comprehension.
"Human-readable" output uses43 digits max, and puts unit suffixes at
the end. Makes output compact and easy-to-read esp. on huge disks.
Formatting code was originally in OpenBSD "df", converted to library routine.
Scanning code written by Ian Darwin, originally for OpenBSD libutil.
Rewritten in Java in January, 2001; re-synched with OpenBSD in 2004.
- Version:
- $Id: ScaledNumberFormat.java,v 1.7 2004/06/16 23:02:45 ian Exp $
- Author:
- Ian F. Darwin, http://www.darwinsys.com/
- See Also:
- Serialized Form
Nested classes inherited from class java.text.Format |
java.text.Format.Field |
Method Summary |
java.lang.String |
format(double n)
Format a double as a Scaled Numeral; just truncate to a
long, and call format(long). |
java.lang.String |
format(long number)
Format a given long as a Scaled Numeral. |
java.lang.StringBuffer |
format(java.lang.Object on,
java.lang.StringBuffer sb,
java.text.FieldPosition fp)
|
java.lang.Object |
parseObject(java.lang.String arg0)
|
java.lang.Object |
parseObject(java.lang.String s,
java.text.ParsePosition where)
Parse a String expected to contain a number in Human Scaled Form. |
Methods inherited from class java.text.Format |
clone, format, formatToCharacterIterator |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ScaledNumberFormat
public ScaledNumberFormat()
parseObject
public java.lang.Object parseObject(java.lang.String s,
java.text.ParsePosition where)
- Parse a String expected to contain a number in Human Scaled Form.
- Parameters:
where
- Ignored - required by API
- Returns:
- a Long containing the value (value is always
integral, even though has a fractional part before scaling).
parseObject
public java.lang.Object parseObject(java.lang.String arg0)
throws java.text.ParseException
- Throws:
java.text.ParseException
format
public java.lang.StringBuffer format(java.lang.Object on,
java.lang.StringBuffer sb,
java.text.FieldPosition fp)
format
public java.lang.String format(double n)
- Format a double as a Scaled Numeral; just truncate to a
long, and call format(long).
format
public java.lang.String format(long number)
- Format a given long as a Scaled Numeral.
This method is the REAL FORMATTING ENGINE.
Copyright © 2000-2003 Ian F. Darwin. See license.html for usage license.