Package org.jibx.binding.model
Class ClassWrapper
- java.lang.Object
-
- org.jibx.binding.model.ClassWrapper
-
- All Implemented Interfaces:
IClass
- Direct Known Subclasses:
ClassSourceWrapper
public class ClassWrapper extends java.lang.Object implements IClass
Wrapper for class information. This wraps the BCEL-based class handling implementation to support the interface defined for use with the binding model.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description private ClassFilem_classprivate IClassItem[]m_fieldsprivate IClassLocatorm_locatorprivate IClassItem[]m_methods
-
Constructor Summary
Constructors Constructor Description ClassWrapper(IClassLocator loc, ClassFile clas)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IClassItembuildItem(ClassItem item)Build an item wrapper.IClassItemgetBestMethod(java.lang.String name, java.lang.String type, java.lang.String[] args)Get information for best matching method.ClassFilegetClassFile()Get class file information.IClassItemgetDirectField(java.lang.String name)Get information for field.IClassItemgetField(java.lang.String name)Get information for field.IClassItem[]getFields()Get all fields of class.IClassItemgetInitializerMethod(java.lang.String sig)Get information for initializer.java.lang.String[]getInstanceSigs()Get signatures for all types of which instances of this type are instances.java.lang.String[]getInterfaces()Get names of all interfaces implemented directly by class.java.lang.StringgetJavaDoc()Get the JavaDoc comment for this class.IClassLocatorgetLocator()Get the locator which provided this class.IClassItemgetMethod(java.lang.String name, java.lang.String sig)Get information for method without respect to potential trailing arguments or return value.IClassItemgetMethod(java.lang.String name, java.lang.String[] sigs)Get information for method matching one of several possible signatures.IClassItem[]getMethods()Get all methods of class.java.lang.StringgetName()Get fully qualified class name.java.lang.StringgetPackage()Get package name.java.lang.StringgetSignature()Get signature for class as type.IClassItemgetStaticMethod(java.lang.String name, java.lang.String sig)Get information for static method without respect to return value.IClassgetSuperClass()Get superclass.booleanisAbstract()Check if class is abstract.booleanisAccessible(IClassItem item)Check accessible method.booleanisAssignable(IClass other)Check if a value of this type can be directly assigned to another type.booleanisImplements(java.lang.String sig)Check if class implements an interface.booleanisInterface()Check if class is an interface.booleanisModifiable()Check if class is modifiable.booleanisSuperclass(java.lang.String name)Check if another class is a superclass of this one.java.lang.ClassloadClass()Load class in executable form.
-
-
-
Field Detail
-
m_locator
private final IClassLocator m_locator
-
m_class
private final ClassFile m_class
-
m_fields
private IClassItem[] m_fields
-
m_methods
private IClassItem[] m_methods
-
-
Constructor Detail
-
ClassWrapper
public ClassWrapper(IClassLocator loc, ClassFile clas)
Constructor.- Parameters:
loc-clas-
-
-
Method Detail
-
buildItem
protected IClassItem buildItem(ClassItem item)
Build an item wrapper. This method may be overridden by subclasses to return a specialized form of wrapper.- Parameters:
item-- Returns:
- wrapper
-
getName
public java.lang.String getName()
Description copied from interface:IClassGet fully qualified class name.
-
getSignature
public java.lang.String getSignature()
Description copied from interface:IClassGet signature for class as type.- Specified by:
getSignaturein interfaceIClass- Returns:
- signature for class used as type
-
getPackage
public java.lang.String getPackage()
Description copied from interface:IClassGet package name.- Specified by:
getPackagein interfaceIClass- Returns:
- package name for class
-
getSuperClass
public IClass getSuperClass()
Description copied from interface:IClassGet superclass.- Specified by:
getSuperClassin interfaceIClass- Returns:
- superclass information
-
getInterfaces
public java.lang.String[] getInterfaces()
Description copied from interface:IClassGet names of all interfaces implemented directly by class.- Specified by:
getInterfacesin interfaceIClass- Returns:
- names of all interfaces implemented directly by class
(non-
null, empty array if none)
-
getInstanceSigs
public java.lang.String[] getInstanceSigs()
Description copied from interface:IClassGet signatures for all types of which instances of this type are instances.- Specified by:
getInstanceSigsin interfaceIClass- Returns:
- all signatures supported by instances
-
isImplements
public boolean isImplements(java.lang.String sig)
Description copied from interface:IClassCheck if class implements an interface.- Specified by:
isImplementsin interfaceIClass- Parameters:
sig- signature of interface to be checked- Returns:
trueif interface is implemented by class,falseif not
-
isAbstract
public boolean isAbstract()
Description copied from interface:IClassCheck if class is abstract.- Specified by:
isAbstractin interfaceIClass- Returns:
trueif class is abstract,falseif not
-
isInterface
public boolean isInterface()
Description copied from interface:IClassCheck if class is an interface.- Specified by:
isInterfacein interfaceIClass- Returns:
trueif class is an interface,falseif not
-
isModifiable
public boolean isModifiable()
Description copied from interface:IClassCheck if class is modifiable.- Specified by:
isModifiablein interfaceIClass- Returns:
trueif class is modifiable,falseif not
-
isSuperclass
public boolean isSuperclass(java.lang.String name)
Description copied from interface:IClassCheck if another class is a superclass of this one.- Specified by:
isSuperclassin interfaceIClass- Parameters:
name- potential superclass to be checked- Returns:
trueif named class is a superclass of this one,falseif not
-
getDirectField
public IClassItem getDirectField(java.lang.String name)
Description copied from interface:IClassGet information for field. This only checks for fields that are actually members of the class (not superclasses). TODO: make this work with both static and member fields- Specified by:
getDirectFieldin interfaceIClass- Parameters:
name- field name- Returns:
- field information, or
nullif field not found
-
getField
public IClassItem getField(java.lang.String name)
Description copied from interface:IClassGet information for field. If the field is not found directly, superclasses are checked for inherited fields matching the supplied name. TODO: make this work with both static and member fields
-
getMethod
public IClassItem getMethod(java.lang.String name, java.lang.String sig)
Description copied from interface:IClassGet information for method without respect to potential trailing arguments or return value. If the method is not found directly, superclasses are checked for inherited methods matching the supplied name. This compares the supplied partial signature against the actual method signature, and considers it a match if the actual sigature starts with the supplied signature. TODO: make this work with both static and member methods
-
getMethod
public IClassItem getMethod(java.lang.String name, java.lang.String[] sigs)
Description copied from interface:IClassGet information for method matching one of several possible signatures. If a match is not found directly, superclasses are checked for inherited methods matching the supplied name and signatures. The signature variations are checked in the order supplied. TODO: make this work with both static and member methods
-
getInitializerMethod
public IClassItem getInitializerMethod(java.lang.String sig)
Description copied from interface:IClassGet information for initializer. Only the class itself is checked for an initializer matching the argument list signature.- Specified by:
getInitializerMethodin interfaceIClass- Parameters:
sig- encoded argument list signature- Returns:
- method information, or
nullif method not found
-
getStaticMethod
public IClassItem getStaticMethod(java.lang.String name, java.lang.String sig)
Description copied from interface:IClassGet information for static method without respect to return value. Only the class itself is checked for a method matching the supplied name and argument list signature.- Specified by:
getStaticMethodin interfaceIClass- Parameters:
name- method namesig- encoded argument list signature- Returns:
- method information, or
nullif method not found
-
isAccessible
public boolean isAccessible(IClassItem item)
Description copied from interface:IClassCheck accessible method. Check if a field or method in another class is accessible from within this class.- Specified by:
isAccessiblein interfaceIClass- Parameters:
item- field or method information- Returns:
trueif accessible,falseif not
-
isAssignable
public boolean isAssignable(IClass other)
Description copied from interface:IClassCheck if a value of this type can be directly assigned to another type. This is basically the equivalent of the instanceof operator.- Specified by:
isAssignablein interfaceIClass- Parameters:
other- type to be assigned to- Returns:
trueif assignable,falseif not
-
getBestMethod
public IClassItem getBestMethod(java.lang.String name, java.lang.String type, java.lang.String[] args)
Description copied from interface:IClassGet information for best matching method. This tries to find a method which matches the specified name, return type, and argument types. If an exact match is not found it looks for a method with a return type that is extended or implemented by the specified type and arguments that are extended or implemented by the specified types. If no match is found for this class superclasses are checked. TODO: make this work with both static and member methods- Specified by:
getBestMethodin interfaceIClass- Parameters:
name- method nametype- return value type name (nullif indeterminant)args- argument value type names (nullif indeterminant)- Returns:
- method information, or
nullif method not found
-
getClassFile
public ClassFile getClassFile()
Description copied from interface:IClassGet class file information. TODO: eliminate this sucker- Specified by:
getClassFilein interfaceIClass- Returns:
- class file information
-
loadClass
public java.lang.Class loadClass()
Description copied from interface:IClassLoad class in executable form.
-
getFields
public IClassItem[] getFields()
Description copied from interface:IClassGet all fields of class.
-
getMethods
public IClassItem[] getMethods()
Description copied from interface:IClassGet all methods of class.- Specified by:
getMethodsin interfaceIClass- Returns:
- methods
-
getJavaDoc
public java.lang.String getJavaDoc()
Description copied from interface:IClassGet the JavaDoc comment for this class.- Specified by:
getJavaDocin interfaceIClass- Returns:
- comment text, or
nullif none or no source available
-
getLocator
public IClassLocator getLocator()
Description copied from interface:IClassGet the locator which provided this class.- Specified by:
getLocatorin interfaceIClass- Returns:
- locator
-
-