|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sibvisions.util.type.ResourceUtil
public final class ResourceUtil
The ResourceUtil contains resource and class
dependent utility methods.
| Method Summary | |
|---|---|
static void |
addResourceArchive(int pIndex,
IResourceArchive pArchive)
Adds a resource archive to the given position in the list of known archives. |
static void |
addResourceArchive(IResourceArchive pArchive)
Adds a resource archive to the list of known archives. |
static boolean |
getAccessibleBoolean(java.lang.String pName,
boolean pDefaultValue)
Gets the boolean value of a system property, if the property is accessible. |
static java.lang.String |
getAccessibleProperty(java.lang.String pName,
java.lang.String pDefaultValue)
Gets the string value of a system property, if the property is accessible. |
static java.lang.ClassLoader |
getDefaultClassLoader()
Gets the default class loader. |
static java.io.File |
getFileForClass(java.lang.ClassLoader pLoader,
java.lang.String pClassName)
Searches the file in which a class is stored. |
static java.io.File |
getFileForClass(java.lang.String pClassName)
Searches the file in which a class is stored. |
static java.lang.String |
getFqClassName(java.lang.Object pScope)
Returns the full qualified class name for an object. |
static java.lang.Class<?>[] |
getInterfaces(java.lang.Class<?> pClass,
boolean pCheckInterfaces,
java.lang.Class<?>... pIncluded)
Gets interfaces from a specific class and all parent classes, recursively. |
static void |
getInterfaces(java.util.List<java.lang.Class<?>> pInterfaces,
java.lang.Class<?> pClass,
boolean pCheckInterfaces,
java.lang.Class<?>... pIncluded)
Gets interfaces from a specific class and all parent classes, recursively. |
static java.lang.String |
getLocationForClass(java.lang.ClassLoader pLoader,
java.lang.String pClassName)
Searches the location where a class is stored. |
static java.lang.String |
getLocationForClass(java.lang.String pClassName)
Searches the location where a class is stored. |
static java.lang.String |
getName(java.lang.Class<?> pClass)
Gets the name of a class. |
static java.lang.String |
getPackage(java.lang.Class<?> pClass)
Gets the package name from a class independent of Class.getPackage(). |
static java.lang.String |
getPathForClass(java.lang.String pClassName)
Searches the directory where a class is stored. |
static java.net.URL |
getResource(java.lang.ClassLoader pLoader,
java.lang.String pResource)
Finds a resource with a given name. |
static java.net.URL |
getResource(java.lang.String pResource)
Finds a resource with a given name. |
static java.util.List<IResourceArchive> |
getResourceArchives()
Gets the current list of known resource archives. |
static java.io.InputStream |
getResourceAsStream(java.lang.ClassLoader pLoader,
java.lang.String pResource)
Finds a resource with a given name. |
static java.io.InputStream |
getResourceAsStream(java.lang.String pResource)
Finds a resource with a given name. |
static java.lang.ClassLoader |
getResourceClassLoader(java.lang.Object pObject)
Get the current class loader for a given object. |
static java.lang.ClassLoader |
getThreadClassLoader()
Gets the resource class loader for the current thread, if set. |
static void |
removeAllResourceArchives()
Removes all resource archives from the list of known archives. |
static void |
removeResourceArchive(IResourceArchive pArchive)
Removes a resource archive from the list of known archives. |
static void |
setDefaultClassLoader(java.lang.ClassLoader pClassLoader)
Sets the default class loader. |
static void |
setThreadClassLoader(java.lang.ClassLoader pClassLoader)
Sets the resource class loader for the current thread. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void addResourceArchive(IResourceArchive pArchive)
pArchive - the resource archive
public static void addResourceArchive(int pIndex,
IResourceArchive pArchive)
pIndex - the list indexpArchive - the resource archivepublic static void removeResourceArchive(IResourceArchive pArchive)
pArchive - the resource archivepublic static void removeAllResourceArchives()
public static java.util.List<IResourceArchive> getResourceArchives()
public static java.io.InputStream getResourceAsStream(java.lang.String pResource)
pResource as absolute pathpResource, if it's an absolute path, and search
in the classes or lib directory where this util class is storedClassLoader
pResource - one of the following: /package/<classname>.class,
C:\temp\config.xml, /tmp/config.xml
null if no resource with this name is foundgetResourceAsStream(ClassLoader, String)public static java.net.URL getResource(java.lang.String pResource)
pResource as absolute pathpResource, if it's an absolute path, and search
in the classes or lib directory where this util class is storedClassLoader
pResource - one of the following: /package/<classname>.class,
C:\temp\config.xml, /tmp/config.xml
null if no resource with this name is foundgetResource(ClassLoader, String)
public static java.io.InputStream getResourceAsStream(java.lang.ClassLoader pLoader,
java.lang.String pResource)
pResource as absolute pathpResource, if it's an absolute path, and search
in the classes or lib directory where this util class is storedClassLoader
pLoader - a specific class loader or null to use the system
class loader.pResource - one of the following: /package/<classname>.class,
C:\temp\config.xml, /tmp/config.xml
null if no resource with this name is found
public static java.net.URL getResource(java.lang.ClassLoader pLoader,
java.lang.String pResource)
pResource as absolute pathpResource, if it's an absolute path, and search
in the classes or lib directory where this util class is storedClassLoader
pLoader - a specific class loader or null to use the system
class loader.pResource - one of the following: /package/<classname>.class,
C:\temp\config.xml, /tmp/config.xml
null if no resource with this name is foundpublic static java.lang.String getPathForClass(java.lang.String pClassName)
pClassName - z.B.: /package/<class>.class
public static java.lang.String getLocationForClass(java.lang.String pClassName)
pClassName - z.B.: /package/<class>.class
getLocationForClass(ClassLoader, String)
public static java.lang.String getLocationForClass(java.lang.ClassLoader pLoader,
java.lang.String pClassName)
pLoader - a specific class loader or null to use the system
class loader.pClassName - z.B.: /package/<class>.class
public static java.io.File getFileForClass(java.lang.String pClassName)
pClassName - z.B.: /package/<class>.class
getFileForClass(ClassLoader, String)
public static java.io.File getFileForClass(java.lang.ClassLoader pLoader,
java.lang.String pClassName)
pLoader - a specific class loader or null to use the system
class loaderpClassName - z.B.: /package/<class>.class
public static java.lang.String getFqClassName(java.lang.Object pScope)
pScope - a class or object instance
public static java.lang.String getName(java.lang.Class<?> pClass)
pClass - class from which you want the name
public static java.lang.String getAccessibleProperty(java.lang.String pName,
java.lang.String pDefaultValue)
pName - the name of the system propertypDefaultValue - the default value if the property is null
or is not accessible
null,
otherwise the pDefaultValue
public static boolean getAccessibleBoolean(java.lang.String pName,
boolean pDefaultValue)
pName - the name of the system propertypDefaultValue - the default value if the property is null
or is not accessible
null,
otherwise the pDefaultValuepublic static java.lang.String getPackage(java.lang.Class<?> pClass)
Class.getPackage().
pClass - the loaded class
public static void setDefaultClassLoader(java.lang.ClassLoader pClassLoader)
pClassLoader - a class loaderpublic static java.lang.ClassLoader getDefaultClassLoader()
null if not explicitely setsetDefaultClassLoader(ClassLoader)public static void setThreadClassLoader(java.lang.ClassLoader pClassLoader)
Thread.getContextClassLoader().
pClassLoader - the class loader to usepublic static java.lang.ClassLoader getThreadClassLoader()
null if not setpublic static java.lang.ClassLoader getResourceClassLoader(java.lang.Object pObject)
null the class loader of this util class is returned.
pObject - the object
public static java.lang.Class<?>[] getInterfaces(java.lang.Class<?> pClass,
boolean pCheckInterfaces,
java.lang.Class<?>... pIncluded)
pClass - the start classpCheckInterfaces - true to get all parent interfaces from a detected interfacepIncluded - the allowed interfaces. A detected interface must be an instance of at least one
interface in the included list. The list won't be used for super interfaces.
public static void getInterfaces(java.util.List<java.lang.Class<?>> pInterfaces,
java.lang.Class<?> pClass,
boolean pCheckInterfaces,
java.lang.Class<?>... pIncluded)
pInterfaces - all found interfacespClass - the start classpCheckInterfaces - true to get all parent interfaces from a detected interfacepIncluded - the allowed interfaces. A detected interface must be an instance of at least one
interface in the included list. The list won't be used for super interfaces.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||