org.jasig.portal.utils
Class CommonUtils

java.lang.Object
  extended by org.jasig.portal.utils.CommonUtils

public class CommonUtils
extends Object

CommonUtils class contains base useful utilities

Version:
$Revision: 19776 $
Author:
Michael Ivanov

Constructor Summary
CommonUtils()
           
 
Method Summary
static String boolToStr(boolean bool)
          This method returns the String representation of the given boolean value.
static String envl(String sourceStr, String replaceStr)
          Replaces "sourceString" with "replaceString" if sourceString is null or empty
static boolean[] getFamilyPropertyArrayBoolean(Hashtable hash, String[] keys, String propName)
           
static boolean[] getFamilyPropertyArrayBoolean(Hashtable hash, String[] keys, String propName, boolean def)
           
static int[] getFamilyPropertyArrayInt(Hashtable hash, String[] keys, String propName)
           
static String[] getFamilyPropertyArrayString(Hashtable hash, String[] keys, String propName)
           
static String[] getFamilyPropertyArrayString(Hashtable hash, String[] keys, String propName, String def)
           
static String[] getFamilyPropertyArrayString(Hashtable hash, String[] keys, String propName, String[] def)
           
static String getFamilyPropertyString(Hashtable hash, String key, String propName, String def)
           
static Hashtable getFamilyProps(Properties props, String prefix, String delim, Properties defaultProps)
           
static int[] getSplitIntByCommas(String str, String delim, int def)
          This method gets a properties of int from given string splitted by commas.
static String[] getSplitStringByCommas(String str, String delim)
          This method gets an array of strings from given string splitted by commas.
static Properties getSplitStringByCommas(String keys, String values, String delim)
          This method gets a properties of strings from given string splitted by commas.
static boolean isArrayEmpty(Object[] objects)
          This method checks if an array of objects is empty or not.
static boolean isArrayEmpty(String[] objects)
          This method checks if an array of strings is empty or not.
static String nvl(String sourceStr)
          Replaces "sourceString" with "" if sourceString equals null
static String nvl(String sourceStr, String replaceStr)
          Replaces "sourceString" with "replaceString" if sourceString equals null
static String nvl(String sourceStr, String replaceStr, String prefix)
          Replaces "sourceString" with "replaceString" if sourceString equals null
static boolean odd(int i)
           
static boolean parseBoolean(String str)
          This method returns the boolean value for the given String representation ("yes"-"no").
static boolean parseBoolean(String str, boolean defaultValue)
           
static int parseInt(String str)
           
static int parseInt(String str, int defaultValue)
           
static void replaceSubstVariables(Hashtable original, Hashtable subst)
           
static String replaceText(String text, String replacedString, String newString)
          replaces "replacedString" with "newString" in "text"
static void setNoCache(HttpServletResponse res)
          Sets "no cache" directives to the given response
static String stackTraceToString(Exception e)
           
static boolean strToBool(String bool)
          This method returns the boolean value for the given String representation ("true"-"false").
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonUtils

public CommonUtils()
Method Detail

setNoCache

public static void setNoCache(HttpServletResponse res)
Sets "no cache" directives to the given response

Parameters:
res - HttpServletResponse response

nvl

public static String nvl(String sourceStr,
                         String replaceStr)
Replaces "sourceString" with "replaceString" if sourceString equals null

Parameters:
sourceStr - the string to replace
replaceStr - the replacement string
Returns:
the processed string

envl

public static String envl(String sourceStr,
                          String replaceStr)
Replaces "sourceString" with "replaceString" if sourceString is null or empty

Parameters:
sourceStr - the string to replace
replaceStr - the replacement string
Returns:
the processed string

nvl

public static String nvl(String sourceStr,
                         String replaceStr,
                         String prefix)
Replaces "sourceString" with "replaceString" if sourceString equals null

Parameters:
sourceStr - the string to replace
replaceStr - the replacement string
prefix - the prefix
Returns:
the processed string

nvl

