ice.util
Class Defs

java.lang.Object
  extended byice.util.Defs

public class Defs
extends Object


Field Summary
static byte[] EMPTY_BYTE_ARRAY
           
static char[] EMPTY_CHAR_ARRAY
           
static int[] EMPTY_INT_ARRAY
           
static long[] EMPTY_LONG_ARRAY
           
static Object[] EMPTY_OBJECT_ARRAY
           
static String EMPTY_STRING
           
static String[] EMPTY_STRING_ARRAY
           
static Object NO_SYNCHRONIZATION
          Useful tag to explicitly indicate intention not to use any synchronization object locks instead of simply writing null when applicable
static Object NOT_FOUND
          Usefull tag to distinguish null value and value absence
 
Constructor Summary
Defs()
           
 
Method Summary
static void badArg()
          Convinient method to throw IllegalArgumentException
static boolean booleanProperty(String name)
          Shortcut for booleanProperty(name, false)
static boolean booleanProperty(String name, boolean defaultValue)
          If security manager allow access to the system property name and it exists, then return true if it is set to yes, true and false if set to no, false.
static Class getClass(String className)
          Utility to return result of Class.forName(className) or null if it throws ClassNotFoundException or SecurityException
static Method getMethod(Class sourceClass, String name, Class[] signature)
          Utility to return result of sourceClass.getMethod(name, signature) or null if it throws NoSuchMethodException or SecurityException
static Method getMethod(String className, String name, Class[] signature)
          Utility to return result of Class.forName(className).getMethod(name, signature) or null if it throws exceptions
static int intProperty(String name, int defaultValue)
          Return value for system property name parsed as int or defaultValue if the property does not exist or a security manager denies access to it
static Object newClassInstance(Class cl)
          Utility to return result of cl.newInstance() or null if it throws IllegalAccessException, InstantiationException, LinkageError or SecurityException
static Object newClassInstance(String className)
           
static Object[] newObjectArray(int size)
          Utility shortcut for:
static String property(String name)
          Equivalent to property(name, null)
static String property(String name, String defaultValue)
          Return value for system property name or defaultValue if the property does not exist or a security manager denies access to it
static void setProperty(String property, String value)
          Set system property to value.
static void setSandBoxEnabled()
           
static void setSystemProperty(String name, String value)
          Set system property to value.
static String sysProperty(String name)
          Alias to property(String name)
static String sysProperty(String name, String defaultValue)
          Alias to property(String name, String defaultValue)
static boolean sysPropertyBoolean(String name)
          Alias to booleanProperty(String name)
static boolean sysPropertyBoolean(String name, boolean defaultValue)
          Alias to booleanProperty(String name, boolean defaultValue)
static int sysPropertyInt(String name, int defaultValue)
          Alias to intProperty(String name, int defaultValue)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_FOUND

public static final Object NOT_FOUND
Usefull tag to distinguish null value and value absence


NO_SYNCHRONIZATION

public static final Object NO_SYNCHRONIZATION
Useful tag to explicitly indicate intention not to use any synchronization object locks instead of simply writing null when applicable


EMPTY_STRING

public static final String EMPTY_STRING
See Also:
Constant Field Values

EMPTY_BYTE_ARRAY

public static final byte[] EMPTY_BYTE_ARRAY

EMPTY_CHAR_ARRAY

public static final char[] EMPTY_CHAR_ARRAY

EMPTY_INT_ARRAY

public static final int[] EMPTY_INT_ARRAY

EMPTY_LONG_ARRAY

public static final long[] EMPTY_LONG_ARRAY

EMPTY_OBJECT_ARRAY

public static final Object[] EMPTY_OBJECT_ARRAY

EMPTY_STRING_ARRAY

public static final String[] EMPTY_STRING_ARRAY
Constructor Detail

Defs

public Defs()
Method Detail

newObjectArray

public static Object[] newObjectArray(int size)
Utility shortcut for:
    (size != 0) ? new Object[size] : Defs.EMPTY_OBJECT_ARRAY;
 


property

public static String property(String name)
Equivalent to property(name, null)


property

public static String property(String name,
                              String defaultValue)
Return value for system property name or defaultValue if the property does not exist or a security manager denies access to it


intProperty

public static int intProperty(String name,
                              int defaultValue)
Return value for system property name parsed as int or defaultValue if the property does not exist or a security manager denies access to it


booleanProperty

public static boolean booleanProperty(String name)
Shortcut for booleanProperty(name, false)


booleanProperty

public static boolean booleanProperty(String name,
                                      boolean defaultValue)
If security manager allow access to the system property name and it exists, then return true if it is set to yes, true and false if set to no, false. Otherwise returns defaultValue


sysProperty

public static String sysProperty(String name)
Alias to property(String name)


sysProperty

public static String sysProperty(String name,
                                 String defaultValue)
Alias to property(String name, String defaultValue)


sysPropertyInt

public static int sysPropertyInt(String name,
                                 int defaultValue)
Alias to intProperty(String name, int defaultValue)


sysPropertyBoolean

public static boolean sysPropertyBoolean(String name)
Alias to booleanProperty(String name)


sysPropertyBoolean

public static boolean sysPropertyBoolean(String name,
                                         boolean defaultValue)
Alias to booleanProperty(String name, boolean defaultValue)


setProperty

public static void setProperty(String property,
                               String value)
Set system property to value. If SecurityManager denies property modification, silently ignore property change


setSandBoxEnabled

public static void setSandBoxEnabled()

setSystemProperty

public static void setSystemProperty(String name,
                                     String value)
Set system property to value. If SecurityManager denies property modification, print debug trace


getClass

public static Class getClass(String className)
Utility to return result of Class.forName(className) or null if it throws ClassNotFoundException or SecurityException


newClassInstance

public static Object newClassInstance(Class cl)
Utility to return result of cl.newInstance() or null if it throws IllegalAccessException, InstantiationException, LinkageError or SecurityException


newClassInstance

public static Object newClassInstance(String className)

getMethod

public static Method getMethod(Class sourceClass,
                               String name,
                               Class[] signature)
Utility to return result of sourceClass.getMethod(name, signature) or null if it throws NoSuchMethodException or SecurityException


getMethod

public static Method getMethod(String className,
                               String name,
                               Class[] signature)
Utility to return result of Class.forName(className).getMethod(name, signature) or null if it throws exceptions


badArg

public static void badArg()
                   throws IllegalArgumentException
Convinient method to throw IllegalArgumentException

Throws:
IllegalArgumentException