public final class Utils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
addEntities(java.lang.String value)
Replace characters that could be interpreted as HTML codes with symbolic
references (entities).
|
static void |
bufferedCopy(java.io.InputStream source,
java.io.OutputStream destination)
Copy stream-data from source to destination, with buffering.
|
static void |
copy(java.io.InputStream input,
java.io.OutputStream output)
Copy stream-data from source to destination.
|
static java.lang.String |
formatISO8601Date(java.util.Date d)
Convert a Date to String in the ISO 8601 standard format.
|
static byte[] |
generateBytesKey()
Generate a unique key as a byte array.
|
static java.lang.String |
generateHexKey()
Generate a unique key.
|
static java.lang.String |
generateKey()
Generate a unique key.
|
static java.lang.String |
getMD5(byte[] data)
Return an MD5 checksum for data in hex format.
|
static java.lang.String |
getMD5(java.lang.String data)
Return an MD5 checksum for data in hex format.
|
static byte[] |
getMD5Bytes(byte[] data)
Return an MD5 checksum for data as a byte array.
|
static long |
parseDuration(java.lang.String duration)
Utility method to parse durations defined as \d+[smhdwy] (seconds,
minutes, hours, days, weeks, years)
|
static java.util.Date |
parseISO8601Date(java.lang.String s)
Translates timestamp from an ISO 8601-standard format, which
is commonly used in XML and RDF documents.
|
static java.lang.String |
toHex(byte[] data)
Return a hex representation of the byte array
|
public static java.lang.String getMD5(java.lang.String data)
data - The data to checksum.public static java.lang.String getMD5(byte[] data)
data - The data to checksum.public static byte[] getMD5Bytes(byte[] data)
data - The data to checksum.public static java.lang.String toHex(byte[] data)
data - The data to transform.public static java.lang.String generateKey()
public static java.lang.String generateHexKey()
public static byte[] generateBytesKey()
public static void copy(java.io.InputStream input,
java.io.OutputStream output)
throws java.io.IOException
bufferedCopy(java.io.InputStream, java.io.OutputStream).input - The InputStream to obtain data from.output - The OutputStream to copy data to.java.io.IOExceptionpublic static void bufferedCopy(java.io.InputStream source,
java.io.OutputStream destination)
throws java.io.IOException
copy(java.io.InputStream, java.io.OutputStream)a
java.io.BufferedInputStream and
java.io.BufferedOutputStream to copy(java.io.InputStream, java.io.OutputStream), and
flushing the output stream afterwards. The streams are not closed after
the copy.source - The InputStream to obtain data from.destination - The OutputStream to copy data to.java.io.IOExceptionpublic static java.lang.String addEntities(java.lang.String value)
value - the metadata value to be scrubbed for displaypublic static long parseDuration(java.lang.String duration)
throws java.text.ParseException
duration - specified durationjava.text.ParseException - if the duration is of incorrect formatpublic static java.util.Date parseISO8601Date(java.lang.String s)
s - the input stringpublic static java.lang.String formatISO8601Date(java.util.Date d)
d - the input DateCopyright © 2018 DuraSpace. All Rights Reserved.