sailpoint.tools

## Class Util

- java.lang.Object
- - sailpoint.tools.Util

    public class Util
    extends java.lang.Object

Various utilities.

### Nested Class Summary

Nested Classes
`static interface` `Util.IConverter<T1,T2>`
`static interface` `Util.IMatcher<T>`
`static interface` `Util.ListElementWrapper<T>` A ListElementWrapper is responsible for wrapping (or transforming) each element of a List when the element is retrieved from the list.
`static interface` `Util.ListFilter<T>` Interface that is used with filter(List<T>, ListFilter<T>) to specify which elements should not be included in the filtered list.
`static class` `Util.ParseException` A runtime exception that is thrown when decoding fails.

### Field Summary

Fields
`static java.lang.String` `APPLICATION_HOME` The system property that indicates our "home" directory.
`static long` `MILLI_IN_DAY`
`static long` `MILLI_IN_HOUR`
`static long` `MILLI_IN_MINUTE`
`static long` `MILLI_IN_MONTH`
`static long` `MILLI_IN_SECOND`
`static long` `MILLI_IN_WEEK`
`static long` `MILLI_IN_YEAR`
`static long` `MILLIS_PER_DAY`

### Constructor Summary

Constructors
Constructor and Description
`Util()`

### Method Summary

All Methods Static Methods Concrete Methods
`static <T> java.util.List<T>` `arrayToList(T[] array)` Given an array, returns a list.
`static java.util.List` `asList(java.lang.Object o)` Return a List with the given object.
`static boolean` `atob(java.lang.String a)`
`static float` `atof(java.lang.String a)`
`static int` `atoi(java.lang.String a)` Convert a String value into a primitive integer value.
`static int` `atoi(java.lang.String a, int def)` Convert a String value into a primitive integer value.
`static long` `atol(java.lang.String a)`
`static java.util.Date` `baselineDate(java.util.Date src)`
`static java.util.Date` `baselineDate(java.util.Date src, java.util.TimeZone timeZone)` Get the baseline date for the source date.
`static java.lang.String` `bytesToString(byte[] bytes)`
`static java.lang.String` `capitalize(java.lang.String str)` Capitalizes the first letter in the given String Example: hElLo becomes HElLo
`static java.lang.String` `capitalizeAndNormalize(java.lang.String str)` Capitalizes the first letter in the given String and lowercases the rest of the String Example: hElLo becomes Hello
`static <T> T` `caseInsensitiveKeyValue(java.util.Map<java.lang.String,T> map, java.lang.String key)` Will search for the key in a case insensitive fashion.
`static java.lang.String` `compressWhiteSpace(java.lang.String str)` This method strips leading and trailing whitespace and guarantees that there is at most one space between characters in the output.
`static java.lang.String` `computeDifference(java.util.Date start, java.util.Date end)`
`static long` `computeDifferenceMilli(java.util.Date start, java.util.Date end)`
`static boolean` `containsAny(java.util.Collection c1, java.util.Collection c2)` Return whether c1 contains any elements found in c2.
`static <T extends java.lang.Comparable<? super T>> boolean` `containsComparable(java.util.List<T> list, T toFind, boolean sorted)` Return whether the given list of comparable items contains the give item according to the Comparable interface.
`static <T1,T2> java.util.List<T2>` `convert(java.util.List<T1> list1, Util.IConverter<T1,T2> converter)` Converts a list of one type into another, IConverter defines the function that is used for the conversion
`static void` `copyFile(java.lang.String src, java.lang.String dest)` Copies one file to another.
`static int` `countChars(java.lang.String sourceString, char lookFor)` Look through a source string looking for the number of occurrences of a given character.
`static java.lang.Object` `createObjectByClassName(java.lang.String name)` Create a new instance of an object by classname.
`static java.lang.String[]` `csvToArray(java.lang.String src)`
`static java.util.List<java.lang.String>` `csvToList(java.lang.String src)` Convert a comma delimited string into a List of strings.
`static java.util.List<java.lang.String>` `csvToList(java.lang.String src, boolean filterEmpty)`
`static java.util.Set<java.lang.String>` `csvToSet(java.lang.String src, boolean filterEmpty)`
`static java.util.Date` `dateBetween(java.util.Date startDate, java.util.Date endDate)`
`static java.lang.String` `dateToString(java.util.Date src)` Format a Date value as a String, using the usual "American" format with the current time zone.
`static java.lang.String` `dateToString(java.util.Date src, java.lang.Integer dateFormat, java.lang.Integer timeFormat)`
`static java.lang.String` `dateToString(java.util.Date src, java.lang.Integer dateFormat, java.lang.Integer timeFormat, java.util.TimeZone timeZone, java.util.Locale locale)`
`static java.lang.String` `dateToString(java.util.Date src, java.lang.String format)`
`static java.lang.String` `dateToString(java.util.Date src, java.lang.String format, java.util.TimeZone tz)`
`static java.lang.String` `decodeJavaIdentifier(java.lang.String s)` Decode the given encoded java identifier to remove any encoded invalid characters and replace them with their original values.
`static java.lang.String` `deleteWhitespace(java.lang.String src)` Deletes any whitespace from the string
`static java.util.List<java.lang.String>` `delimToList(java.lang.String delim, java.lang.String src, boolean filterEmpty)`
`static long` `dottedQuadToLong(java.lang.String ipaddr)`
`static void` `dumpProperties()` Prints the current system properties to the system output device.
`static void` `dumpProperties(java.io.PrintWriter out)` Prints the current system properties to a writer object.
`static java.lang.String` `encodeJavaIdentifier(java.lang.String s)` Encode the given string into a valid java identifier (for example - does not start with a number, does not include spaces, commas, etc...) by replacing any invalid characters with the ASCII code of the character surrounded by double underscores.
`static java.lang.String` `escapeHTMLNewlines(java.lang.String src)` Escape newlines from the string into the HTML escaped newline and carriage return.
`static java.lang.String` `escapeNewlines(java.lang.String src)` Process a string to escape newline characters.
`static java.lang.String` `escapeNewlines(java.lang.String src, java.lang.String nRepl, java.lang.String rRepl)` Process a string to escape newline characters.
`static java.lang.String` `expandVariables(java.lang.String src, java.util.Map<java.lang.String,java.lang.Object> variables)` Process a string which may contain references to variables and substitute the values of those variables.
`static <T> java.util.List<T>` `filter(java.util.List<T> list, Util.ListFilter<T> filter)` Return a filtered copy of the given list with any elements that match the given ListFilter not included.
`static <T> java.util.List<T>` `filterNulls(java.util.List<T> src)` Remove nulls from a list.
`static <T> T` `find(java.util.List<T> list, T t, java.util.Comparator<T> comparator)` Find the requested object in the given list using the given comparator.
`static <T> T` `find(java.util.List<T> values, Util.IMatcher<T> matcher)` Looks through the list and returns an item which matches the IMatcher interface.
`static <T extends java.lang.Comparable<? super T>> T` `findComparable(java.util.List<T> list, T toFind, boolean sorted)` Return a matching object from the given list.
`static java.lang.String` `findFile(java.lang.String name)`
`static java.lang.String` `findFile(java.lang.String property, java.lang.String name)`
`static java.lang.String` `findFile(java.lang.String property, java.lang.String name, boolean searchClasspath)` Attempt to derive the absolute path of a file.
`static java.lang.String` `findOutputFile(java.lang.String name)` Build an absolute path name for a file.
`static void` `flushIterator(java.util.Iterator i)` Exhaust the remainder of the iterator so that Hibernate will properly close the cursor associated with it.
`static java.lang.String` `ftoa(float i)`
`static java.lang.Object` `get(java.util.Map map, java.lang.String name)`
`static java.lang.String` `getApplicationHome()` Returns the filesystem path for the application home.
`static java.util.Date` `getBeginningOfDay(java.util.Date day)`
`static boolean` `getBoolean(java.util.Map map, java.lang.String name)`
`static java.lang.String` `getClasspathDirectory(int idx)` Return the nth item on the CLASSPATH.
`static java.util.Date` `getDate(java.util.Map map, java.lang.String name)`
`static java.util.Date` `getDate(java.lang.Object o)` Try to derive a Date from a random object.
`static int` `getDaysDifference(java.util.Date d1, java.util.Date d2)` Return the number of days difference between the two given dates.
`static java.util.Date` `getEndOfDay(java.util.Date day)`
`static java.lang.String` `getFullname(java.lang.String first, java.lang.String last)` Return a fullname constructed from the given first and last names.
`static java.lang.String` `getHostName()`
`static java.util.ResourceBundle` `getIIQHelpMessages(java.util.Locale locale)`
`static java.util.ResourceBundle` `getIIQMessages(java.util.Locale locale)`
`static int` `getInt(java.util.Map map, java.lang.String name)`
`static java.lang.String` `getJsonSafeKey(java.lang.String key)` cannot have '.' in json key names change them to '-'
`static java.lang.String` `getKeyFromJsonSafeKey(java.lang.String jsonSafeKey)` Does the opposite of @link {getJsonSafeKey}
`static long` `getLongDifference(java.util.Date d1, java.util.Date d2)`
`static java.lang.String` `getMachineUser()` Get the name of the user that is logged in to the host machine.
`static java.lang.String` `getMemoryStats()` Return a String that contains the free, allocated, max and totalFree (free+(max-allocated))
`static java.lang.String` `getMessage(java.util.ResourceBundle bundle, java.lang.String keyName)` Wrap ResourceBundle.getString() so it does not throw an exception if the key cannot be found.
`static java.lang.String` `getMessage(java.util.ResourceBundle bundle, java.lang.String keyName, boolean returnKey)`
`static int` `getPercentage(int x, int y)` Returns percentage given two numbers.
`static java.util.ResourceBundle` `getResourceBundle(java.lang.String bundleBaseName, java.util.Locale locale)` Wrap ResourceBundle.getBundle() so it does not throw an exception of the bundle cannot be found.
`static java.lang.String` `getResourcePath(java.lang.String name)` Attempts to determine the absolute pathname of a resource file.
`static java.lang.String` `getString(java.util.Map map, java.lang.String name)` Return a map value as a string.
`static java.lang.String` `getString(java.lang.String s)` Return the given String or null (if the given String is null or zero-length).
`static java.util.HashMap` `hashtableToMap(java.util.Hashtable hash)` Convert a Hashtable into a HashMap.
`static java.lang.String` `htmlify(java.lang.String src)` Take a string that can contain formatting characters typical for hand-edited XML and simplify it for rendering as HTML or within an Ext component.
`static java.util.Date` `incrementDateByDays(java.util.Date date, long duration)`
`static java.util.Date` `incrementDateByMinutes(java.util.Date date, int minutes)`
`static java.util.Date` `incrementDateBySeconds(java.util.Date date, int seconds)`
`static boolean` `isAlreadyExistsException(java.lang.Throwable t)` Return true if the exception means that an attempt was made to save an object with a name that was already in use.
`static boolean` `isAnyNullOrEmpty(java.lang.String... vals)`
`static boolean` `isDateAfter(java.util.Date testDate, java.util.Date startDate)` Determine whether the testDate is greater than or equal to the startDate
`static boolean` `isDateAfterToday(java.util.Date date)`
`static boolean` `isEmpty(java.util.Collection collection)`
`static boolean` `isEmpty(java.util.Iterator i)` Return true if the specified Iterator is empty.
`static boolean` `isEmpty(java.util.Map map)`
`static boolean` `isEmpty(java.lang.String csv)`
`static boolean` `isFirstElement(java.lang.Object o, java.lang.Iterable i)` Return true if the given object is the first element of the given Iterable.
`static boolean` `isInt(java.lang.String str)`
`static boolean` `isLastElement(java.lang.Object o, java.lang.Iterable i)`
`static boolean` `isNothing(java.lang.String str)`
`static boolean` `isNotNullOrEmpty(java.lang.String str)` Negative of isNullOrEmpty Its simply there for easier to read code.
`static boolean` `isNullOrEmpty(java.lang.String str)`
`static boolean` `isWindows()`
`static <T> java.lang.Iterable<T>` `iterate(java.lang.Iterable<T> iterable)` Alternate name that's easier to remember.
`static <T> java.util.List<T>` `iteratorToList(java.util.Iterator<T> iterator)` Return a List with the elements returned by the given iterator.
`static java.util.List<java.util.Map<java.lang.String,java.lang.Object>>` `iteratorToMaps(java.util.Iterator<java.lang.Object[]> iterator, java.lang.String... keys)` Return a List of maps that have the object arrays in the given iterator keyed by the given list of keys.
`static java.lang.String` `itoa(int i)` Convert an primitive integer value into a String.
`static java.lang.String` `join(java.util.Collection c, java.lang.String delimiter)` Join the items in a collection into a String just as the Perl join function does.
`static java.lang.String` `leftPadZeros(int toValue, int padding)` Takes an integer value and left pads it with 0s.
`static java.lang.String` `listToCsv(java.util.List list)` Convert a list of strings into a comma delimited list.
`static java.lang.String` `listToCsv(java.util.List list, boolean filterEmpty)`
`static java.lang.String` `listToPipeDelimited(java.util.List list)` Return a pipe (|) delimited string with all values in the given list.
`static java.lang.String` `listToQuotedCsv(java.util.List list, java.lang.Character quoteChar, boolean filterEmpty)` Convert a list of strings into a comma delimited list of Strings wrapped in the specified type of quote.
`static java.lang.String` `listToQuotedCsv(java.util.List list, java.lang.Character quoteChar, boolean filterEmpty, boolean conditionallyQuote)` This is similar to listToQuoteCsv but allows the specification of the conditionally quoted individual values in a csv that have embedded commas.
`static java.lang.String` `listToRfc4180Csv(java.util.List<?> list)`
`static java.lang.String` `longToDottedQuad(long inaddr)`
`static java.lang.String` `ltoa(long i)`
`static void` `main(java.lang.String[] args)`
`static <T> java.util.List<T>` `mapKeys(java.util.Map<T,?> map)` Return a list of the keys in a Map
`static java.lang.String` `mapToString(java.util.Map map)` Convert the given Map to a String.
`static java.lang.String` `memoryFormat(long size)` Converts number of bytes to a human readable format.
`static long[]` `mergeAndSortArrays(long[] array1, long[] array2)` Merge the contents of two arrays of longs into a newly created sorted array
`static java.lang.Object` `nullify(java.lang.Object obj)` Collapse a value to null if it is logically null.
`static boolean` `nullsafeBoolean(java.lang.Boolean val)`
`static boolean` `nullSafeCaseInsensitiveEq(java.lang.String o1, java.lang.String o2)` This method performs a null-safe equality comparison between the two strings.
`static <T extends java.lang.Comparable> int` `nullSafeCompareTo(T o1, T o2)` Return the compareTo() value for two objects that may be null.
`static boolean` `nullSafeContains(java.util.List list, java.lang.Object o)` Check a list for the given object, checking for null on the list.
`static boolean` `nullSafeContains(java.lang.String csv, java.lang.Object o)` Check a csv-based list for the given object, checking for null on the list.
`static boolean` `nullSafeEq(java.lang.Object o1, java.lang.Object o2)` This method performs a null-safe equality comparison between the two given objects.
`static boolean` `nullSafeEq(java.lang.Object o1, java.lang.Object o2, boolean nullsEq)` This method performs a null-safe equality comparison between the two given objects.
`static boolean` `nullSafeEq(java.lang.Object o1, java.lang.Object o2, boolean nullsEq, boolean emptyStringToNull)` This method performs a null-safe equality comparison between the two given objects.
`static int` `nullSafeHashCode(java.lang.Object o)` Return the hashcode of the given object, or -1 if the given object is null.
`static long` `nullsafeLong(java.lang.Long val)`
`static <T> boolean` `orderInsensitiveEquals(java.util.List<T> l1, java.util.List<T> l2)` Check if the two given Lists contain all of the same elements.
`static java.lang.String` `otoa(java.lang.Object o)`
`static boolean` `otob(java.lang.Object o)`
`static int` `otoi(java.lang.Object o)`
`static java.util.List<java.lang.String>` `otol(java.lang.Object o)` Convert an object to a List of Strings.
`static java.lang.String` `otos(java.lang.Object o)` Convert an object to its string representation.
`static java.lang.String` `padID(java.lang.String strId)`
`static int` `rand(int low, int high)` Generate a random number between a low a high value inclusive.
`static byte[]` `readBinaryFile(java.io.File f)`
`static byte[]` `readBinaryFile(java.lang.String name)` Read the contents of a file and return it as a byte array.
`static byte[]` `readBinaryInputStream(java.io.InputStream inputStream)`
`static java.lang.String` `readFile(java.io.File f)`
`static java.lang.String` `readFile(java.lang.String name)` Read the contents of a file and return it as a String.
`static java.lang.String` `readInputStream(java.io.InputStream inputStream)`
`static java.lang.Object` `readSerializedObject(byte[] bytes)` Reconstitute a serialized object from a byte array.
`static <T> void` `removeDuplicates(java.util.List<T> list)`
`static <T> java.lang.Iterable<T>` `safeIterable(java.lang.Iterable<T> iterable)` Constructs a null-safe iterable for use with for-each loops to avoid null checking.
`static byte[]` `serializableObjectToBytes(java.lang.Object toWrite)` Convert a Serializable Object into a byte array.
`static java.lang.String` `setToCsv(java.util.Set<?> set)`
`static java.lang.String[]` `shiftArray(java.lang.String[] input)` Return a copy of the array with the first element removed.
`static int` `size(java.util.Collection c)` Return the size of the given collection.
`static void` `sleep(int millis)` Pause for reflection, catching the usual silly exception.
`static boolean` `smellsLikeMessageKey(java.lang.String key)` Does the given string look like a message key?
`static java.lang.String` `splitCamelCase(java.lang.String str)` Takes a camel case string, splits the words out of it and capitalizes each one.
`static java.lang.StringBuffer` `sprintf(java.lang.String format, java.lang.String[] args)` A marginally functional attempt to provide "sprintf" in Java.
`static java.lang.String` `stackToString(java.lang.Throwable th)` Converts the stack trace of an exception to a String
`static java.util.Date` `stringToDate(java.lang.String src)` Convert the string representation for a date into a Date object.
`static java.util.List` `stringToList(java.lang.String value)` Note: Why don't we return List<String> here? I have noticed that if I change it to List<String> some classes depending on this break.
`static java.util.Map` `stringToMap(java.lang.String value)` Convert the string representation for a map into a Map object
`static java.util.Date` `stringToTime(java.lang.String src)` Convert the string representation for a date into a Date object.
`static java.lang.String` `stripLeadingChar(java.lang.String s, char c)` Strip all occurrences of the given character off the front of the given string.
`static java.lang.String` `strstr(java.lang.String inString, java.lang.String delimeter)` Returns the last token in a string of tokens separated by delimiter argument.
`static java.lang.String` `trimnull(java.lang.String str)` Like nullify but we don't have to cast the return
`static java.lang.String` `trimWhitespace(java.lang.String src)` Trims trailing whitespace from a string.
`static java.lang.String` `truncate(java.lang.String s, int maxLength)` Truncate the given string if it is longer than maxLength - if so, the last 3 characters are replaced with an ellipsis (...).
`static java.lang.String` `truncatedJoin(java.util.Collection c, java.lang.String delimiter, int maxChars)` First joins the list of string values using the specified delimiter, then truncates the resulting string to the specified character maximum.
`static java.lang.String` `truncateFront(java.lang.String s, int maxLength)` Similar to truncate(), but if truncation is necessary the beginning of the string is trimmed rather than the end.
`static java.lang.String` `unxml(java.lang.String src)` Remove "xml garbage" from a string that might have started out life in an XML element.
`static java.lang.String` `uuid()` Generate a unique identifier.
`static <T> java.util.List<T>` `wrappedList(java.util.List<T> list, Util.ListElementWrapper<T> wrapper)` Returns a List backed by the given list that wraps each element that is returned using the given wrapper.
`static void` `writeFile(java.lang.String name, byte[] contents)` Store the contents of a byte array to a file.
`static void` `writeFile(java.lang.String name, java.lang.String contents)` Store the contents of a String in a file.
`static void` `writeTestFile(java.lang.String name, byte[] contents)`
`static void` `writeTestFile(java.lang.String name, java.lang.String contents)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### MILLIS_PER_DAY

    public static final long MILLIS_PER_DAY

See Also:
  Constant Field Values

#### MILLI_IN_SECOND

    public static final long MILLI_IN_SECOND

See Also:
  Constant Field Values

#### MILLI_IN_MINUTE

    public static final long MILLI_IN_MINUTE

See Also:
  Constant Field Values

#### MILLI_IN_HOUR

    public static final long MILLI_IN_HOUR

See Also:
  Constant Field Values

#### MILLI_IN_DAY

    public static final long MILLI_IN_DAY

See Also:
  Constant Field Values

#### MILLI_IN_WEEK

    public static final long MILLI_IN_WEEK

See Also:
  Constant Field Values

#### MILLI_IN_MONTH

    public static final long MILLI_IN_MONTH

See Also:
  Constant Field Values

#### MILLI_IN_YEAR

    public static final long MILLI_IN_YEAR

See Also:
  Constant Field Values

#### APPLICATION_HOME

    public static final java.lang.String APPLICATION_HOME

The system property that indicates our "home" directory.

See Also:
  Constant Field Values

### Constructor Detail

#### Util

    public Util()

### Method Detail

#### sleep

    public static void sleep(int millis)

Pause for reflection, catching the usual silly exception.

#### leftPadZeros

    public static java.lang.String leftPadZeros(int toValue,
                                                int padding)

Takes an integer value and left pads it with 0s. Negative values will have the negative marked at the beginning of the string, for example, -000001

#### uuid

    public static java.lang.String uuid()

Generate a unique identifier.

#### getHostName

    public static java.lang.String getHostName()

#### nullSafeEq

    public static boolean nullSafeEq(java.lang.Object o1,
                                     java.lang.Object o2)

This method performs a null-safe equality comparison between the two given objects. If both objects are null, this returns false.

Parameters:
  `o1` - The first object to compare.
  `o2` - The second object to compare.
Returns:
  True if both objects are non-null and equal.

#### nullSafeEq

    public static boolean nullSafeEq(java.lang.Object o1,
                                     java.lang.Object o2,
                                     boolean nullsEq)

This method performs a null-safe equality comparison between the two given objects. This will return true if both objects are null and nullsEq is true.

Parameters:
  `o1` - The first object to compare.
  `o2` - The second object to compare.
  `nullsEq` - Whether two null objects should be considered equal.
Returns:
  True if both objects equal, or both objects are null and nullsEq is true.

#### nullSafeEq

    public static boolean nullSafeEq(java.lang.Object o1,
                                     java.lang.Object o2,
                                     boolean nullsEq,
                                     boolean emptyStringToNull)

This method performs a null-safe equality comparison between the two given objects. This will return true if both objects are null and nullsEq is true. Empty or "null" strings will be converted to null before checking if emptyStringToNull is true.

#### nullSafeCaseInsensitiveEq

    public static boolean nullSafeCaseInsensitiveEq(java.lang.String o1,
                                                    java.lang.String o2)

This method performs a null-safe equality comparison between the two strings. This will return true if both objects are null and nullsEq is true. Empty or "null" strings will be converted to null before checking if emptyStringToNull is true.

#### nullSafeCompareTo

    public static <T extends java.lang.Comparable> int nullSafeCompareTo(T o1,
                                                                         T o2)

Return the compareTo() value for two objects that may be null. Nulls are considered equal, and null is greater than non-null.

#### nullSafeHashCode

    public static int nullSafeHashCode(java.lang.Object o)

Return the hashcode of the given object, or -1 if the given object is null.

#### nullSafeContains

    public static boolean nullSafeContains(java.util.List list,
                                           java.lang.Object o)

Check a list for the given object, checking for null on the list.

Parameters:
  `list` -
  `o` -
Returns:
  true if value is found in the list

#### nullSafeContains

    public static boolean nullSafeContains(java.lang.String csv,
                                           java.lang.Object o)

Check a csv-based list for the given object, checking for null on the list.

Parameters:
  `csv` - List of objects in CSV form
  `o` - Object to check for in the list
Returns:
  true if value is found in the list

#### rand

    public static int rand(int low,
                           int high)

Generate a random number between a low a high value inclusive.

#### filterNulls

    public static <T> java.util.List<T> filterNulls(java.util.List<T> src)

Remove nulls from a list. Added as a temporary kludge for some obscure Hibernate crap that adds phantom null's to Lists under some conditions. Do not collapse empty lists to null, some object constructors set the list before they begin populating it. This obviously still has the potental for nulls, but at least Hibernate doesn't appear to follow that pattern.

#### getJsonSafeKey

    public static java.lang.String getJsonSafeKey(java.lang.String key)

cannot have '.' in json key names change them to '-'

#### getKeyFromJsonSafeKey

    public static java.lang.String getKeyFromJsonSafeKey(java.lang.String jsonSafeKey)

Does the opposite of @link {getJsonSafeKey}

#### filter

    public static <T> java.util.List<T> filter(java.util.List<T> list,
                                               Util.ListFilter<T> filter)
                                        throws GeneralException

Return a filtered copy of the given list with any elements that match the given ListFilter not included.

Parameters:
  `list` - The List to filter.
  `filter` - The ListFilter to apply to each element to determine if it should be in the copy or not.
Returns:
  A filtered copy of the given list with any elements that match the given ListFilter not included.
Throws:
  `GeneralException`

#### find

    public static <T> T find(java.util.List<T> values,
                             Util.IMatcher<T> matcher)

Looks through the list and returns an item which matches the IMatcher interface.

#### wrappedList

    public static <T> java.util.List<T> wrappedList(java.util.List<T> list,
                                                    Util.ListElementWrapper<T> wrapper)

Returns a List backed by the given list that wraps each element that is returned using the given wrapper. This original intent was to provide lazy proxy replacement for list elements (for example - a proxy for each element is returned instead of the actual element), but this could also be used to transform the elements when they are read from the list. Passing in a null list will return null.

Parameters:
  `list` - The List to wrap.
  `wrapper` - The ListElementWrapper to use to wrap the elements when retrieved from the list.
Returns:
  A List backed by the given list that wraps each element this is returned using the given wrapper, or null if the given list is null.
See Also:
  `Util.ListElementWrapper`

#### asList

    public static java.util.List asList(java.lang.Object o)

Return a List with the given object. If the object is a List, it is returned. If the object is a collection, a List with all of the elements of the collection is returned. If the object is a non-collection, a new List containing the given object is returned. If the object is null, null is returned.

Parameters:
  `o` - The object to return as a list.

#### isFirstElement

    public static boolean isFirstElement(java.lang.Object o,
                                         java.lang.Iterable i)

Return true if the given object is the first element of the given Iterable.

Parameters:
  `o` - The object to check as the first element.
  `i` - The Iterable to check.
Returns:
  True if the given object is the first element of the given Iterable.

#### isLastElement

    public static boolean isLastElement(java.lang.Object o,
                                        java.lang.Iterable i)

#### isEmpty

    public static boolean isEmpty(java.util.Iterator i)

Return true if the specified Iterator is empty.

Parameters:
  `i` - Iterator being checked
Returns:
  true of the given Iterator is empty

#### flushIterator

    public static void flushIterator(java.util.Iterator i)

Exhaust the remainder of the iterator so that Hibernate will properly close the cursor associated with it.

Parameters:
  `i` - Iterator being exhausted

#### orderInsensitiveEquals

    public static <T> boolean orderInsensitiveEquals(java.util.List<T> l1,
                                                     java.util.List<T> l2)

Check if the two given Lists contain all of the same elements. Unlike ArrayList.equals(Object), this ignores the order of the elements.

Parameters:
  `l1` - The first List to compare.
  `l2` - The second List to compare.
Returns:
  Return true if both Lists are non-null and contain all of the same elements.

#### find

    public static <T> T find(java.util.List<T> list,
                             T t,
                             java.util.Comparator<T> comparator)

Find the requested object in the given list using the given comparator.

Parameters:
  `list` - The list in which to search for a match to t.
  `t` - The object to look for using the comparator in the list.
  `comparator` - The Comparator to use to compare t to the list elements.
Returns:
  The requested object in the given list or null if not found.

#### findComparable

    public static <T extends java.lang.Comparable<? super T>> T findComparable(java.util.List<T> list,
                                                                               T toFind,
                                                                               boolean sorted)

Return a matching object from the given list.

Parameters:
  `list` - The list of comparable items.
  `toFind` - The item to find.
  `sorted` - Whether the list is already sorted.
Returns:
  A matching object according to the comparable interface, or null if no match is found.

#### containsComparable

    public static <T extends java.lang.Comparable<? super T>> boolean containsComparable(java.util.List<T> list,
                                                                                         T toFind,
                                                                                         boolean sorted)

Return whether the given list of comparable items contains the give item according to the Comparable interface. This is similar to the contains() method on Collection, except that it uses natural ordering (Comparable interface) rather than equality (equals and hashCode) to determine matches.

Parameters:
  `list` - The list of comparable items.
  `toFind` - The item to find.
  `sorted` - Whether the list is already sorted.
Returns:
  Whether the given item is in the given list. False if either parameter is null.

#### arrayToList

    public static <T> java.util.List<T> arrayToList(T[] array)

Given an array, returns a list.

Parameters:
  `array` - Array to copy to a list
Returns:
  New List, empty list if array is null.

#### shiftArray

    public static java.lang.String[] shiftArray(java.lang.String[] input)

Return a copy of the array with the first element removed.

Parameters:
  `input` - The array to shift.
Returns:
  A copy of the array with the first element removed.

#### mergeAndSortArrays

    public static long[] mergeAndSortArrays(long[] array1,
                                            long[] array2)

Merge the contents of two arrays of longs into a newly created sorted array

Parameters:
  `array1` - First array to merge
  `array2` - Second array to merge
Returns:
  New array containing the sorted contents of the two specified arrays

#### iteratorToList

    public static <T> java.util.List<T> iteratorToList(java.util.Iterator<T> iterator)

Return a List with the elements returned by the given iterator.

Parameters:
  `iterator` - The Iterator from which to create the List.
Returns:
  A List with the elements returned by the given iterator.

#### safeIterable

    public static <T> java.lang.Iterable<T> safeIterable(java.lang.Iterable<T> iterable)

Constructs a null-safe iterable for use with for-each loops to avoid null checking.

Parameters:
  `iterable` - The iterable to use.
Returns:
  iterable if it is non-null, otherwise an empty iterable.

#### iterate

    public static <T> java.lang.Iterable<T> iterate(java.lang.Iterable<T> iterable)

Alternate name that's easier to remember.

#### iteratorToMaps

    public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> iteratorToMaps(java.util.Iterator<java.lang.Object[]> iterator,
                                                                                                  java.lang.String... keys)

Return a List of maps that have the object arrays in the given iterator keyed by the given list of keys.

Parameters:
  `iterator` - The Iterator from which to create the List of Maps.
  `keys` - The keys for the maps that are being created. The number of keys must match the number of objects in each Object[] in the iterator. Note that this can be a single string that has a comma-separated list of keys.
Returns:
  A List with the elements returned by the given iterator.

#### size

    public static int size(java.util.Collection c)

Return the size of the given collection.

Parameters:
  `c` - The possibly-null collection to get the size of.

#### isEmpty

    public static boolean isEmpty(java.util.Collection collection)

#### isEmpty

    public static boolean isEmpty(java.util.Map map)

#### isEmpty

    public static boolean isEmpty(java.lang.String csv)

Parameters:
  `csv` - CSV that is being checked for emptiness
Returns:
  true if the csv contains values; false otherwise

#### mapKeys

    public static <T> java.util.List<T> mapKeys(java.util.Map<T,?> map)

Return a list of the keys in a Map

Parameters:
  `map` - Map containing keys
Returns:
  A List containing the keys from the Map

#### containsAny

    public static boolean containsAny(java.util.Collection c1,
                                      java.util.Collection c2)

Return whether c1 contains any elements found in c2.

Parameters:
  `c1` - The first collection to compare.
  `c2` - The second collection to compare.
Returns:
  True if c1 contains any elements found in c2, false otherwise.

#### getString

    public static java.lang.String getString(java.util.Map map,
                                             java.lang.String name)

Return a map value as a string.

#### getBoolean

    public static boolean getBoolean(java.util.Map map,
                                     java.lang.String name)

#### getInt

    public static int getInt(java.util.Map map,
                             java.lang.String name)

#### getDate

    public static java.util.Date getDate(java.util.Map map,
                                         java.lang.String name)

#### get

    public static java.lang.Object get(java.util.Map map,
                                       java.lang.String name)

#### htmlify

    public static java.lang.String htmlify(java.lang.String src)

Take a string that can contain formatting characters typical for hand-edited XML and simplify it for rendering as HTML or within an Ext component. This was necessary for some object description strings since Ext seems to collapse newlines which causes words separted only by newlines to be merged. Ext does seem to strip leading and trailing whitespace but we'll do it here to so this method can be used in several places.

#### getFullname

    public static java.lang.String getFullname(java.lang.String first,
                                               java.lang.String last)

Return a fullname constructed from the given first and last names. More often than not, you should use Identity.getDisplayableName() instead of this.

#### getString

    public static java.lang.String getString(java.lang.String s)

Return the given String or null (if the given String is null or zero-length).

Parameters:
  `s` - The String to filter.
Returns:
  The given String or null (if the given String is null or zero-length).

#### nullify

    public static java.lang.Object nullify(java.lang.Object obj)

Collapse a value to null if it is logically null. This differs from getString because I didn't like the handling for "null" where was that used??

#### trimnull

    public static java.lang.String trimnull(java.lang.String str)

Like nullify but we don't have to cast the return

#### capitalize

    public static java.lang.String capitalize(java.lang.String str)

Capitalizes the first letter in the given String Example: hElLo becomes HElLo

Parameters:
  `str` - string in need of some capitalization
Returns:
  capitalized string

#### capitalizeAndNormalize

    public static java.lang.String capitalizeAndNormalize(java.lang.String str)

Capitalizes the first letter in the given String and lowercases the rest of the String Example: hElLo becomes Hello

Parameters:
  `str` - string in need of help
Returns:
  capitalized and normalized string

#### truncate

    public static java.lang.String truncate(java.lang.String s,
                                            int maxLength)

Truncate the given string if it is longer than maxLength - if so, the last 3 characters are replaced with an ellipsis (...).

Parameters:
  `s` - The string to truncate.
  `maxLength` - The maximum length.

#### truncateFront

    public static java.lang.String truncateFront(java.lang.String s,
                                                 int maxLength)

Similar to truncate(), but if truncation is necessary the beginning of the string is trimmed rather than the end.

Parameters:
  `s` - The string to truncate.
  `maxLength` - The maximum length.

#### stripLeadingChar

    public static java.lang.String stripLeadingChar(java.lang.String s,
                                                    char c)

Strip all occurrences of the given character off the front of the given string.

#### splitCamelCase

    public static java.lang.String splitCamelCase(java.lang.String str)

Takes a camel case string, splits the words out of it and capitalizes each one. Example: camelCaseString becomes Camel Case String

#### encodeJavaIdentifier

    public static java.lang.String encodeJavaIdentifier(java.lang.String s)

Encode the given string into a valid java identifier (for example - does not start with a number, does not include spaces, commas, etc...) by replacing any invalid characters with the ASCII code of the character surrounded by double underscores. For example: 0 becomes __48__. Note that we allow spaces and dots to go through unescaped.

Parameters:
  `s` - The string to convert to a valid java identifier.
Returns:
  An encoded valid java identifier.

#### decodeJavaIdentifier

    public static java.lang.String decodeJavaIdentifier(java.lang.String s)
                                                 throws Util.ParseException

Decode the given encoded java identifier to remove any encoded invalid characters and replace them with their original values.

Parameters:
  `s` - The string to decode.
Returns:
  The decoded version of the given encoded java identifier.
Throws:
  `Util.ParseException` - If the given string is not a valid encoded java identifier. The method encodeJavaIdentifier() should always produce valid identifiers that will not throw this exception.

#### itoa

    public static java.lang.String itoa(int i)

Convert an primitive integer value into a String. This does not really save much space, but its the obvious inverse to atoi.

#### ltoa

    public static java.lang.String ltoa(long i)

#### ftoa

    public static java.lang.String ftoa(float i)

#### atoi

    public static int atoi(java.lang.String a)

Convert a String value into a primitive integer value. Truncate doubles and return the floor. Tolerate null strings, and invalid integer strings and return 0.

#### atoi

    public static int atoi(java.lang.String a,
                           int def)

Convert a String value into a primitive integer value. If the string is invalid, the value of the "def" argument is returned.

#### atol

    public static long atol(java.lang.String a)

#### atof

    public static float atof(java.lang.String a)

#### atob

    public static boolean atob(java.lang.String a)

#### otoa

    public static java.lang.String otoa(java.lang.Object o)

#### otob

    public static boolean otob(java.lang.Object o)

#### otoi

    public static int otoi(java.lang.Object o)

#### otos

    public static java.lang.String otos(java.lang.Object o)

Convert an object to its string representation. This will convert Lists and Collections to comma-separated lists. Any other object is simply returned as its toString() representation.

Parameters:
  `o` - The object to convert to a string.
Returns:
  The string representation of the given object, or null if the given object is null.

#### otol

    public static java.util.List<java.lang.String> otol(java.lang.Object o)

Convert an object to a List of Strings. This is useful when contending with arguments that may be coming in as CSVs or as Lists.

Parameters:
  `o` - Either a List<String> or a CSV list
Returns:
  A new List containing all the elements in the specified object. Note that if the specified object is a List this method returns a new List containing all the elements of the one that was passed in.

#### trimWhitespace

    public static java.lang.String trimWhitespace(java.lang.String src)

Trims trailing whitespace from a string. String.trim() can be used if you want to trim from both sides of the string.

#### deleteWhitespace

    public static java.lang.String deleteWhitespace(java.lang.String src)

Deletes any whitespace from the string

#### compressWhiteSpace

    public static java.lang.String compressWhiteSpace(java.lang.String str)

This method strips leading and trailing whitespace and guarantees that there is at most one space between characters in the output. For example,

    "What    does    this    do?"

becomes

    "What does this do?"

Parameters:
  `str` - string in need of compression
Returns:
  compressed string

#### unxml

    public static java.lang.String unxml(java.lang.String src)

Remove "xml garbage" from a string that might have started out life in an XML element. These commonly have leading whitespace that was used to indent the text in the XML file, but once this has been imported it is no longer necessary and annoyong to look at in the UI. Also collapse empty strings to null for contexts where we select from several values based on their nullness. NOTE: This isn't enough! Also need to be sifting through this looking for embedded newlines followed by spaces and collapsing out this "insignificant whitespace". Sigh, also must avoid triggering unnecessary Hibernate updates by checking to see if the string actually needs fixing.

#### strstr

    public static java.lang.String strstr(java.lang.String inString,
                                          java.lang.String delimeter)

Returns the last token in a string of tokens separated by delimiter argument.

#### expandVariables

    public static java.lang.String expandVariables(java.lang.String src,
                                                   java.util.Map<java.lang.String,java.lang.Object> variables)

Process a string which may contain references to variables and substitute the values of those variables.

If a variable is not defined, it silently expands to nothing.

A variable is referenced with the syntax "$(x)" where "x" is the name of the variable. Values for variables are supplied through a Map.

#### escapeNewlines

    public static java.lang.String escapeNewlines(java.lang.String src)

Process a string to escape newline characters.

Ordinarilly done if you want to store a string as a value in a property file, where the newline marks the end of the value.

#### escapeHTMLNewlines

    public static java.lang.String escapeHTMLNewlines(java.lang.String src)

Escape newlines from the string into the HTML escaped newline and carriage return.

#### escapeNewlines

    public static java.lang.String escapeNewlines(java.lang.String src,
                                                  java.lang.String nRepl,
                                                  java.lang.String rRepl)

Process a string to escape newline characters.

#### delimToList

    public static java.util.List<java.lang.String> delimToList(java.lang.String delim,
                                                               java.lang.String src,
                                                               boolean filterEmpty)

#### csvToList

    public static java.util.List<java.lang.String> csvToList(java.lang.String src)

Convert a comma delimited string into a List of strings.

#### csvToList

    public static java.util.List<java.lang.String> csvToList(java.lang.String src,
                                                             boolean filterEmpty)

#### csvToArray

    public static java.lang.String[] csvToArray(java.lang.String src)

#### csvToSet

    public static java.util.Set<java.lang.String> csvToSet(java.lang.String src,
                                                           boolean filterEmpty)

#### setToCsv

    public static java.lang.String setToCsv(java.util.Set<?> set)

#### listToCsv

    public static java.lang.String listToCsv(java.util.List list)

Convert a list of strings into a comma delimited list.

#### listToCsv

    public static java.lang.String listToCsv(java.util.List list,
                                             boolean filterEmpty)

#### listToQuotedCsv

    public static java.lang.String listToQuotedCsv(java.util.List list,
                                                   java.lang.Character quoteChar,
                                                   boolean filterEmpty)

Convert a list of strings into a comma delimited list of Strings wrapped in the specified type of quote. If null as provided as the quote type no quotes are applied.

Parameters:
  `list` - List of objects to be converted into a list of strings
  `quoteChar` - Quote character in which to wrap the strings. Can be ', ", or null. If null is specified no quotes will be applied
  `filterEmpty` - True to filter blank strings out of the list. False to include them
Returns:
  String representation of a comma delimited list of Strings wrapped in the specified type of quote

#### listToQuotedCsv

    public static java.lang.String listToQuotedCsv(java.util.List list,
                                                   java.lang.Character quoteChar,
                                                   boolean filterEmpty,
                                                   boolean conditionallyQuote)

This is similar to listToQuoteCsv but allows the specification of the conditionally quoted individual values in a csv that have embedded commas.

Returns:
  String representation of the list
See Also:
  `listToQuotedCsv(List, Character, boolean)`

#### listToRfc4180Csv

    public static java.lang.String listToRfc4180Csv(java.util.List<?> list)

#### listToPipeDelimited

    public static java.lang.String listToPipeDelimited(java.util.List list)

Return a pipe (|) delimited string with all values in the given list. Each list element will be surrounded by pipes. For example, [A, B, C] would return "|A|B|C|".

Parameters:
  `list` - The List to convert to a pipe delimited string.
Returns:
  A pipe delimited string with all values in the given list, or null if the given list is null.

#### join

    public static java.lang.String join(java.util.Collection c,
                                        java.lang.String delimiter)

Join the items in a collection into a String just as the Perl join function does.

Parameters:
  `c` - the Collection to join
  `delimiter` - the delimeter to place between the collection elements
Returns:
  joined string

#### truncatedJoin

    public static java.lang.String truncatedJoin(java.util.Collection c,
                                                 java.lang.String delimiter,
                                                 int maxChars)

First joins the list of string values using the specified delimiter, then truncates the resulting string to the specified character maximum.

Parameters:
  `c` - The collection to join.
  `delimiter` - The join character.
  `maxChars` - The maximum characters after truncation.
Returns:
  The joined and truncated string.

#### readBinaryFile

    public static byte[] readBinaryFile(java.lang.String name)
                                 throws GeneralException

Read the contents of a file and return it as a byte array.

Throws:
  `GeneralException`

#### readBinaryInputStream

    public static byte[] readBinaryInputStream(java.io.InputStream inputStream)
                                        throws GeneralException

Throws:
  `GeneralException`

#### readBinaryFile

    public static byte[] readBinaryFile(java.io.File f)
                                 throws GeneralException

Throws:
  `GeneralException`

#### readInputStream

    public static java.lang.String readInputStream(java.io.InputStream inputStream)
                                            throws GeneralException

Throws:
  `GeneralException`

#### readFile

    public static java.lang.String readFile(java.lang.String name)
                                     throws GeneralException

Read the contents of a file and return it as a String.

Throws:
  `GeneralException`

#### readFile

    public static java.lang.String readFile(java.io.File f)
                                     throws GeneralException

Throws:
  `GeneralException`

#### bytesToString

    public static java.lang.String bytesToString(byte[] bytes)
                                          throws GeneralException

Throws:
  `GeneralException`

#### writeFile

    public static void writeFile(java.lang.String name,
                                 byte[] contents)
                          throws GeneralException

Store the contents of a byte array to a file.

Throws:
  `GeneralException`

#### writeTestFile

    public static void writeTestFile(java.lang.String name,
                                     byte[] contents)

#### writeFile

    public static void writeFile(java.lang.String name,
                                 java.lang.String contents)
                          throws GeneralException

Store the contents of a String in a file.

Throws:
  `GeneralException`

#### writeTestFile

    public static void writeTestFile(java.lang.String name,
                                     java.lang.String contents)

#### copyFile

    public static void copyFile(java.lang.String src,
                                java.lang.String dest)
                         throws GeneralException,
                                java.io.IOException

Copies one file to another.

I'm sort of suprised the JDK doesn't have something to do this. If this were used with large files, we'd want to do iterate over a fixed block size.

Throws:
  `GeneralException`
  `java.io.IOException`

#### getMachineUser

    public static java.lang.String getMachineUser()

Get the name of the user that is logged in to the host machine.

#### getDate

    public static java.util.Date getDate(java.lang.Object o)

Try to derive a Date from a random object. If this is a String then we have to use the default format.

#### dateToString

    public static java.lang.String dateToString(java.util.Date src)

Format a Date value as a String, using the usual "American" format with the current time zone.

#### dateToString

    public static java.lang.String dateToString(java.util.Date src,
                                                java.lang.String format)

#### dateToString

    public static java.lang.String dateToString(java.util.Date src,
                                                java.lang.String format,
                                                java.util.TimeZone tz)

#### incrementDateByDays

    public static java.util.Date incrementDateByDays(java.util.Date date,
                                                     long duration)

#### incrementDateByMinutes

    public static java.util.Date incrementDateByMinutes(java.util.Date date,
                                                        int minutes)

#### incrementDateBySeconds

    public static java.util.Date incrementDateBySeconds(java.util.Date date,
                                                        int seconds)

#### getBeginningOfDay

    public static java.util.Date getBeginningOfDay(java.util.Date day)

#### getEndOfDay

    public static java.util.Date getEndOfDay(java.util.Date day)

#### dateToString

    public static java.lang.String dateToString(java.util.Date src,
                                                java.lang.Integer dateFormat,
                                                java.lang.Integer timeFormat)

#### dateToString

    public static java.lang.String dateToString(java.util.Date src,
                                                java.lang.Integer dateFormat,
                                                java.lang.Integer timeFormat,
                                                java.util.TimeZone timeZone,
                                                java.util.Locale locale)

#### baselineDate

    public static java.util.Date baselineDate(java.util.Date src)

#### baselineDate

    public static java.util.Date baselineDate(java.util.Date src,
                                              java.util.TimeZone timeZone)

Get the baseline date for the source date. If timezone is passed, will use the day of month this date will represent in that timezone. Otherwise, use default timezone.

Parameters:
  `src` - Date to baseline
  `timeZone` - Optional. Timezone to use when getting day of month.
Returns:
  Baseline date with no time values

#### dateBetween

    public static java.util.Date dateBetween(java.util.Date startDate,
                                             java.util.Date endDate)

#### isDateAfter

    public static boolean isDateAfter(java.util.Date testDate,
                                      java.util.Date startDate)

Determine whether the testDate is greater than or equal to the startDate

Parameters:
  `testDate` - Date that we want to test
  `startDate` - Beginning of the test interval
Returns:
  true if the test Date is after the start date; false otherwise

#### stringToList

    public static java.util.List stringToList(java.lang.String value)

Note: Why don't we return List<String> here? I have noticed that if I change it to List<String> some classes depending on this break. Those classes are already broken. We should fix that.

#### mapToString

    public static java.lang.String mapToString(java.util.Map map)

Convert the given Map to a String.

#### stringToMap

    public static java.util.Map stringToMap(java.lang.String value)

Convert the string representation for a map into a Map object

#### stringToDate

    public static java.util.Date stringToDate(java.lang.String src)
                                       throws java.text.ParseException

Convert the string representation for a date into a Date object. The string can be of the following forms: M/d/y H:m:s z M/d/y H:m:s M/d/y

Throws:
  `java.text.ParseException`

#### stringToTime

    public static java.util.Date stringToTime(java.lang.String src)
                                       throws java.text.ParseException

Convert the string representation for a date into a Date object. This method is similar to stringToDate, except it assumes that no day, month, or year is specified. The string can be of the following forms: H:m:s z H:m:s

Throws:
  `java.text.ParseException`

#### getDaysDifference

    public static int getDaysDifference(java.util.Date d1,
                                        java.util.Date d2)

Return the number of days difference between the two given dates. If d1 is after d2, the returned value is positive otherwise the returned value is negative. If either given date is null, this returns Integer.MIN_VALUE.

Returns:
  The number of days difference between the two given dates, or Integer.MIN_VALUE if either date is null.

#### isDateAfterToday

    public static boolean isDateAfterToday(java.util.Date date)

#### getLongDifference

    public static long getLongDifference(java.util.Date d1,
                                         java.util.Date d2)

#### getPercentage

    public static int getPercentage(int x,
                                    int y)

Returns percentage given two numbers. The result is rounded to the nearest integer. If the percentage is between 0 and 1 we round up to 1. If the percentage is between 99 and 100 we round down to 99.

Parameters:
  `x` - number to divide
  `y` - number to divide by
Returns:
  Percentage dividing x/y. See rounding rules above.

#### computeDifferenceMilli

    public static long computeDifferenceMilli(java.util.Date start,
                                              java.util.Date end)
                                       throws GeneralException

Throws:
  `GeneralException`

#### computeDifference

    public static java.lang.String computeDifference(java.util.Date start,
                                                     java.util.Date end)
                                              throws GeneralException

Throws:
  `GeneralException`

#### sprintf

    public static java.lang.StringBuffer sprintf(java.lang.String format,
                                                 java.lang.String[] args)

A marginally functional attempt to provide "sprintf" in Java. The format string is a blank delimited list of integer tokens that represent the field sizes. The args array contains the strings that will plug into the fields. Todo: take an Object[] array instead of a String[] array add format tokens for left/right justification allow literal text in the format string UPDATE: This is no longer needed now that we use Java 5, remove...

#### getResourcePath

    public static java.lang.String getResourcePath(java.lang.String name)

Attempts to determine the absolute pathname of a resource file. The "name" argument must be the name of a resource file that can be located through the CLASSPATH. It must use forward slashes.

#### getClasspathDirectory

    public static java.lang.String getClasspathDirectory(int idx)

Return the nth item on the CLASSPATH. In addition to isolating the path, it will convert \ to / and trim the trailing slash if any.

#### findFile

    public static java.lang.String findFile(java.lang.String property,
                                            java.lang.String name,
                                            boolean searchClasspath)

Attempt to derive the absolute path of a file. The "name" argument may be an absolute path or relative path fragment. If the name is an absolute path we simply return it. Otherwise we combine the name with various other root directories and probe until we find a valid file. The sequence of probes is: - relative path alone - relative path combined with the value of the system property named in the "property" argument - relative path passed to getResourcePath to search the classpath (the path *must* contain only forward slashes for this to be used)

#### findFile

    public static java.lang.String findFile(java.lang.String property,
                                            java.lang.String name)

#### findFile

    public static java.lang.String findFile(java.lang.String name)

#### findOutputFile

    public static java.lang.String findOutputFile(java.lang.String name)

Build an absolute path name for a file. Typically used when you want to write an output file to the "current working directory". If the name is already an absolute path we use it, otherwise we use the system property "user.dir" as the root directory and add the name.

#### getApplicationHome

    public static java.lang.String getApplicationHome()
                                               throws GeneralException

Returns the filesystem path for the application home. If a System property named sailpoint.home is set, then use it. Otherwise, calculate it by finding a known resource in the class path and doing some string manipulation.

Throws:
  `GeneralException`

#### dumpProperties

    public static void dumpProperties(java.io.PrintWriter out)

Prints the current system properties to a writer object.

#### dumpProperties

    public static void dumpProperties()

Prints the current system properties to the system output device.

#### hashtableToMap

    public static java.util.HashMap hashtableToMap(java.util.Hashtable hash)

Convert a Hashtable into a HashMap. There are probably easier ways to do this with some of the newer collection methods.

#### stackToString

    public static java.lang.String stackToString(java.lang.Throwable th)

Converts the stack trace of an exception to a String

#### isAlreadyExistsException

    public static boolean isAlreadyExistsException(java.lang.Throwable t)

Return true if the exception means that an attempt was made to save an object with a name that was already in use. This is used to avoid putting alarming messages in the log file when an exception we expect is encountered. Since a specific exception class is not received from Hibernate the message has to be parsed. jsl - Factored out of TaskManager so we could use it for duplicate detection in ManagedAttributer. The "design" of this seems anecdotal but it has been use for a long time by TaskManager. Should really force this in all 4 databases and explicitly document what each does.

#### serializableObjectToBytes

    public static byte[] serializableObjectToBytes(java.lang.Object toWrite)
                                            throws java.io.IOException

Convert a Serializable Object into a byte array.

Parameters:
  `toWrite` - The Object to serialize to bytes.
Returns:
  A byte array containing the serialized object.
Throws:
  `java.io.IOException`

#### readSerializedObject

    public static java.lang.Object readSerializedObject(byte[] bytes)
                                                 throws java.io.IOException,
                                                        java.lang.ClassNotFoundException

Reconstitute a serialized object from a byte array.

Parameters:
  `bytes` - The byte array containing the serialized object.
Returns:
  The Object reconstituted from the given byte array.
Throws:
  `java.io.IOException`
  `java.lang.ClassNotFoundException`

#### main

    public static void main(java.lang.String[] args)

#### longToDottedQuad

    public static java.lang.String longToDottedQuad(long inaddr)

#### dottedQuadToLong

    public static long dottedQuadToLong(java.lang.String ipaddr)

#### isWindows

    public static boolean isWindows()

#### createObjectByClassName

    public static java.lang.Object createObjectByClassName(java.lang.String name)
                                                    throws GeneralException

Create a new instance of an object by classname.

This method calls Class.forname and then creates a default instance using the newInstance() method on the Class object. This means the object must have a no argument constructor for this method to work properly.

Throws:
  `GeneralException`

#### memoryFormat

    public static java.lang.String memoryFormat(long size)

Converts number of bytes to a human readable format.

Parameters:
  `size` - number of bytes
Returns:
  human readable memory size

#### getIIQMessages

    public static java.util.ResourceBundle getIIQMessages(java.util.Locale locale)

#### getIIQHelpMessages

    public static java.util.ResourceBundle getIIQHelpMessages(java.util.Locale locale)

#### getResourceBundle

    public static java.util.ResourceBundle getResourceBundle(java.lang.String bundleBaseName,
                                                             java.util.Locale locale)

Wrap ResourceBundle.getBundle() so it does not throw an exception of the bundle cannot be found.

#### getMessage

    public static java.lang.String getMessage(java.util.ResourceBundle bundle,
                                              java.lang.String keyName)

Wrap ResourceBundle.getString() so it does not throw an exception if the key cannot be found. Instead return the key that was not found.

#### getMessage

    public static java.lang.String getMessage(java.util.ResourceBundle bundle,
                                              java.lang.String keyName,
                                              boolean returnKey)

#### getMemoryStats

    public static java.lang.String getMemoryStats()

Return a String that contains the free, allocated, max and totalFree (free+(max-allocated))

#### isNullOrEmpty

    public static boolean isNullOrEmpty(java.lang.String str)

#### isNotNullOrEmpty

    public static boolean isNotNullOrEmpty(java.lang.String str)

Negative of isNullOrEmpty Its simply there for easier to read code.

#### isAnyNullOrEmpty

    public static boolean isAnyNullOrEmpty(java.lang.String... vals)

#### isNothing

    public static boolean isNothing(java.lang.String str)

#### isInt

    public static boolean isInt(java.lang.String str)

#### smellsLikeMessageKey

    public static boolean smellsLikeMessageKey(java.lang.String key)

Does the given string look like a message key?

#### countChars

    public static int countChars(java.lang.String sourceString,
                                 char lookFor)

Look through a source string looking for the number of occurrences of a given character.

#### convert

    public static <T1,T2> java.util.List<T2> convert(java.util.List<T1> list1,
                                                     Util.IConverter<T1,T2> converter)
                                              throws GeneralException

Converts a list of one type into another, IConverter defines the function that is used for the conversion

Throws:
  `GeneralException`

#### nullsafeLong

    public static long nullsafeLong(java.lang.Long val)

#### nullsafeBoolean

    public static boolean nullsafeBoolean(java.lang.Boolean val)

#### padID

    public static java.lang.String padID(java.lang.String strId)

#### removeDuplicates

    public static <T> void removeDuplicates(java.util.List<T> list)

#### caseInsensitiveKeyValue

    public static <T> T caseInsensitiveKeyValue(java.util.Map<java.lang.String,T> map,
                                                java.lang.String key)

Will search for the key in a case insensitive fashion.

Type Parameters:
  `T` - type of map values
Parameters:
  `map` - The map.
  `key` - The string key
Returns:
  The value in in the Map for the given case insensitive key.