Package org.jibx.binding.classes
Class MungedClass
java.lang.Object
org.jibx.binding.classes.MungedClass
Modifiable class handler. Each instance controls changes to a particular
class modified by one or more binding definitions. As methods are generated
they're checked for uniqueness. If an already-generated method is found with
the same characteristics (including byte code) as the one being generated,
the already-generated is used instead.
- Author:
- Dennis M. Sosnoski
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Filter for class files generated by JiBX. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ClassFile[]
Empty class file array.private static final String[]
Name and signature for generated methods without standard prefix.private ClassFile
Munged class file information.private ExistingMethod[]
Existing binding methods in class.private String
List of factory names for this class.private HashMap
Map from method byte code and signature to method item.private static ArrayList
Munged class information.private static HashMap
Map from generated class to binding information.private static HashSet
Set of class names in list (used to assure uniqueness).private static HashMap
Map of directories already checked for JiBX classes.private static HashMap
Map from class name to binding information.private static ArrayList
Munged classes to be unique-added at end of binding. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
addFactory
(String fact) Add binding factory to class.static void
Add class file to set modified.(package private) static void
checkDirectory
(File root, String pack) Check directory for JiBX generated files.static void
Add unique support class at end of binding process.static ClassFile[][]
Finalize class name assignments and dispositions.(package private) ClassFile
Get munged class file information.(package private) static MungedClass
getInstance
(ClassFile cf) Get modification tracking information for class.(package private) BindingMethod
getUniqueMethod
(MethodBuilder builder, boolean suffix) Get unique method.static ClassFile
Get unique generated support class.private void
Delete pre-existing binding methods that are no longer needed.static void
reset()
Discard cached information and reset in preparation for a new binding run.(package private) void
Generate factory list.static void
Write all modified class files, and delete all obsolete class files from previous runs of the binding compiler.
-
Field Details
-
EMPTY_CLASSFILE_ARRAY
Empty class file array. -
EXTRA_METHODS_MATCHES
Name and signature for generated methods without standard prefix. -
s_classes
Munged class information. -
s_classNameSet
Set of class names in list (used to assure uniqueness). -
s_classMap
Map from generated class to binding information. -
s_directories
Map of directories already checked for JiBX classes. -
s_nameMap
Map from class name to binding information. -
s_pendingClasses
Munged classes to be unique-added at end of binding. -
m_classFile
Munged class file information. -
m_methodMap
Map from method byte code and signature to method item. -
m_existingMethods
Existing binding methods in class. -
m_factoryList
List of factory names for this class.
-
-
Constructor Details
-
MungedClass
Constructor. This sets up for modifying a class with added methods.- Parameters:
cf
- owning class file information
-
-
Method Details
-
getClassFile
ClassFile getClassFile()Get munged class file information.- Returns:
- class file information for bound class
-
purgeUnusedMethods
private void purgeUnusedMethods()Delete pre-existing binding methods that are no longer needed. -
getUniqueMethod
Get unique method. If a method matching the byte code of the supplied method has already been defined the existing method is returned. Otherwise the method is added to the definitions. If necessary, a number suffix is appended to the method name to prevent conflicts with existing names.- Parameters:
builder
- method to be definedsuffix
- append name suffix to assure uniqueness flag- Returns:
- defined method item
-
getUniqueSupportClass
Get unique generated support class. Allows tracking of all generated classes for common handling with the bound classes. Each generated support class is associated with a particular bound class.- Parameters:
cf
- generated class file- Returns:
- unique class file information
-
checkDirectory
Check directory for JiBX generated files. Scans through all class files in the target directory and loads any that start with the JiBX identifier string which have not been added to the preserve list.- Parameters:
root
- class path root for directory (non-null
)pack
- package relative to root directory- Throws:
JiBXException
- on configuration error
-
addFactory
Add binding factory to class. The binding factories are accumulated as a delimited string during generation, then dumped to a static field in the class at the end.- Parameters:
fact
- binding factory name
-
setFactoryList
void setFactoryList()Generate factory list. Adds or replaces the existing static array of factories in the class. -
getInstance
Get modification tracking information for class.- Parameters:
cf
- information for class to be modified (must be writable)- Returns:
- binding information for class
- Throws:
JiBXException
- on configuration error
-
delayedAddUnique
Add unique support class at end of binding process. This allows a class to be constructed in steps during handling of one or more bindings, with the class finished and checked for uniqueness only after all bindings have been handled. The actual add of the class is done during thefixDispositions()
handling.- Parameters:
cf
- class file to be added as unique support class at end of binding
-
addModifiedClass
Add class file to set modified. This uses the class name as a identifier to prevent duplicate entries in the list, so that classes which are still under construction can be handled.- Parameters:
cf
-
-
fixDispositions
Finalize class name assignments and dispositions.- Returns:
- three-way array of class files, for modified, unchanged, and deleted
-
writeChanges
Write all modified class files, and delete all obsolete class files from previous runs of the binding compiler.- Throws:
JiBXException
- on write error
-
reset
public static void reset()Discard cached information and reset in preparation for a new binding run.
-