|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.util.value.LongValue org.apache.wicket.util.lang.Bytes
public final class Bytes
Represents an immutable byte count. These static factory methods allow easy construction of value objects using either long values like bytes(2034) or megabytes(3):
or double precision floating point values like megabytes(3.2):
In the case of bytes(double), the value will be rounded off to the nearest integer byte count using Math.round().
The precise number of bytes in a Bytes object can be retrieved by calling bytes(). Approximate values for different units can be retrieved as double precision values using these methods:
Also, value objects can be constructed from strings, optionally using a Locale with valueOf(String) and valueOf(String,Locale). The string may contain a decimal or floating point number followed by optional whitespace followed by a unit (nothing for bytes, K for kilobyte, M for megabytes, G for gigabytes or T for terabytes) optionally followed by a B (for bytes). Any of these letters can be any case. So, examples of permissible string values are:
Note that if the Locale was not US, the values might substitute "," for "." as that is the custom in Euroland.
The toString() and toString(Locale) methods are smart enough to convert a given value object to the most appropriate units for the given value.
Field Summary | |
---|---|
static Bytes |
MAX
Maximum bytes value |
Fields inherited from class org.apache.wicket.util.value.LongValue |
---|
value |
Method Summary | |
---|---|
long |
bytes()
Gets the byte count represented by this value object. |
static Bytes |
bytes(double bytes)
Instantiate immutable Bytes value object.. |
static Bytes |
bytes(long bytes)
Instantiate immutable Bytes value object.. |
double |
gigabytes()
Gets the byte count in gigabytes. |
static Bytes |
gigabytes(double gigabytes)
Instantiate immutable Bytes value object.. |
static Bytes |
gigabytes(long gigabytes)
Instantiate immutable Bytes value object.. |
double |
kilobytes()
Gets the byte count in kilobytes. |
static Bytes |
kilobytes(double kilobytes)
Instantiate immutable Bytes value object.. |
static Bytes |
kilobytes(long kilobytes)
Instantiate immutable Bytes value object.. |
double |
megabytes()
Gets the byte count in megabytes. |
static Bytes |
megabytes(double megabytes)
Instantiate immutable Bytes value object.. |
static Bytes |
megabytes(long megabytes)
Instantiate immutable Bytes value object.. |
double |
terabytes()
Gets the byte count in terabytes. |
static Bytes |
terabytes(double terabytes)
Instantiate immutable Bytes value object.. |
static Bytes |
terabytes(long terabytes)
Instantiate immutable Bytes value object.. |
String |
toString()
Converts this byte count to a string using the default locale. |
String |
toString(Locale locale)
Converts this byte count to a string using the given locale. |
static Bytes |
valueOf(String string)
Converts a string to a number of bytes. |
static Bytes |
valueOf(String string,
Locale locale)
Converts a string to a number of bytes. |
Methods inherited from class org.apache.wicket.util.value.LongValue |
---|
compareTo, equals, greaterThan, greaterThan, hashCode, lessThan, lessThan |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Bytes MAX
Method Detail |
---|
public static Bytes bytes(long bytes)
bytes
- Value to convert
public static Bytes kilobytes(long kilobytes)
kilobytes
- Value to convert
public static Bytes megabytes(long megabytes)
megabytes
- Value to convert
public static Bytes gigabytes(long gigabytes)
gigabytes
- Value to convert
public static Bytes terabytes(long terabytes)
terabytes
- Value to convert
public static Bytes bytes(double bytes)
bytes
- Value to convert
public static Bytes kilobytes(double kilobytes)
kilobytes
- Value to convert
public static Bytes megabytes(double megabytes)
megabytes
- Value to convert
public static Bytes gigabytes(double gigabytes)
gigabytes
- Value to convert
public static Bytes terabytes(double terabytes)
terabytes
- Value to convert
public final long bytes()
public final double kilobytes()
public final double megabytes()
public final double gigabytes()
public final double terabytes()
public static Bytes valueOf(String string, Locale locale) throws StringValueConversionException
string
- The string to convertlocale
- The Locale to be used for transformation
StringValueConversionException
public static Bytes valueOf(String string) throws StringValueConversionException
string
- The string to convert
StringValueConversionException
public String toString()
toString
in class LongValue
public String toString(Locale locale)
locale
- Locale to use for conversion
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |