Class DisplayFormatters
java.lang.Object
com.biglybt.core.util.DisplayFormatters
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final SimpleDateFormatprivate static final String[]private static final NumberFormat[]private static booleanprivate static charprivate static Stringprivate static booleanprivate static Map<String, DisplayFormatters.Formatter> private static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static intprivate static Stringprivate static booleanprivate static Stringprivate static Stringprivate static Stringprivate static NumberFormatprivate static final booleanprivate static booleanprivate static intprivate static final booleanprivate static final booleanstatic final intstatic final intstatic final intstatic final intstatic final intprivate static String[]private static String[]private static String[]private static final int[]private static String[]private static intprivate static booleanprivate static booleanprivate static final SimpleDateFormatprivate static String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatByteCountToBase10KBEtc(long n) static Stringstatic StringformatByteCountToBitsPerSec(long n) Deprecated.Dunno who thought this was a good idea to use decimal calc but binary/decimal selected unit textstatic StringformatByteCountToBitsPerSec2(long n) Prints byte value in BITS/second in either binary or decimal units as requiredstatic StringformatByteCountToKiBEtc(int n) static StringformatByteCountToKiBEtc(long n) static StringformatByteCountToKiBEtc(long n, boolean bTruncateZeros) static StringformatByteCountToKiBEtc(long n, boolean rate, boolean bTruncateZeros) static StringformatByteCountToKiBEtc(long n, boolean rate, boolean bTruncateZeros, int precision) static StringformatByteCountToKiBEtc(long n, boolean rate, boolean bTruncateZeros, int precision, int minUnit) static StringformatByteCountToKiBEtcPerSec(long n) static StringformatByteCountToKiBEtcPerSec(long n, boolean bTruncateZeros) static StringformatCustomDateOnly(long date) static StringformatCustomDateTime(long date) static StringformatCustomRate(String key, long value) static StringformatCustomSize(String key, long value) static StringformatCustomTimeOnly(long date) static StringformatCustomTimeOnly(long date, boolean with_secs) static StringformatDataProtByteCountToKiBEtc(long data, long prot) static StringformatDataProtByteCountToKiBEtcPerSec(long data, long prot) static StringformatDate(long date) private static StringformatDate(long date, String format) static StringformatDateNum(long date) static StringformatDateShort(long date) static StringformatDateYMDHM(long time) static StringformatDateYMDHMS(long time) static StringformatDecimal(double value, int precision) Format a real number to the precision specified.static StringformatDecimal(double value, int precision, boolean bTruncateZeros, boolean bRound) Format a real numberstatic Stringstatic StringformatDownloadStatus(DownloadManager manager) static Stringstatic StringformatETA(long eta) static StringformatETA(long eta, boolean abs) static StringformatHashFails(DownloadManager download_manager) static StringformatIntToTwoDigits(int n) static StringformatPercentFromThousands(int thousands) static StringformatTime(long time) static StringformatTimeStamp(long time) static charstatic intgetKinB()static longgetMinB()static StringgetRateUnit(int unit_size) static StringgetRateUnitBase10(int unit_size) private static StringgetResourceString(String key, String def) static long[]static StringgetUnit(int unit_size) private static Stringstatic StringgetUnitBase10(int unit_size) static intstatic StringgetYesNo(boolean b) static booleanstatic booleanstatic voidstatic voidstatic floatparseFloat(DecimalFormat df, String str) static voidsetUnits()static StringtrimDigits(String str, int num_digits) static StringtruncateString(String str, int width) Attempts vaguely smart string truncation by searching for largest token and truncating thatprivate static voidupdateFormatOverrides(String formats)
-
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
-
percentage_format
-
all_units
-
units
-
units_bits
-
units_rate
-
unitsStopAt
private static int unitsStopAt -
units_base10
-
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
-
PeerManager_status_finished
-
PeerManager_status_finishedin
-
Formats_units_alot
-
discarded
-
ManagerItem_waiting
-
ManagerItem_initializing
-
ManagerItem_allocating
-
ManagerItem_checking
-
ManagerItem_finishing
-
ManagerItem_ready
-
ManagerItem_downloading
-
ManagerItem_swarmMerge
-
ManagerItem_seeding
-
ManagerItem_lightseeding
-
ManagerItem_superseeding
-
ManagerItem_stopping
-
ManagerItem_stopped
-
ManagerItem_paused
-
ManagerItem_queued
-
ManagerItem_error
-
ManagerItem_forced
-
ManagerItem_moving
-
ManagerItem_unallocated
-
yes
-
no
-
abs_df
-
ydmhm_df
-
-
Constructor Details
-
DisplayFormatters
public DisplayFormatters()
-
-
Method Details
-
setUnits
public static void setUnits() -
getUnit
-
loadMessages
public static void loadMessages() -
getResourceString
-
getYesNo
-
getRateUnit
-
getUnit
-
getRateUnitBase10
-
getUnitBase10
-
isRateUsingBits
public static boolean isRateUsingBits() -
formatByteCountToKiBEtc
-
formatByteCountToKiBEtc
-
formatByteCountToKiBEtc
-
formatByteCountToKiBEtc
-
getXinBBase
public static int getXinBBase() -
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
-
formatDataProtByteCountToKiBEtcPerSec
-
formatByteCountToKiBEtcPerSec
-
formatByteCountToKiBEtcPerSec
-
formatByteCountToBase10KBEtc
-
formatByteCountToBase10KBEtcPerSec
-
formatByteCountToBitsPerSec
Deprecated.Dunno who thought this was a good idea to use decimal calc but binary/decimal selected unit textPrint the BITS/second in an international format.- Parameters:
n- - always formatted using SI (i.e. decimal) prefixes- Returns:
- String in an internationalized format.
-
formatByteCountToBitsPerSec2
Prints byte value in BITS/second in either binary or decimal units as required- Parameters:
n- byte count- Returns:
-
formatETA
-
formatDateYMDHMS
-
formatDateYMDHM
-
formatETA
-
formatDownloaded
-
formatHashFails
-
formatDownloadStatus
-
formatDownloadStatusDefaultLocale
-
trimDigits
-
formatPercentFromThousands
-
formatTimeStamp
-
formatIntToTwoDigits
-
formatDate
-
formatDate
-
formatDateShort
-
formatDateNum
-
formatCustomDateOnly
-
formatCustomTimeOnly
-
formatCustomTimeOnly
-
formatCustomDateTime
-
formatTime
-
formatDecimal
Format a real number to the precision specified. Does not round the number or truncate trailing zeros.- Parameters:
value- real number to formatprecision- # 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 formatprecision- max # of digits after the decimal placebTruncateZeros- remove any trailing zeros after decimal placebRound- Whether the number will be rounded to the precision, or truncated off.- Returns:
- formatted string
-
truncateString
-
getDecimalSeparator
public static char getDecimalSeparator() -
updateFormatOverrides
-
parseFloat
- Throws:
NumberFormatException
-
formatCustomRate
-
formatCustomSize
-
main
-