org.gudy.azureus2.core3.util
Class DisplayFormatters

java.lang.Object
  extended by org.gudy.azureus2.core3.util.DisplayFormatters

public class DisplayFormatters
extends Object


Field Summary
static int UNIT_B
           
static int UNIT_GB
           
static int UNIT_KB
           
static int UNIT_MB
           
static int UNIT_TB
           
 
Constructor Summary
DisplayFormatters()
           
 
Method Summary
static String formatByteCountToBase10KBEtc(long n)
           
static String formatByteCountToBase10KBEtcPerSec(long n)
           
static String formatByteCountToBitsPerSec(long n)
          Print the BITS/second in an international format.
static String formatByteCountToKiBEtc(int n)
           
static String formatByteCountToKiBEtc(long n)
           
static String formatByteCountToKiBEtc(long n, boolean bTruncateZeros)
           
static String formatByteCountToKiBEtc(long n, boolean rate, boolean bTruncateZeros)
           
static String formatByteCountToKiBEtc(long n, boolean rate, boolean bTruncateZeros, int precision)
           
static String formatByteCountToKiBEtc(long n, boolean rate, boolean bTruncateZeros, int precision, int minUnit)
           
static String formatByteCountToKiBEtcPerSec(long n)
           
static String formatByteCountToKiBEtcPerSec(long n, boolean bTruncateZeros)
           
static String formatCustomDateOnly(long date)
           
static String formatCustomDateTime(long date)
           
static String formatCustomRate(String key, long value)
           
static String formatCustomSize(String key, long value)
           
static String formatCustomTimeOnly(long date)
           
static String formatCustomTimeOnly(long date, boolean with_secs)
           
static String formatDataProtByteCountToKiBEtc(long data, long prot)
           
static String formatDataProtByteCountToKiBEtcPerSec(long data, long prot)
           
static String formatDate(long date)
           
static String formatDateNum(long date)
           
static String formatDateShort(long date)
           
static String formatDecimal(double value, int precision)
          Format a real number to the precision specified.
static String formatDecimal(double value, int precision, boolean bTruncateZeros, boolean bRound)
          Format a real number
static String formatDownloaded(DownloadManagerStats stats)
           
static String formatDownloadStatus(DownloadManager manager)
           
static String formatDownloadStatusDefaultLocale(DownloadManager manager)
           
static String formatETA(long eta)
           
static String formatETA(long eta, boolean abs)
           
static String formatHashFails(DownloadManager download_manager)
           
static String formatIntToTwoDigits(int n)
           
static String formatPercentFromThousands(int thousands)
           
static String formatTime(long time)
           
static String formatTimeStamp(long time)
           
static char getDecimalSeparator()
           
static int getKinB()
           
static String getRateUnit(int unit_size)
           
static String getRateUnitBase10(int unit_size)
           
static String getUnit(int unit_size)
           
static String getUnitBase10(int unit_size)
           
static String getYesNo(boolean b)
           
static boolean isDataProtSeparate()
           
static boolean isRateUsingBits()
           
static void loadMessages()
           
static void main(String[] args)
           
static void setUnits()
           
static String trimDigits(String str, int num_digits)
           
static String truncateString(String str, int width)
          Attempts vaguely smart string truncation by searching for largest token and truncating that
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNIT_B

public static final int UNIT_B
See Also:
Constant Field Values

UNIT_KB

public static final int UNIT_KB
See Also:
Constant Field Values

UNIT_MB

public static final int UNIT_MB
See Also:
Constant Field Values

UNIT_GB

public static final int UNIT_GB
See Also:
Constant Field Values

UNIT_TB

public static final int UNIT_TB
See Also:
Constant Field Values
Constructor Detail

DisplayFormatters

public DisplayFormatters()
Method Detail

setUnits

public static void setUnits()

loadMessages

public static void loadMessages()

getYesNo

public static String getYesNo(boolean b)

getRateUnit

public static String getRateUnit(int unit_size)

getUnit

public static String getUnit(int unit_size)

getRateUnitBase10

public static String getRateUnitBase10(int unit_size)

getUnitBase10

public static String getUnitBase10(int unit_size)

isRateUsingBits

public static boolean isRateUsingBits()

formatByteCountToKiBEtc

