Package org.appng.api

Enum FileUpload.Unit

    • Method Detail

      • values

        public static FileUpload.Unit[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (FileUpload.Unit c : FileUpload.Unit.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static FileUpload.Unit valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getFactor

        public long getFactor()
        the factor to multiply with to get the number of bytes per whole unit
        Returns:
        the factor
      • format

        public static String format​(FileUpload.Unit unit,
                                    long size,
                                    NumberFormat format)
        Formats the given size of the given FileUpload.Unit using a NumberFormat, appending the given FileUpload.Unit.
        Example:
         NumberFormat numberFormat = new DecimalFormat("0.0# ", new DecimalFormatSymbols(Locale.ENGLISH));
         String format = Unit.format(Unit.MB, (long) (2.46d * 1024l * 1024l), numberFormat);
         org.junit.Assert.assertEquals("2.46 MB", format);
         
         
        Parameters:
        unit - the FileUpload.Unit
        size - the size in bytes
        format - the NumberFormat
        Returns:
        the formatted size