public static String nvl(String sourceStr)
Replaces "sourceString" with "" if sourceString equals null

Parameters:
sourceStr - string to replace
Returns:
the processed string

replaceText

public static String replaceText(String text,
                                 String replacedString,
                                 String newString)
replaces "replacedString" with "newString" in "text"

Parameters:
text - text where to replace
replacedString - string to replace
newString - new string
Returns:
new text

replaceSubstVariables

public static void replaceSubstVariables(Hashtable original,
                                         Hashtable subst)

stackTraceToString

public static String stackTraceToString(Exception e)

getSplitStringByCommas

public static String[] getSplitStringByCommas(String str,
                                              String delim)
This method gets an array of strings from given string splitted by commas.

Parameters:
str - a string value
delim - a delimeter
Returns:
an array of strings

getSplitStringByCommas

public static Properties getSplitStringByCommas(String keys,
                                                String values,
                                                String delim)
This method gets a properties of strings from given string splitted by commas.

Parameters:
keys - a string keys for properties
values - a string value
delim - a delimeter
Returns:
an array of strings

getSplitIntByCommas

public static int[] getSplitIntByCommas(String str,
                                        String delim,
                                        int def)
This method gets a properties of int from given string splitted by commas.

Parameters:
str - a string keys for properties
delim - a delimeter
def - a default value
Returns:
an array of int

getFamilyProps

public static Hashtable getFamilyProps(Properties props,
                                       String prefix,
                                       String delim,
                                       Properties defaultProps)

getFamilyPropertyArrayString

public static String[] getFamilyPropertyArrayString(Hashtable hash,
                                                    String[] keys,
                                                    String propName,
                                                    String[] def)

getFamilyPropertyString

public static String getFamilyPropertyString(Hashtable hash,
                                             String key,
                                             String propName,
                                             String def)

getFamilyPropertyArrayString

public static String[] getFamilyPropertyArrayString(Hashtable hash,
                                                    String[] keys,
                                                    String propName,
                                                    String def)

getFamilyPropertyArrayString

public static String[] getFamilyPropertyArrayString(Hashtable hash,
                                                    String[] keys,
                                                    String propName)

getFamilyPropertyArrayBoolean

public static boolean[] getFamilyPropertyArrayBoolean(Hashtable hash,
                                                      String[] keys,
                                                      String propName,
                                                      boolean def)

getFamilyPropertyArrayBoolean

public static boolean[] getFamilyPropertyArrayBoolean(Hashtable hash,
                                                      String[] keys,
                                                      String propName)

getFamilyPropertyArrayInt

public static int[] getFamilyPropertyArrayInt(Hashtable hash,
                                              String[] keys,
                                              String propName)

parseBoolean

public static boolean parseBoolean(String str,
                                   boolean defaultValue)

boolToStr

public static String boolToStr(boolean bool)
This method returns the String representation of the given boolean value.

Parameters:
bool - a value of boolean type
Returns:
"true" if bool is true, "false" - otherwise

strToBool

public static boolean strToBool(String bool)
This method returns the boolean value for the given String representation ("true"-"false").

Parameters:
bool - a String value
Returns:
true if bool is "true", false - otherwise

parseBoolean

public static boolean parseBoolean(String str)
This method returns the boolean value for the given String representation ("yes"-"no").

Parameters:
str - a String value
Returns:
true if str is "yes", false - otherwise

parseInt

public static int parseInt(String str,
                           int defaultValue)

parseInt

public static int parseInt(String str)

odd

public static boolean odd(int i)

isArrayEmpty

public static boolean isArrayEmpty(Object[] objects)
This method checks if an array of objects is empty or not.

Parameters:
objects - an array of objects
Returns:
true if array is empty, false - otherwise

isArrayEmpty

public static boolean isArrayEmpty(String[] objects)
This method checks if an array of strings is empty or not.

Parameters:
objects - an array of strings
Returns:
true if array is empty, false - otherwise


Copyright © 2010 Jasig. All Rights Reserved.