public static String formatByteCountToKiBEtc(int n)

formatByteCountToKiBEtc

public static String formatByteCountToKiBEtc(long n)

formatByteCountToKiBEtc

public static String formatByteCountToKiBEtc(long n,
                                             boolean bTruncateZeros)

formatByteCountToKiBEtc

public static String formatByteCountToKiBEtc(long n,
                                             boolean rate,
                                             boolean bTruncateZeros)

getKinB

public static int getKinB()

formatByteCountToKiBEtc

public static String formatByteCountToKiBEtc(long n,
                                             boolean rate,
                                             boolean bTruncateZeros,
                                             int precision)

formatByteCountToKiBEtc

public static String formatByteCountToKiBEtc(long n,
                                             boolean rate,
                                             boolean bTruncateZeros,
                                             int precision,
                                             int minUnit)

isDataProtSeparate

public static boolean isDataProtSeparate()

formatDataProtByteCountToKiBEtc

public static String formatDataProtByteCountToKiBEtc(long data,
                                                     long prot)

formatDataProtByteCountToKiBEtcPerSec

public static String formatDataProtByteCountToKiBEtcPerSec(long data,
                                                           long prot)

formatByteCountToKiBEtcPerSec

public static String formatByteCountToKiBEtcPerSec(long n)

formatByteCountToKiBEtcPerSec

public static String formatByteCountToKiBEtcPerSec(long n,
                                                   boolean bTruncateZeros)

formatByteCountToBase10KBEtc

public static String formatByteCountToBase10KBEtc(long n)

formatByteCountToBase10KBEtcPerSec

public static String formatByteCountToBase10KBEtcPerSec(long n)

formatByteCountToBitsPerSec

public static String formatByteCountToBitsPerSec(long n)
Print the BITS/second in an international format.

Parameters:
n - - always formatted using SI (i.e. decimal) prefixes
Returns:
String in an internationalized format.

formatETA

public static String formatETA(long eta)

formatETA

public static String formatETA(long eta,
                               boolean abs)

formatDownloaded

public static String formatDownloaded(DownloadManagerStats stats)

formatHashFails

public static String formatHashFails(DownloadManager download_manager)

formatDownloadStatus

public static String formatDownloadStatus(DownloadManager manager)

formatDownloadStatusDefaultLocale

public static String formatDownloadStatusDefaultLocale(DownloadManager manager)

trimDigits

public static String trimDigits(String str,
                                int num_digits)

formatPercentFromThousands

public static String formatPercentFromThousands(int thousands)

formatTimeStamp

public static String formatTimeStamp(long time)

formatIntToTwoDigits

public static String formatIntToTwoDigits(int n)

formatDate

public static String formatDate(long date)

formatDateShort

public static String formatDateShort(long date)

formatDateNum

public static String formatDateNum(long date)

formatCustomDateOnly

public static String formatCustomDateOnly(long date)

formatCustomTimeOnly

public static String formatCustomTimeOnly(long date)

formatCustomTimeOnly

public static String formatCustomTimeOnly(long date,
                                          boolean with_secs)

formatCustomDateTime

public static String formatCustomDateTime(long date)

formatTime

public static String formatTime(long time)

formatDecimal

public static String formatDecimal(double value,
                                   int precision)
Format a real number to the precision specified. Does not round the number or truncate trailing zeros.

Parameters:
value - real number to format
precision - # of digits after the decimal place
Returns:
formatted string

formatDecimal

public static String formatDecimal(double value,
                                   int precision,
                                   boolean bTruncateZeros,
                                   boolean bRound)
Format a real number

Parameters:
value - real number to format
precision - max # of digits after the decimal place
bTruncateZeros - remove any trailing zeros after decimal place
bRound - Whether the number will be rounded to the precision, or truncated off.
Returns:
formatted string

truncateString

public static String truncateString(String str,
                                    int width)
Attempts vaguely smart string truncation by searching for largest token and truncating that

Parameters:
str -
width -
Returns:

getDecimalSeparator

public static char getDecimalSeparator()

formatCustomRate

public static String formatCustomRate(String key,
                                      long value)

formatCustomSize

public static String formatCustomSize(String key,
                                      long value)

main

public static void main(String[] args)