Class BytesSizeFormat

java.lang.Object
net.thevpc.nsh.util.bundles.BytesSizeFormat
All Implemented Interfaces:
Serializable, DoubleFormat

public class BytesSizeFormat extends Object implements DoubleFormat
Created by vpc on 3/20/17.
See Also:
  • 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, char high, char 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 java.lang.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, char high, char 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