com.jivesoftware.spark.util
Class ByteFormat

java.lang.Object
  extended byjava.text.Format
      extended bycom.jivesoftware.spark.util.ByteFormat
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class ByteFormat
extends java.text.Format

A formatter for formatting byte sizes. For example, formatting 12345 byes results in "12.1 K" and 1234567 results in "1.18 MB".

Author:
Bill Lynch
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Constructor Summary
ByteFormat()
           
 
Method Summary
 java.lang.String format(long bytes)
          Formats a long which represent a number of bytes.
 java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer buf, java.text.FieldPosition pos)
          Format the given object (must be a Long).
 java.lang.String formatKB(long kilobytes)
          Formats a long which represent a number of kilobytes.
 java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition pos)
          In this implementation, returns null always.
 
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
 

Constructor Detail

ByteFormat

public ByteFormat()
Method Detail

format

public java.lang.String format(long bytes)
Formats a long which represent a number of bytes.


formatKB

public java.lang.String formatKB(long kilobytes)
Formats a long which represent a number of kilobytes.


format

public java.lang.StringBuffer format(java.lang.Object obj,
                                     java.lang.StringBuffer buf,
                                     java.text.FieldPosition pos)
Format the given object (must be a Long).

Parameters:
obj - assumed to be the number of bytes as a Long.
buf - the StringBuffer to append to.
pos -
Returns:
A formatted string representing the given bytes in more human-readable form.

parseObject

public java.lang.Object parseObject(java.lang.String source,
                                    java.text.ParsePosition pos)
In this implementation, returns null always.

Parameters:
source -
pos -
Returns:
returns null in this implementation.