|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.flat502.rox.utils.Utils
public class Utils
This class provides various static utility routines used by the rest of this library.
Constructor Summary | |
---|---|
Utils()
|
Method Summary | ||
---|---|---|
static java.lang.Object |
coerce(java.lang.Object value,
java.lang.Class targetType)
|
|
static java.lang.Object |
convert(java.lang.Object value,
java.lang.Class targetType)
|
|
static java.security.cert.X509Certificate |
convert(javax.security.cert.X509Certificate cert)
|
|
static javax.security.cert.X509Certificate |
convert(java.security.cert.X509Certificate cert)
|
|
static java.lang.Object |
convertToArray(java.lang.Class targetType,
java.lang.Object value)
|
|
static boolean[] |
convertToBooleanArray(java.util.List list)
|
|
static double[] |
convertToDoubleArray(java.util.List list)
|
|
static float[] |
convertToFloatArray(java.util.List list)
|
|
static int[] |
convertToIntArray(java.util.List list)
|
|
static long[] |
convertToLongArray(java.util.List list)
|
|
static void |
dbgPrintln(java.lang.String msg)
A very simple utility routine to aid debugging. |
|
static java.nio.charset.Charset |
extractContentCharset(java.lang.String contentType)
Parses the value of an HTTP Content-Type
header and returns the specified character set. |
|
static java.lang.String |
extractContentType(java.lang.String contentType)
Parses the value of an HTTP Content-Type
header and returns the Internet Media Type
type and sub-type separated by a forwards-slash. |
|
static float |
getJavaRuntimeVersion()
|
|
static java.lang.String |
join(java.lang.String delim,
java.util.Iterator iter)
|
|
static java.lang.String |
join(java.lang.String delim,
java.lang.Object[] values)
|
|
static void |
main(java.lang.String[] args)
|
|
static java.io.Reader |
newXmlReader(java.io.InputStream in,
java.nio.charset.Charset hint)
Converts an InputStream containing XML into a
Reader using the encoding specified in the XML header. |
|
static java.lang.String |
normalizeHttpHeaderName(java.lang.String name)
Normalizes an HTTP header name. |
|
static java.lang.String |
normalizeURIPath(java.lang.String uri)
|
|
static
|
resize(T[] src,
int newsize)
|
|
static java.lang.String[] |
splitAt(java.lang.String input,
java.lang.String marker)
|
|
static java.lang.Object |
toArray(java.lang.Class targetType,
java.lang.Object value)
|
|
static boolean[] |
toBooleanArray(java.util.List list)
|
|
static double[] |
toDoubleArray(java.util.List list)
|
|
static float[] |
toFloatArray(java.util.List list)
|
|
static java.lang.String |
toHexDump(byte[] data)
|
|
static java.lang.String |
toHexDump(byte[] data,
int offset,
int length)
|
|
static int[] |
toIntArray(java.util.List list)
|
|
static long[] |
toLongArray(java.util.List list)
|
|
static java.lang.String |
toString(boolean[] list)
|
|
static java.lang.String |
toString(boolean[][] list)
|
|
static java.lang.String |
toString(int[] list)
|
|
static java.lang.String |
toString(java.lang.Object[] list)
|
|
static java.lang.String |
toString(java.security.Principal p)
|
|
static java.lang.String |
toString(java.nio.channels.SelectionKey key)
|
|
static java.lang.String |
toString(java.net.ServerSocket socket)
|
|
static java.lang.String |
toString(java.net.Socket socket)
|
|
static java.lang.String |
toString(javax.net.ssl.SSLSession session)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static java.nio.charset.Charset extractContentCharset(java.lang.String contentType)
Content-Type
header and returns the specified character set.
If no character set is specified then ISO-8859-1
is returned as per
section 3.7.1
of RFC 2616.
contentType
- The value of the Content-Type
header.
ISO-8859-1
if none was found.public static java.lang.String extractContentType(java.lang.String contentType)
Content-Type
header and returns the Internet Media Type
type and sub-type separated by a forwards-slash.
Any additional parameters (such as character set information) is discarded.
An example of a return value would be text/xml
.
contentType
- The value of the Content-Type
header.
java.lang.IllegalArgumentException
- if the value is malformed.public static java.lang.String normalizeURIPath(java.lang.String uri)
public static java.io.Reader newXmlReader(java.io.InputStream in, java.nio.charset.Charset hint) throws java.lang.Exception
InputStream
containing XML into a
Reader
using the encoding specified in the XML header.
The encoding is determined as specified by appendix F of version 1.0 of the XML specification.
in
- The input stream the XML document should be read from.hint
- An optional hint (may be null
) if the caller
has an idea of what the encoding may be.
Reader
instance backed by the given
InputStream
using the encoding specified
by the XML document within the stream.
java.lang.Exception
- if the underlying encoding cannot be determined, or
if an error occurs while constructing a reader to return.public static void dbgPrintln(java.lang.String msg)
The message is printed to stdout, prefixed with the name of the calling thread and the interval in milliseconds since this class was loaded. This is handy for simple "println" style debugging when relative timing is a factor.
msg
- The message to display.public static java.lang.String normalizeHttpHeaderName(java.lang.String name)
Normalization produces the logical equivalent of the following algorithm.
The name is split into words using the '-' character. Each word is then normalized by converting the first character to uppercase and all remaining characters to lowercase. The resulting words are joined again using the '-' character. The result is returned.
name
- The header name.
public static java.lang.String join(java.lang.String delim, java.lang.Object[] values)
public static java.lang.String join(java.lang.String delim, java.util.Iterator iter)
public static java.lang.Object toArray(java.lang.Class targetType, java.lang.Object value)
public static int[] toIntArray(java.util.List list)
public static long[] toLongArray(java.util.List list)
public static boolean[] toBooleanArray(java.util.List list)
public static float[] toFloatArray(java.util.List list)
public static double[] toDoubleArray(java.util.List list)
public static java.lang.Object coerce(java.lang.Object value, java.lang.Class targetType)
public static java.lang.Object convert(java.lang.Object value, java.lang.Class targetType)
public static java.lang.Object convertToArray(java.lang.Class targetType, java.lang.Object value)
public static int[] convertToIntArray(java.util.List list)
public static long[] convertToLongArray(java.util.List list)
public static boolean[] convertToBooleanArray(java.util.List list)
public static float[] convertToFloatArray(java.util.List list)
public static double[] convertToDoubleArray(java.util.List list)
public static java.lang.String toHexDump(byte[] data)
public static java.lang.String toHexDump(byte[] data, int offset, int length)
public static java.lang.String toString(int[] list)
public static java.lang.String toString(boolean[] list)
public static java.lang.String toString(boolean[][] list)
public static java.lang.String toString(java.lang.Object[] list)
public static java.lang.String toString(java.net.Socket socket)
public static java.lang.String toString(java.net.ServerSocket socket)
public static java.lang.String toString(java.nio.channels.SelectionKey key)
public static java.lang.String toString(javax.net.ssl.SSLSession session)
public static java.lang.String toString(java.security.Principal p)
public static float getJavaRuntimeVersion()
public static <T> T[] resize(T[] src, int newsize)
public static java.security.cert.X509Certificate convert(javax.security.cert.X509Certificate cert) throws javax.security.cert.CertificateEncodingException, java.security.cert.CertificateException
javax.security.cert.CertificateEncodingException
java.security.cert.CertificateException
public static javax.security.cert.X509Certificate convert(java.security.cert.X509Certificate cert) throws java.security.cert.CertificateEncodingException, javax.security.cert.CertificateException
java.security.cert.CertificateEncodingException
javax.security.cert.CertificateException
public static java.lang.String[] splitAt(java.lang.String input, java.lang.String marker)
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |