Package org.apache.pivot.text
Class FileSizeFormat
- java.lang.Object
-
- java.text.Format
-
- org.apache.pivot.text.FileSizeFormat
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public final class FileSizeFormat extends java.text.Format
Converts a file size into a human-readable representation using binary prefixes (1KB = 1024 bytes). Only supports display and not parsing.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]
ABBREVIATIONS
The list of first letter abbreviations for each kilobyte power.static int
KILOBYTE
The binary value of a "kilo"byte.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringBuffer
format(java.lang.Object object, java.lang.StringBuffer stringBuffer, java.text.FieldPosition fieldPosition)
Formats a file size.static FileSizeFormat
getInstance()
Returns a shared file size format instance.java.lang.Object
parseObject(java.lang.String arg0, java.text.ParsePosition arg1)
This method is not supported.
-
-
-
Field Detail
-
KILOBYTE
public static final int KILOBYTE
The binary value of a "kilo"byte.- See Also:
- Constant Field Values
-
ABBREVIATIONS
public static final java.lang.String[] ABBREVIATIONS
The list of first letter abbreviations for each kilobyte power.
-
-
Method Detail
-
format
public java.lang.StringBuffer format(java.lang.Object object, java.lang.StringBuffer stringBuffer, java.text.FieldPosition fieldPosition)
Formats a file size.- Specified by:
format
in classjava.text.Format
- Parameters:
object
- ANumber
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
@UnsupportedOperation public java.lang.Object parseObject(java.lang.String arg0, java.text.ParsePosition arg1)
This method is not supported.- Specified by:
parseObject
in classjava.text.Format
- Throws:
java.lang.UnsupportedOperationException
- always.
-
getInstance
public static FileSizeFormat getInstance()
Returns a shared file size format instance.- Returns:
- A shared instance of this object.
-
-