public static enum FileUpload.Unit extends Enum<FileUpload.Unit>
Modifier and Type | Method and Description |
---|---|
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: |
String |
format(long size,
NumberFormat format)
Formats the given size using a
NumberFormat |
long |
getFactor()
the factor to multiply with to get the number of bytes per whole unit
|
static FileUpload.Unit |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static FileUpload.Unit[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final FileUpload.Unit B
public static final FileUpload.Unit KB
public static final FileUpload.Unit MB
public static FileUpload.Unit[] values()
for (FileUpload.Unit c : FileUpload.Unit.values()) System.out.println(c);
public static FileUpload.Unit valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic long getFactor()
public String format(long size, NumberFormat format)
NumberFormat
size
- the size in bytesformat
- the NumberFormat
format(FileUpload.Unit, long, NumberFormat)
public static String format(FileUpload.Unit unit, long size, NumberFormat format)
FileUpload.Unit
using a NumberFormat
, appending the given
FileUpload.Unit
.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);
unit
- the FileUpload.Unit
size
- the size in bytesformat
- the NumberFormat
Copyright © 2011–2020 aiticon GmbH. All rights reserved.