public class CommonUtilities extends Object
| Modifier and Type | Method and Description | 
|---|---|
static boolean | 
arrayContains(Object[] objs,
             Object objToCheck)
Returns indication as to whether the specified array contains
 the specified value, using an equals() check. 
 | 
static String | 
collapseQuotes(String s)
Collapse embedded/doubled quotes to a single embedded quote. 
 | 
static String | 
concatenateStrings(String[] strings,
                  String separator)
Concatenate the specified array of strings into a single string,
 separated by the specified separator. 
 | 
static String[] | 
concatenateStrings(String[] strings,
                  String separator,
                  int maxPerString)
Concatenate the specified array of strings into a set of strings,
 separated by the specified separator, with each of the produced Strings 
 containing no more than the specified limit value. 
 | 
static String | 
convertEmptyToNull(String str)
Convert an empty string to null. 
 | 
static int | 
countOccurrences(String string,
                char charToCount)
Returns the count of occurrences of the specified character 
 within the specified String. 
 | 
static int | 
countUnquotedOccurrences(String string,
                        char charToCount,
                        char quoteChar,
                        char escapeChar)
Returns the count of occurrences of the specified character 
 within the specified String, not counting occurrences that occur
 in a quoted context. 
 | 
static String | 
expandQuotes(String s)
Expand embedded quotes to double the quotes. 
 | 
static Boolean | 
getBoolean(Map source,
          String key)
Returns a Boolean value from a Map given a key; throws IFS-90008 if the
 cast to a Boolean value fails. 
 | 
static Date | 
getDate(Map source,
       String key)
Returns a Date value from a Map given a key; throws IFS-90008 if the
 cast to a Date value fails. 
 | 
static Integer | 
getInteger(Map source,
          String key)
Returns a Integer value from a Map given a key; throws IFS-90008 if the
 cast to a Integer value fails. 
 | 
static Long | 
getLong(Map source,
       String key)
Returns a Long value from a Map given a key; throws IFS-90008 if the
 cast to a Long value fails. 
 | 
static long[] | 
getLongArray(Map source,
            String key)
Returns a long array value from a Map given a key; throws IFS-90008 if the
 cast to a long array value fails. 
 | 
static Map<Long,Double> | 
getLongDoubleMap(Long[] keys,
                Double[] values)
Construct a Long-Double map from the key and value arrays specified. 
 | 
static Map<Long,AttributeValue> | 
getLongLibraryObjectMap(Long[] keys,
                       LibraryObject[] values)
Construct a Long-LibraryObject map from the key and value arrays specified. 
 | 
static Map<Long,Long> | 
getLongLongMap(Long[] keys,
              Long[] values)
Construct a Long-Long map from the key and value arrays specified. 
 | 
static Map<Long,String> | 
getLongStringMap(Long[] keys,
                String[] values)
Construct a Long-String map from the key and value arrays specified. 
 | 
static String | 
getString(Map source,
         String key)
Returns a String value from a Map given a key; throws IFS-90008 if the
 cast to a String value fails. 
 | 
static String[] | 
getStringArray(Map source,
              String key)
Returns a String array value from a Map given a key; throws IFS-90008 if
 the cast to a String array value fails. 
 | 
static Map<String,Double> | 
getStringDoubleMap(String[] keys,
                  Double[] values)
Construct a String-Double map from the key and value arrays specified. 
 | 
static Map<String,AttributeValue> | 
getStringLibraryObjectMap(String[] keys,
                         LibraryObject[] values)
Construct a String-LibraryObject map from the key and value arrays specified. 
 | 
static Map<String,Long> | 
getStringLongMap(String[] keys,
                Long[] values)
Construct a String-Long map from the key and value arrays specified. 
 | 
static String[] | 
getStringsFromDelimitedToken(String token)
Get String array from a value of the form 
 "{value1, value2, value3}". 
 | 
static String[] | 
getStringsFromDelimitedToken(String token,
                            String delim)
Get String array from a value of the form 
 "{value1 
 | 
