|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nih.nci.caarray.util.CaArrayUtils
public final class CaArrayUtils
Utility classes for our project.
Method Summary | ||
---|---|---|
static void |
bindPropertiesAsNamed(java.lang.String resourceName,
com.google.inject.Binder binder)
Load a properties file from given classpath resource, and create a constant binding to @Named(key) for each property using the given binder. |
|
static void |
blankStringPropsToNull(java.lang.Object o)
For each String bean property on o, if o is blank or empty, converts that property to null. |
|
static ReflectionHelper |
createReflectionHelper(java.lang.Class<?> clazz)
For given class, returns a ReflectionHelper instance with property accessors for the class. |
|
static java.lang.String |
dequoteString(java.lang.String str)
Removes matched quotes (single or double) from a string. |
|
static java.io.Serializable |
deserialize(byte[] bytes)
Deserializes an object from a gzipped serialized representation. |
|
static java.io.Serializable |
deserialize(java.io.InputStream is)
Deserializes an object from a gzipped serialized representation. |
|
static java.lang.Object |
emptyCollectionOrMapFor(java.lang.Class<?> collectionType)
Returns an empty collection or map of the appropriate type for a given collection class. |
|
static
|
find(java.lang.Iterable<T> iterable,
com.google.common.base.Predicate<? super T> predicate)
Returns the first element in iterable that satisfies the given predicate, or null if no elements do. |
|
static byte[] |
gunzip(byte[] input)
returns a byte array representing the input byte array, un-gzipped. |
|
static byte[] |
gzip(byte[] input)
returns a byte array representing the input byte array, gzipped. |
|
static java.lang.String |
join(boolean[] values,
java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements. |
|
static java.lang.String |
join(double[] values,
java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements. |
|
static java.lang.String |
join(float[] values,
java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements. |
|
static java.lang.String |
join(int[] values,
java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements. |
|
static java.lang.String |
join(long[] values,
java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements. |
|
static java.lang.String |
join(short[] values,
java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements. |
|
static java.lang.String |
joinAsCsv(java.lang.String[] values)
Joins the given values as a comma-separated string. |
|
static java.net.URI |
makeUriQuietly(java.lang.String uri)
Utility method to create a URI from given string without throwing a checked exception. |
|
static java.net.URI |
makeUriQuietly(java.lang.String scheme,
java.lang.String schemeSpecificPart)
Utility method to create a URI from given scheme and scheme specific part without throwing a checked exception. |
|
static
|
namesForEnums(java.lang.Iterable<E> enums)
Return the constant names of the given enum instances. |
|
static byte[] |
serialize(java.io.Serializable serializable)
Serializes the given object (zipped) to a byte array. |
|
static java.lang.String[] |
splitFromCsv(java.lang.String s)
Splits the provided CSV String into an array of parsed values. |
|
static boolean[] |
splitIntoBooleans(java.lang.String s,
java.lang.String separator)
Splits the provided text into an array of parsed boolean values, using specified separator. |
|
static double[] |
splitIntoDoubles(java.lang.String s,
java.lang.String separator)
Splits the provided text into an array of parsed double values, using specified separator. |
|
static float[] |
splitIntoFloats(java.lang.String s,
java.lang.String separator)
Splits the provided text into an array of parsed float values, using specified separator. |
|
static int[] |
splitIntoInts(java.lang.String s,
java.lang.String separator)
Splits the provided text into an array of parsed int values, using specified separator. |
|
static long[] |
splitIntoLongs(java.lang.String s,
java.lang.String separator)
Splits the provided text into an array of parsed long values, using specified separator. |
|
static short[] |
splitIntoShorts(java.lang.String s,
java.lang.String separator)
Splits the provided text into an array of parsed short values, using specified separator. |
|
static
|
uniqueResult(java.util.Collection<T> results)
Method to take a get a unique result from a set and return it or null. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> T uniqueResult(java.util.Collection<T> results)
T
- the type of the returned objectresults
- the set of results returned from a query
public static java.lang.Object emptyCollectionOrMapFor(java.lang.Class<?> collectionType)
collectionType
- the class of whose type to return an empty collection or map
public static java.lang.String dequoteString(java.lang.String str)
str
- string to dequote
public static ReflectionHelper createReflectionHelper(java.lang.Class<?> clazz)
clazz
- the class
public static void blankStringPropsToNull(java.lang.Object o)
o
- object to convert properties on.public static java.lang.String join(boolean[] values, java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
values
- the values to join together, may be null (in which case an empty String is returned)separator
- the separator to use
public static java.lang.String join(int[] values, java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
values
- the values to join together, may be null (in which case an empty String is returned)separator
- the separator to use
public static java.lang.String join(long[] values, java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
values
- the values to join together, may be null (in which case an empty String is returned)separator
- the separator to use
public static java.lang.String join(short[] values, java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
values
- the values to join together, may be null (in which case an empty String is returned)separator
- the separator to use
public static java.lang.String join(double[] values, java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
values
- the values to join together, may be null (in which case an empty String is returned)separator
- the separator to use
public static java.lang.String join(float[] values, java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
values
- the values to join together, may be null (in which case an empty String is returned)separator
- the separator to use
public static java.lang.String joinAsCsv(java.lang.String[] values)
values
- the values to join (null is acceptable).
public static boolean[] splitIntoBooleans(java.lang.String s, java.lang.String separator)
Splits the provided text into an array of parsed boolean values, using specified separator.
Each value should be encoded using the literal representation of the XML Schema xs:boolean type
s
- the string to parseseparator
- the separator between values
public static short[] splitIntoShorts(java.lang.String s, java.lang.String separator)
Splits the provided text into an array of parsed short values, using specified separator.
Each value should be encoded using the literal representation of the XML Schema xs:short type
s
- the string to parseseparator
- the separator between values
public static long[] splitIntoLongs(java.lang.String s, java.lang.String separator)
Splits the provided text into an array of parsed long values, using specified separator.
Each value should be encoded using the literal representation of the XML Schema xs:long type
s
- the string to parseseparator
- the separator between values
public static int[] splitIntoInts(java.lang.String s, java.lang.String separator)
Splits the provided text into an array of parsed int values, using specified separator.
Each value should be encoded using the literal representation of the XML Schema xs:int type
s
- the string to parseseparator
- the separator between values
public static float[] splitIntoFloats(java.lang.String s, java.lang.String separator)
Splits the provided text into an array of parsed float values, using specified separator.
Each value should be encoded using the literal representation of the XML Schema xs:float type
s
- the string to parseseparator
- the separator between values
public static double[] splitIntoDoubles(java.lang.String s, java.lang.String separator)
Splits the provided text into an array of parsed double values, using specified separator.
Each value should be encoded using the literal representation of the XML Schema xs:double type
s
- the string to parseseparator
- the separator between values
public static java.lang.String[] splitFromCsv(java.lang.String s)
Splits the provided CSV String into an array of parsed values.
Each value within the String will be unescaped by converting any backslash-comma combinations back to commas.
s
- string containing a comma-separated list of strings.
public static <E extends java.lang.Enum<E>> java.util.Set<java.lang.String> namesForEnums(java.lang.Iterable<E> enums)
E
- the type of the enum instancesenums
- the enum instances whose constant names to return
public static byte[] serialize(java.io.Serializable serializable)
serializable
- object to serialize
public static java.io.Serializable deserialize(byte[] bytes)
bytes
- the byte array containing the gzipped serialized representation of an object
public static java.io.Serializable deserialize(java.io.InputStream is)
is
- the InputStream which will produce the gzipped serialized representation of an object
public static <T> T find(java.lang.Iterable<T> iterable, com.google.common.base.Predicate<? super T> predicate)
T
- the type of elements of iterableiterable
- the iterable to search throwpredicate
- the predicate to satisfy
public static java.net.URI makeUriQuietly(java.lang.String uri)
uri
- the URI string
public static java.net.URI makeUriQuietly(java.lang.String scheme, java.lang.String schemeSpecificPart)
scheme
- the schemeschemeSpecificPart
- the schemeSpecificPart
public static byte[] gzip(byte[] input) throws java.io.IOException
input
- the content to compress
java.io.IOException
- if there is a problem zipping the contentpublic static byte[] gunzip(byte[] input) throws java.io.IOException
input
- the content to uncompress, should be in gzip format
java.io.IOException
- if there is a problem uncompressing the content, including if the input is not gzippedpublic static void bindPropertiesAsNamed(java.lang.String resourceName, com.google.inject.Binder binder)
resourceName
- the resource to load. it is loaded using the classloader of this class.binder
- the binder to use for pinding the key=property values
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |