Class DisplayFormatters

java.lang.Object
com.biglybt.core.util.DisplayFormatters

public class DisplayFormatters extends Object
  • Field Details

    • ROUND_NO

      private static final boolean ROUND_NO
      See Also:
    • TRUNCZEROS_NO

      private static final boolean TRUNCZEROS_NO
      See Also:
    • TRUNCZEROS_YES

      private static final boolean TRUNCZEROS_YES
      See Also:
    • UNIT_B

      public static final int UNIT_B
      See Also:
    • UNIT_KB

      public static final int UNIT_KB
      See Also:
    • UNIT_MB

      public static final int UNIT_MB
      See Also:
    • UNIT_GB

      public static final int UNIT_GB
      See Also:
    • UNIT_TB

      public static final int UNIT_TB
      See Also:
    • UNITS_PRECISION

      private static final int[] UNITS_PRECISION
    • cached_number_formats

      private static final NumberFormat[] cached_number_formats
    • percentage_format

      private static NumberFormat percentage_format
    • all_units

      private static final String[] all_units
    • units

      private static String[] units
    • units_bits

      private static String[] units_bits
    • units_rate

      private static String[] units_rate
    • unitsStopAt

      private static int unitsStopAt
    • units_base10

      private static String[] units_base10
    • per_sec

      private static String per_sec
    • use_si_units

      private static boolean use_si_units
    • force_si_values

      private static boolean force_si_values
    • use_units_rate_bits

      private static boolean use_units_rate_bits
    • not_use_GB_TB

      private static boolean not_use_GB_TB
    • message_text_state

      private static int message_text_state
    • separate_prot_data_stats

      private static boolean separate_prot_data_stats
    • data_stats_only

      private static boolean data_stats_only
    • decimalSeparator

      private static char decimalSeparator
    • format_map

      private static volatile Map<String,DisplayFormatters.Formatter> format_map
    • PeerManager_status_finished

      private static String PeerManager_status_finished
    • PeerManager_status_finishedin

      private static String PeerManager_status_finishedin
    • Formats_units_alot

      private static String Formats_units_alot
    • discarded

      private static String discarded
    • ManagerItem_waiting

      private static String ManagerItem_waiting
    • ManagerItem_initializing

      private static String ManagerItem_initializing
    • ManagerItem_allocating

      private static String ManagerItem_allocating
    • ManagerItem_checking

      private static String ManagerItem_checking
    • ManagerItem_finishing

      private static String ManagerItem_finishing
    • ManagerItem_ready

      private static String ManagerItem_ready
    • ManagerItem_downloading

      private static String ManagerItem_downloading
    • ManagerItem_swarmMerge

      private static String ManagerItem_swarmMerge
    • ManagerItem_seeding

      private static String ManagerItem_seeding
    • ManagerItem_lightseeding

      private static String ManagerItem_lightseeding
    • ManagerItem_superseeding

      private static String ManagerItem_superseeding
    • ManagerItem_stopping

      private static String ManagerItem_stopping
    • ManagerItem_stopped

      private static String ManagerItem_stopped
    • ManagerItem_paused

      private static String ManagerItem_paused
    • ManagerItem_queued

      private static String ManagerItem_queued
    • ManagerItem_error

      private static String ManagerItem_error
    • ManagerItem_forced

      private static String ManagerItem_forced
    • ManagerItem_moving

      private static String ManagerItem_moving
    • ManagerItem_unallocated

      private static String ManagerItem_unallocated
    • yes

      private static String yes
    • no

      private static String no
    • abs_df

      private static final SimpleDateFormat abs_df
    • ydmhm_df

      private static final SimpleDateFormat ydmhm_df
    • share_ratio_progress_interval

      private static int share_ratio_progress_interval
  • Constructor Details

    • DisplayFormatters

      public DisplayFormatters()
  • Method Details

    • setUnits

      public static void setUnits()
    • getUnit

      private static String getUnit(String key)
    • loadMessages

      public static void loadMessages()
    • getResourceString

      private static String getResourceString(String key, String def)
    • 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()
    • getMinB

      public static long getMinB()
    • 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)
      Deprecated.
      Dunno who thought this was a good idea to use decimal calc but binary/decimal selected unit text
      Print the BITS/second in an international format.
      Parameters:
      n - - always formatted using SI (i.e. decimal) prefixes
      Returns:
      String in an internationalized format.
    • formatByteCountToBitsPerSec2

      public static String formatByteCountToBitsPerSec2(long n)
      Prints byte value in BITS/second in either binary or decimal units as required
      Parameters:
      n - byte count
      Returns:
    • formatETA

      public static String formatETA(long eta)
    • formatDateYMDHM

      public static String formatDateYMDHM(long time)
    • 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

      private static String formatDate(long date, String format)
    • 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()
    • updateFormatOverrides

      private static void updateFormatOverrides(String formats)
    • parseFloat

      public static float parseFloat(DecimalFormat df, String str) throws NumberFormatException
      Throws:
      NumberFormatException
    • formatCustomRate

      public static String formatCustomRate(String key, long value)
    • formatCustomSize

      public static String formatCustomSize(String key, long value)
    • getShareRatioProgressInfo

      public static long[] getShareRatioProgressInfo(DownloadManager dm)
    • main

      public static void main(String[] args)