Class _BytesSizeFormat

java.lang.Object
net.thevpc.common.mon._BytesSizeFormat

public class _BytesSizeFormat extends Object
Created by vpc on 3/20/17.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final _BytesSizeFormat
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    _BytesSizeFormat(boolean leadingZeros, boolean intermediateZeros, boolean fixedLength, boolean binaryPrefix, long high, long low, int depth)
     
    Size format is a sequence of commands : B,K,M,G,T : Show Bytes/Kilo/Mega/Giga/Tera, if this is the first multiplier it will be considered as the minimum multiplier otherwise it will be considered as the maximum multiplier I : binary prefix (use 1024 multipliers) D : multiplier maximum depth, should be suffixed with an integer (i.e BTD2 means that if number is in giga will not show further than kilo) F : fixed length Z : if used in the very first position (0) consider leadingZeros, if at the last position consider trailing zeros if anywhere else consider intermediateZeros examples
  • Method Summary

    Modifier and Type
    Method
    Description
    format(long bytes)
     
    formatDouble(double value)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • _BytesSizeFormat

      public _BytesSizeFormat(boolean leadingZeros, boolean intermediateZeros, boolean fixedLength, boolean binaryPrefix, long high, long low, int depth)
    • _BytesSizeFormat

      public _BytesSizeFormat()
    • _BytesSizeFormat

      public _BytesSizeFormat(String format)
      Size format is a sequence of commands :
      • B,K,M,G,T : Show Bytes/Kilo/Mega/Giga/Tera, if this is the first multiplier it will be considered as the minimum multiplier otherwise it will be considered as the maximum multiplier
      • I : binary prefix (use 1024 multipliers)
      • D : multiplier maximum depth, should be suffixed with an integer (i.e BTD2 means that if number is in giga will not show further than kilo)
      • F : fixed length
      • Z : if used in the very first position (0) consider leadingZeros, if at the last position consider trailing zeros if anywhere else consider intermediateZeros
      examples
            System.out.println(new MemorySizeFormatter("0I0BEF0").format(1073741824));
            0Ei   0Pi   0Ti   1Gi   0Mi   0Ki
      
            System.out.println(new MemorySizeFormatter("00BEF0").format(1073741824));
            0E   0P   0T   1G  73M 741K 824B
      
            System.out.println(new MemorySizeFormatter("B0TD1F").format(1073741824));
            1G
      
            System.out.println(new MemorySizeFormatter("B0TD2F").format(1073741824));
            1G  73M
      
            System.out.println(new MemorySizeFormatter("B0TD3F").format(1073741824));
            1G  73M 741K
      
            System.out.println(new MemorySizeFormatter("B0TD1FI").format(1073741824));
            1Gi
      
            System.out.println(new MemorySizeFormatter("B0TD2FI").format(1073741824));
            1Gi
      
            System.out.println(new MemorySizeFormatter("B0TD3FI").format(1073741824));
            1Gi
      
            System.out.println(new MemorySizeFormatter("0I0BEF0").format(1073741824));
            0Ei   0Pi   0Ti   1Gi   0Mi   0Ki
      
            System.out.println(new MemorySizeFormatter("I0BEF").format(1073741824));
            1Gi
      
            System.out.println(new MemorySizeFormatter("IBEF").format(1073741824));
            1Gi
      
            System.out.println(new MemorySizeFormatter("0IBTF").format(1073741824));
            0Ti   1Gi
      
      
      
      Parameters:
      format - size format
  • Method Details

    • formatDouble

      public String formatDouble(double value)
    • format

      public String format(long bytes)