Package org.jibx.binding.classes
Class ClassCache
- java.lang.Object
-
- org.jibx.binding.classes.ClassCache
-
public class ClassCache extends Object
Cache for class files being modified. Handles loading and saving of class files. Classes are loaded directly from the file system paths supplied on initialization in preference to the system class path.- Author:
- Dennis M. Sosnoski
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClassCache.ClassCacheLocatorLocator using the cache.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddPreserveClass(String name)Add class name to set to be preserved without modification.static ClassFilegetClassFile(String name)Get class information.static FilegetModifiablePath()Return the first modifiable directory path from the classpath in use.static booleanhasClassFile(String name)Check if class information has been loaded.static booleanisPreserveClass(String name)Check if a class is to be preserved without modification.static ClassFilerequireClassFile(String name)Get required class information.static voidsetPaths(String[] paths)Set class paths to be searched.
-
-
-
Method Detail
-
addPreserveClass
public static void addPreserveClass(String name)
Add class name to set to be preserved without modification. If the class information has already been loaded, this forces the modifiable setting to unmodifiable.- Parameters:
name- fully-qualified class name
-
isPreserveClass
public static boolean isPreserveClass(String name)
Check if a class is to be preserved without modification.- Parameters:
name- fully-qualified class name- Returns:
trueif to be preserved,falseif not
-
getClassFile
public static ClassFile getClassFile(String name) throws org.jibx.runtime.JiBXException
Get class information. Looks up the class in cache, and if not already present tries to find it based on the class file search path list. If the class file is found it is loaded along with all superclasses.- Parameters:
name- fully-qualified name of class to be found- Returns:
- class information, or
nullif class not found - Throws:
org.jibx.runtime.JiBXException- on any error accessing class file
-
requireClassFile
public static ClassFile requireClassFile(String name) throws org.jibx.runtime.JiBXException
Get required class information. Looks up the class in cache, and if not already present tries to find it based on the class file search path list. If the class is not found this throws a runtime exception.- Parameters:
name- fully-qualified name of class to be found- Returns:
- class information, or
nullif class not found - Throws:
org.jibx.runtime.JiBXException- on any error accessing class file
-
hasClassFile
public static boolean hasClassFile(String name)
Check if class information has been loaded.- Parameters:
name- full-qualified name of class to be checked- Returns:
trueif found
-
getModifiablePath
public static File getModifiablePath()
Return the first modifiable directory path from the classpath in use.- Returns:
- modifiable directory, or
nullif none
-
setPaths
public static void setPaths(String[] paths)
Set class paths to be searched. Discards jar file paths and normalizes all other paths (except the empty path) to end with the system path separator character.- Parameters:
paths- ordered set of paths to be searched for class files
-
-