static Map<String,String> | 
getStringStringMap(String[] keys,
                  String[] values)
Construct a String-String map from the key and value arrays specified. 
 | 
static String | 
makeString(List<Character> charList)
Make a String from a list of Character. 
 | 
static String | 
makeString(List<Character> charList,
          String defString)
Make a String from a list of Character. 
 | 
static void | 
objectArrayReverse(Object[] objArray)
Reverse the elements of the specified object array. 
 | 
static String[] | 
splitString(String string,
           int maxSegLength)
Split a string into segments bounded by the max segment length specified. 
 | 
static boolean | 
stringArrayContains(String[] objs,
                   String objToCheck)
Returns indication as to whether the specified String array contains
 the specified String value, ignoring case. 
 | 
static boolean | 
stringArrayContains(String[] objs,
                   String objToCheck,
                   boolean ignoreCase)
Returns indication as to whether the specified String array contains
 the specified String value, with or without ignoring case. 
 | 
static AttributeValue[] | 
toAttributeValueArray(List<AttributeValue> avList)
Convert the specified list of AttributeValue to an AttributeValue array. 
 | 
static String | 
toLowerCase(String string)
Returns the lower-cased variant of the specified String. 
 | 
static String | 
toLowerCase(String string,
           String ifNull)
Returns the lower-cased variant of the specified String, 
 or the second String if the specified String is null. 
 | 
static String | 
toUpperCase(String string)
Returns the upper-cased variant of the specified String. 
 | 
static String | 
toUpperCase(String string,
           String ifNull)
Returns the upper-cased variant of the specified String, 
 or the second String if the specified String is null. 
 | 
static String | 
toZeroPaddedString(int value,
                  int len)
Convert an integer into a zero padded String that is at least as
 long as the specified length. 
 | 
static String | 
zeroPad(String s,
       int len)
Prepends  
s with "0" characters until the resulting
 String is of length len. | 
public static boolean arrayContains(Object[] objs, Object objToCheck)
objs - the array to checkobjToCheck - the object to check forpublic static void objectArrayReverse(Object[] objArray)
objArray - the array to reverse in placepublic static boolean stringArrayContains(String[] objs, String objToCheck)
objs - the array to checkobjToCheck - the object to check forpublic static boolean stringArrayContains(String[] objs, String objToCheck, boolean ignoreCase)
objs - the array to checkobjToCheck - the object to check forignoreCase - whether to ignore casepublic static String zeroPad(String s, int len)
s with "0" characters until the resulting
 String is of length len.s - the string to pad.len - the desired length of the string.public static String toZeroPaddedString(int value, int len)
Only zero pads for non-negative integer values.
value - the integer value to convertlen - the desired minimum length of the stringpublic static String concatenateStrings(String[] strings, String separator)
strings - the array of stringsseparator - the separatorpublic static String[] concatenateStrings(String[] strings, String separator, int maxPerString)
strings - the array of stringsseparator - the separatormaxPerString - the maximum number of Strings per each produced Stringpublic static String[] splitString(String string, int maxSegLength)
string - the string to splitmaxSegLength - the maximum length of a single segmentpublic static int countOccurrences(String string, char charToCount)
string - the stringcharToCount - the character of interestpublic static int countUnquotedOccurrences(String string, char charToCount, char quoteChar, char escapeChar)
 For example, the following will return 2:
 countUnquotedOccurrences("Foo = 'warum?', ?, ?", '?', '\'', '\\')
