Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.util
Class ByteFormat

java.lang.Object
  extended by java.text.Format
      extended by net.java.sip.communicator.util.ByteFormat
All Implemented Interfaces:
Serializable, Cloneable

public class ByteFormat
extends Format

Acknowledgment: This file was originally provided by the Ignite Realtime community, and was part of the Spark project (distributed under the terms of the LGPL). A formatter for formatting byte sizes. For example, formatting 12345 bytes results in "12.1 K" and 1234567 results in "1.18 MB".

Author:
Bill Lynch
See Also:
Serialized Form

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


formatKB

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

Parameters:
kilobytes - Long kbytes to format as a string.
Returns:
String representation of kbytes.

format

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

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

parseObject

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

Specified by:
parseObject in class Format
Parameters:
source - Source string to parse.
pos - Position to parse from.
Returns:
returns null in this implementation.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.