Package com.twelvemonkeys.lang
Class SystemUtil
- java.lang.Object
-
- com.twelvemonkeys.lang.SystemUtil
-
public final class SystemUtil extends java.lang.ObjectA utility class with some useful system-related functions.NOTE: This class is not considered part of the public API and may be changed without notice
- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/lang/SystemUtil.java#3 $
- Author:
- Harald Kuhr, last modified by $Author: haku $
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSTD_PROPERTIES".properties"static java.lang.StringXML_PROPERTIES".xml"
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Objectclone(java.lang.Cloneable pObject)static booleanisClassAvailable(java.lang.String pClassName)Tests if a named class is generally available.static booleanisClassAvailable(java.lang.String pClassName, java.lang.Class pFromClass)Tests if a named class is available from another class.static booleanisFieldAvailable(java.lang.String pClassName, java.lang.String pFieldName)static booleanisFieldAvailable(java.lang.String pClassName, java.lang.String pFieldName, java.lang.Class pFromClass)static booleanisMethodAvailable(java.lang.String pClassName, java.lang.String pMethodName)static booleanisMethodAvailable(java.lang.String pClassName, java.lang.String pMethodName, java.lang.Class[] pParams)static booleanisMethodAvailable(java.lang.String pClassName, java.lang.String pMethodName, java.lang.Class[] pParams, java.lang.Class pFromClass)static java.util.PropertiesloadProperties(java.lang.Class pClass)Utility method for loading a properties-file for a given class.static java.util.PropertiesloadProperties(java.lang.Class pClass, java.lang.String pName)Utility method for loading a named properties-file for a class.static java.util.PropertiesloadProperties(java.lang.String pName)Utility method for loading a named properties-file.static voidmain(java.lang.String[] args)
-
-
-
Method Detail
-
loadProperties
public static java.util.Properties loadProperties(java.lang.Class pClass, java.lang.String pName) throws java.io.IOExceptionUtility method for loading a named properties-file for a class.The properties-file is loaded through either:
- The given class' class loader (from classpath)
- Or, the system class loader (from classpath)
- Or, if it cannot be found in the classpath, an attempt to read from the current directory (or full path if given).
Both normal java.util.Properties and com.twelvemonkeys.util.XMLProperties are supported (XML-properties must have ".xml" as its file extension).
- Parameters:
pClass- The class to load properties for. If this parameter isnull, the method will work exactly asloadProperties(String)pName- The name of the properties-file. If this parameter isnull, the method will work exactly asloadProperties(Class)- Returns:
- A Properties mapping read from the given file or for the given class.
- Throws:
java.lang.NullPointerException- if bothpNameandpClassparamters arenulljava.io.IOException- if an error occurs during load.java.io.FileNotFoundException- if no properties-file could be found.- See Also:
loadProperties(String),loadProperties(Class),ClassLoader.getResourceAsStream(java.lang.String),ClassLoader.getSystemResourceAsStream(java.lang.String)
-
loadProperties
public static java.util.Properties loadProperties(java.lang.Class pClass) throws java.io.IOExceptionUtility method for loading a properties-file for a given class. The properties are searched for on the form "com/package/ClassName.properties" or "com/package/ClassName.xml".The properties-file is loaded through either:
- The given class' class loader (from classpath)
- Or, the system class loader (from classpath)
- Or, if it cannot be found in the classpath, an attempt to read from the current directory (or full path if given).
Both normal java.util.Properties and com.twelvemonkeys.util.XMLProperties are supported (XML-properties must have ".xml" as its file extension).
- Parameters:
pClass- The class to load properties for- Returns:
- A Properties mapping for the given class.
- Throws:
java.lang.NullPointerException- if thepClassparamters isnulljava.io.IOException- if an error occurs during load.java.io.FileNotFoundException- if no properties-file could be found.- See Also:
loadProperties(String),loadProperties(Class, String),ClassLoader.getResourceAsStream(java.lang.String),ClassLoader.getSystemResourceAsStream(java.lang.String)
-
loadProperties
public static java.util.Properties loadProperties(java.lang.String pName) throws java.io.IOExceptionUtility method for loading a named properties-file.The properties-file is loaded through either:
- The system class loader (from classpath)
- Or, if it cannot be found in the classpath, an attempt to read from the current directory.
Both normal java.util.Properties and com.twelvemonkeys.util.XMLProperties are supported (XML-properties must have ".xml" as its file extension).
- Parameters:
pName- The name of the properties-file.- Returns:
- A Properties mapping read from the given file.
- Throws:
java.lang.NullPointerException- if thepNameparamters isnulljava.io.IOException- if an error occurs during load.java.io.FileNotFoundException- if no properties-file could be found.- See Also:
loadProperties(Class),loadProperties(Class, String),ClassLoader.getSystemResourceAsStream(java.lang.String)
-
clone
public static java.lang.Object clone(java.lang.Cloneable pObject) throws java.lang.CloneNotSupportedException- Throws:
java.lang.CloneNotSupportedException
-
main
public static void main(java.lang.String[] args) throws java.lang.CloneNotSupportedException- Throws:
java.lang.CloneNotSupportedException
-
isClassAvailable
public static boolean isClassAvailable(java.lang.String pClassName)
Tests if a named class is generally available. If a class is considered available, a call toClass.forName(pClassName)will not result in an exception.- Parameters:
pClassName- the class name to test- Returns:
trueif available
-
isClassAvailable
public static boolean isClassAvailable(java.lang.String pClassName, java.lang.Class pFromClass)Tests if a named class is available from another class. If a class is considered available, a call toClass.forName(pClassName, true, pFromClass.getClassLoader())will not result in an exception.- Parameters:
pClassName- the class name to testpFromClass- the class to test from- Returns:
trueif available
-
isFieldAvailable
public static boolean isFieldAvailable(java.lang.String pClassName, java.lang.String pFieldName)
-
isFieldAvailable
public static boolean isFieldAvailable(java.lang.String pClassName, java.lang.String pFieldName, java.lang.Class pFromClass)
-
isMethodAvailable
public static boolean isMethodAvailable(java.lang.String pClassName, java.lang.String pMethodName)
-
isMethodAvailable
public static boolean isMethodAvailable(java.lang.String pClassName, java.lang.String pMethodName, java.lang.Class[] pParams)
-
isMethodAvailable
public static boolean isMethodAvailable(java.lang.String pClassName, java.lang.String pMethodName, java.lang.Class[] pParams, java.lang.Class pFromClass)
-
-