org.apache.pivot.text
Class FileSizeFormat

java.lang.Object
  extended by java.text.Format
      extended by org.apache.pivot.text.FileSizeFormat
All Implemented Interfaces:
Serializable, Cloneable

public class FileSizeFormat
extends Format

Converts a file size into a human-readable representation using binary prefixes (1KB = 1024 bytes).

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.Format
Format.Field
 
Field Summary
static String[] ABBREVIATIONS
           
static int KILOBYTE
           
 
Method Summary
 StringBuffer format(Object object, StringBuffer stringBuffer, FieldPosition fieldPosition)
          Formats a file size.
static FileSizeFormat getInstance()
          Returns a shared file size format instance.
 Object parseObject(String arg0, ParsePosition arg1)
          This method is not supported.
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KILOBYTE

public static final int KILOBYTE
See Also:
Constant Field Values

ABBREVIATIONS

public static final String[] ABBREVIATIONS
Method Detail

format

public StringBuffer format(Object object,
                           StringBuffer stringBuffer,
                           FieldPosition fieldPosition)
Formats a file size.

Specified by:
format in class Format
Parameters:
object - A Number containing the length of the file, in bytes. May be negative to indicate an unknown file size.
stringBuffer - The string buffer to which the formatted output will be appended.
fieldPosition - Not used.
Returns:
The original string buffer, with the formatted value appended.

parseObject

public Object parseObject(String arg0,
                          ParsePosition arg1)
This method is not supported.

Specified by:
parseObject in class Format
Throws:
UnsupportedOperationException

getInstance

public static FileSizeFormat getInstance()
Returns a shared file size format instance.

Returns:
A shared file format size instance.