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