Openfire 3.6.1 Javadoc

org.jivesoftware.util
Class ByteFormat

java.lang.Object
  extended by java.text.Format
      extended by org.jivesoftware.util.ByteFormat
All Implemented Interfaces:
Serializable, Cloneable

public class ByteFormat
extends 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/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.


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 -
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 -
pos -
Returns:
returns null in this implementation.

Openfire 3.6.1 Javadoc

Copyright © 2003-2008 Jive Software.