|
||||||||||
| 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(String pName,
boolean pDefaultValue)
Gets the boolean value of a system property, if the property is accessible. |
static String |
getAccessibleProperty(String pName,
String pDefaultValue)
Gets the string value of a system property, if the property is accessible. |
static File |
getFileForClass(ClassLoader pLoader,
String pClassName)
Searches the file in which a class is stored. |
static File |
getFileForClass(String pClassName)
Searches the file in which a class is stored. |
static String |
getFqClassName(Object pScope)
Returns the full qualified class name for an object. |
static Class<?>[] |
getInterfaces(Class<?> pClass,
boolean pCheckInterfaces,
Class<?>... pIncluded)
Gets interfaces from a specific class and all parent classes, recursively. |
static void |
getInterfaces(List<Class<?>> pInterfaces,
Class<?> pClass,
boolean pCheckInterfaces,
Class<?>... pIncluded)
Gets interfaces from a specific class and all parent classes, recursively. |
static String |
getLocationForClass(ClassLoader pLoader,
String pClassName)
Searches the location where a class is stored. |
static String |
getLocationForClass(String pClassName)
Searches the location where a class is stored. |
static String |
getName(Class<?> pClass)
Gets the name of a class. |
static String |
getPackage(Class<?> pClass)
Gets the package name from a class independent of Class.getPackage(). |
static String |
getPathForClass(String pClassName)
Searches the directory where a class is stored. |
static URL |
getResource(ClassLoader pLoader,
String pResource)
Finds a resource with a given name. |
static URL |
getResource(String pResource)
Finds a resource with a given name. |
static List<IResourceArchive> |
getResourceArchives()
Gets the current list of known resource archives. |
static InputStream |
getResourceAsStream(ClassLoader pLoader,
String pResource)
Finds a resource with a given name. |
static InputStream |
getResourceAsStream(String pResource)
Finds a resource with a given name. |
static ClassLoader |
getResourceClassLoader(Object pObject)
Get the current class loader for a given object. |
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(ClassLoader pClassLoader)
Sets the default class loader. |
| 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 List<IResourceArchive> getResourceArchives()
public static InputStream getResourceAsStream(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 URL getResource(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 InputStream getResourceAsStream(ClassLoader pLoader,
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 URL getResource(ClassLoader pLoader,
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 String getPathForClass(String pClassName)
pClassName - z.B.: /package/<class>.class
public static String getLocationForClass(String pClassName)
pClassName - z.B.: /package/<class>.class
getLocationForClass(ClassLoader, String)
public static String getLocationForClass(ClassLoader pLoader,
String pClassName)
pLoader - a specific class loader or null to use the system
class loader.pClassName - z.B.: /package/<class>.class
public static File getFileForClass(String pClassName)
pClassName - z.B.: /package/<class>.class
getFileForClass(ClassLoader, String)
public static File getFileForClass(ClassLoader pLoader,
String pClassName)
pLoader - a specific class loader or null to use the system
class loaderpClassName - z.B.: /package/<class>.class
public static String getFqClassName(Object pScope)
pScope - a class or object instance
public static String getName(Class<?> pClass)
pClass - class from which you want the name
public static String getAccessibleProperty(String pName,
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(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 String getPackage(Class<?> pClass)
Class.getPackage().
pClass - the loaded class
public static void setDefaultClassLoader(ClassLoader pClassLoader)
pClassLoader - a class loaderpublic static ClassLoader getResourceClassLoader(Object pObject)
null the class loader of this util class is returned.
pObject - the object
public static Class<?>[] getInterfaces(Class<?> pClass,
boolean pCheckInterfaces,
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(List<Class<?>> pInterfaces,
Class<?> pClass,
boolean pCheckInterfaces,
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 | |||||||||