string - the stringcharToCount - the character of interestquoteChar - the character used for quoted stringsescapeChar - the character used as an escape characterpublic static String toUpperCase(String string)
string - the string to uppercasepublic static String toUpperCase(String string, String ifNull)
string - the string to upper casecharToCount - the string to return if the string is nullpublic static String toLowerCase(String string)
string - the string to lower casepublic static String toLowerCase(String string, String ifNull)
string - the string to lower casecharToCount - the string to return if the string is nullpublic static String[] getStringsFromDelimitedToken(String token)
A single comma is treated as the delimiter. The enclosing curly braces can be omitted.
token - the string tokenpublic static String[] getStringsFromDelimitedToken(String token, String delim)
The enclosing curly braces can be omitted.
NOTE: consecutive delimitters are recognized, both leading, trailing, and within the string. For example, getStringsFromArrayToken("{,, foo,, bar, zad,,, }", ",") will return an array of: [null, null, "foo", null, "bar", "zad", null, null, null].
token - the string tokendelim - the delimiterpublic static String makeString(List<Character> charList)
If the list is empty, an empty String will be returned.
charList - the Character listpublic static String makeString(List<Character> charList, String defString)
If the list is null or empty, return the specified default String.
charList - the Character listdefString - the default String, used if the list is null/emptypublic static String expandQuotes(String s)
For exmaple, if the input string is: |matt "likes" the news|, the returned string is: |matt ""likes"" the news|.
s - the input string that may contain doubled quotespublic static String collapseQuotes(String s)
For exmaple, if the input string is: |matt ""likes"" the news|, the returned string is: |matt "likes" the news|.
s - the input string that may contain doubled quotespublic static String convertEmptyToNull(String str)
Trims the string before checking.
str - the string to checkpublic static String getString(Map source, String key) throws IfsException
source - the Map from which to get the String valuekey - the key for the String valueIfsException - 90008: if the cast failspublic static Boolean getBoolean(Map source, String key) throws IfsException
source - the Map from which to get the Boolean valuekey - the key for the Boolean valueIfsException - 90008: if the cast failspublic static Integer getInteger(Map source, String key) throws IfsException
source - the Map from which to get the Integer valuekey - the key for the Integer valueIfsException - 90008: if the cast failspublic static Long getLong(Map source, String key) throws IfsException
source - the Map from which to get the Long valuekey - the key for the Long valueIfsException - 90008: if the cast failspublic static Date getDate(Map source, String key) throws IfsException
source - the Map from which to get the Date valuekey - the key for the Date valueIfsException - 90008: if the cast failspublic static long[] getLongArray(Map source, String key) throws IfsException
source - the Map from which to get the Long array valuekey - the key for the Long array valueIfsException - 90008: if the cast failspublic static String[] getStringArray(Map source, String key) throws IfsException
source - the Map from which to get the String array valuekey - the key for the String array valueIfsException - 90008: if the cast failspublic static AttributeValue[] toAttributeValueArray(List<AttributeValue> avList)
avList - the list of AttributeValuepublic static Map<String,String> getStringStringMap(String[] keys, String[] values) throws IfsException
keys - the keysvalues - the valuesIfsException - (19004) if the arrays are not of equal lengthpublic static Map<String,Long> getStringLongMap(String[] keys, Long[] values) throws IfsException
keys - the keysvalues - the valuesIfsException - (19004) if the arrays are not of equal lengthpublic static Map<String,Double> getStringDoubleMap(String[] keys, Double[] values) throws IfsException
keys - the keysvalues - the valuesIfsException - (19004) if the arrays are not of equal lengthpublic static Map<String,AttributeValue> getStringLibraryObjectMap(String[] keys, LibraryObject[] values) throws IfsException
keys - the keysvalues - the valuesIfsException - (19004) if the arrays are not of equal lengthpublic static Map<Long,String> getLongStringMap(Long[] keys, String[] values) throws IfsException
keys - the keysvalues - the valuesIfsException - (19004) if the arrays are not of equal lengthpublic static Map<Long,Long> getLongLongMap(Long[] keys, Long[] values) throws IfsException
keys - the keysvalues - the valuesIfsException - (19004) if the arrays are not of equal lengthpublic static Map<Long,Double> getLongDoubleMap(Long[] keys, Double[] values) throws IfsException
keys - the keysvalues - the valuesIfsException - (19004) if the arrays are not of equal lengthpublic static Map<Long,AttributeValue> getLongLibraryObjectMap(Long[] keys, LibraryObject[] values) throws IfsException
keys - the keysvalues - the valuesIfsException - (19004) if the arrays are not of equal lengthCopyright © 2025. All rights reserved.