com.mucommander.text
Class SizeFormat

java.lang.Object
  extended by com.mucommander.text.SizeFormat

public class SizeFormat
extends java.lang.Object

SizeFormat formats byte sizes into localized string representations.

Author:
Maxence Bernard.

Field Summary
static int BYTE_UNIT
          Byte unit
static int DIGITS_FULL
          Bitmask for full digits, e.g.
static int DIGITS_MEDIUM
          Bitmask for medium digits, e.g.
static int DIGITS_SHORT
          Bitmask for short digits, e.g.
static int GIGABYTE_UNIT
          Gigabyte unit
static int INCLUDE_SPACE
          Bitmask to include a space character to separate the digits and unit parts
static int KILOBYTE_UNIT
          Kilobyte unit
static int MEGABYTE_UNIT
          Megabyte unit
static int ROUND_TO_KB
          Bitmask to round any size < 1KB to 1KB (except 0 which will be 0 KB)
static int TERABYTE_UNIT
          Terabyte unit
static int UNIT_LONG
          Bitmask for short unit string, e.g.
static int UNIT_NONE
          Bitmask for no unit string
static int UNIT_SHORT
          Bitmask for short unit string, e.g.
static int UNIT_SPEED
          Bitmask to add '/s' (per second) to the returned String
 
Constructor Summary
SizeFormat()
           
 
Method Summary
static java.lang.String format(long size, int format)
          Returns a String representation of the given byte size.
static long getUnitBytes(int unit)
          Returns the size in bytes of the given byte unit, e.g.
static java.lang.String getUnitString(int unit, boolean speedUnit)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIGITS_SHORT

public static final int DIGITS_SHORT
Bitmask for short digits, e.g. "15"

See Also:
Constant Field Values

DIGITS_MEDIUM

public static final int DIGITS_MEDIUM
Bitmask for medium digits, e.g. "15,2"

See Also:
Constant Field Values

DIGITS_FULL

public static final int DIGITS_FULL
Bitmask for full digits, e.g. "15,204,405"

See Also:
Constant Field Values

UNIT_NONE

public static final int UNIT_NONE
Bitmask for no unit string

See Also:
Constant Field Values

UNIT_SHORT

public static final int UNIT_SHORT
Bitmask for short unit string, e.g. "b"

See Also:
Constant Field Values

UNIT_LONG

public static final int UNIT_LONG
Bitmask for short unit string, e.g. "bytes"

See Also:
Constant Field Values

BYTE_UNIT

public static final int BYTE_UNIT
Byte unit

See Also:
Constant Field Values

KILOBYTE_UNIT

public static final int KILOBYTE_UNIT
Kilobyte unit

See Also:
Constant Field Values

MEGABYTE_UNIT

public static final int MEGABYTE_UNIT
Megabyte unit

See Also:
Constant Field Values

GIGABYTE_UNIT

public static final int GIGABYTE_UNIT
Gigabyte unit

See Also:
Constant Field Values

TERABYTE_UNIT

public static final int TERABYTE_UNIT
Terabyte unit

See Also:
Constant Field Values

UNIT_SPEED

public static final int UNIT_SPEED
Bitmask to add '/s' (per second) to the returned String

See Also:
Constant Field Values

INCLUDE_SPACE

public static final int INCLUDE_SPACE
Bitmask to include a space character to separate the digits and unit parts

See Also:
Constant Field Values

ROUND_TO_KB

public static final int ROUND_TO_KB
Bitmask to round any size < 1KB to 1KB (except 0 which will be 0 KB)

See Also:
Constant Field Values
Constructor Detail

SizeFormat

public SizeFormat()
Method Detail

format

public static java.lang.String format(long size,
                                      int format)
Returns a String representation of the given byte size.

Parameters:
size - the size to format
format - format bitmask, see constant fields for allowed values
Returns:
a String representation of the given byte size

getUnitString

public static java.lang.String getUnitString(int unit,
                                             boolean speedUnit)

getUnitBytes

public static long getUnitBytes(int unit)
Returns the size in bytes of the given byte unit, e.g. 1024 for KILOBYTE_UNIT.

Parameters:
unit - a unit constant, see constant fields for allowed values
Returns:
the size in bytes of the given byte unit


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard