Package org.jibx.binding.classes
Class ClassItem
- java.lang.Object
-
- org.jibx.binding.classes.ClassItem
-
public class ClassItem extends java.lang.ObjectWrapper for field or method information. Provides the information needed for access to either existing or added methods in existing classes.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String[]m_argTypesArgument types for method.private ClassFilem_classFileOwning class information.private FieldOrMethodm_itemWrapped existing item.private java.lang.Stringm_nameItem name.private java.lang.String[]m_parmNamesParameter names for method (nullif not yet found).private java.lang.Stringm_signatureEncoded signature.private java.lang.Stringm_typeNameFully qualified class name of item type.private static java.util.HashMaps_primitiveMapMap for primitive type signature variants.private static java.util.HashMaps_signatureParamsMapMap from method signature to array of argument types.private static java.util.HashMaps_signatureTypeMapMap from method signature to return type.private static java.util.HashMaps_typeMapMap from type name to BCEL type.private static byteSIGNATURE_ATTRIBUTE_TAGTag value for signature attribute.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ClassItemfindStaticMethod(java.lang.String name, java.lang.String[] sigs)Get static method by fully qualified name.static ClassItemfindVirtualMethod(java.lang.String name, java.lang.String[] sigs)Get virtual method by fully qualified name.intgetAccessFlags()Get access flags.intgetArgumentCount()Get number of arguments for method.java.lang.StringgetArgumentType(int index)Get argument type as fully qualified class name.java.lang.String[]getArgumentTypes()Get argument types as array of fully qualified class names.ClassFilegetClassFile()Get owning class information.java.lang.String[]getExceptions()Get names of exceptions thrown by method.java.lang.StringgetFullName()Get fully-qualified class and method name.java.lang.StringgetGenericsSignature()Get the generics signature information for item.java.lang.StringgetName()Get item name.java.lang.StringgetParameterName(int index)Get method parameter name.static java.lang.String[]getParametersFromSignature(java.lang.String sig)Get parameter type names from method signature.static java.lang.StringgetPrimitiveSignature(java.lang.String type)Get the signature for a primitive.java.lang.StringgetSignature()Get method signature.static java.lang.String[]getSignatureVariants(java.lang.String name)Get all variant signatures for a fully qualified class name.static java.lang.StringgetTypeFromSignature(java.lang.String sig)Get return type names from method signature.java.lang.StringgetTypeName()Get item type as fully qualified class name.static booleanisAssignable(java.lang.String from, java.lang.String to)Check if a value of one type can be directly assigned to another type.booleanisInitializer()Check if item is an initializer.booleanisMethod()Check if item is a method.static booleanisPrimitive(java.lang.String type)Check if type is a primitive.booleanisStatic()Check if item is a static.voidmakeAccessible(ClassFile src)Make accessible item.voidsetAccessFlags(int flags)Set access flags.static TypetypeFromName(java.lang.String name)Create type from name.
-
-
-
Field Detail
-
SIGNATURE_ATTRIBUTE_TAG
private static final byte SIGNATURE_ATTRIBUTE_TAG
Tag value for signature attribute.- See Also:
- Constant Field Values
-
s_primitiveMap
private static java.util.HashMap s_primitiveMap
Map for primitive type signature variants.
-
s_typeMap
private static java.util.HashMap s_typeMap
Map from type name to BCEL type.
-
s_signatureParamsMap
private static java.util.HashMap s_signatureParamsMap
Map from method signature to array of argument types.
-
s_signatureTypeMap
private static java.util.HashMap s_signatureTypeMap
Map from method signature to return type.
-
m_classFile
private ClassFile m_classFile
Owning class information.
-
m_name
private java.lang.String m_name
Item name.
-
m_signature
private java.lang.String m_signature
Encoded signature.
-
m_typeName
private java.lang.String m_typeName
Fully qualified class name of item type.
-
m_argTypes
private java.lang.String[] m_argTypes
Argument types for method.
-
m_parmNames
private java.lang.String[] m_parmNames
Parameter names for method (nullif not yet found).
-
m_item
private FieldOrMethod m_item
Wrapped existing item.
-
-
Constructor Detail
-
ClassItem
public ClassItem(java.lang.String name, ClassFile cf, FieldOrMethod item)Constructor. Builds a wrapper for an item based on an existing field or method.- Parameters:
name- field or method namecf- owning class informationitem- field or method information
-
-
Method Detail
-
getClassFile
public ClassFile getClassFile()
Get owning class information.- Returns:
- owning class information
-
getName
public java.lang.String getName()
Get item name.- Returns:
- item name
-
getFullName
public java.lang.String getFullName()
Get fully-qualified class and method name.- Returns:
- fully-qualified class and method name
-
getTypeName
public java.lang.String getTypeName()
Get item type as fully qualified class name.- Returns:
- item type name
-
getArgumentCount
public int getArgumentCount()
Get number of arguments for method.- Returns:
- argument count for method, or zero if not a method
-
getArgumentType
public java.lang.String getArgumentType(int index)
Get argument type as fully qualified class name.- Parameters:
index- argument number- Returns:
- argument type name
-
getParameterName
public java.lang.String getParameterName(int index)
Get method parameter name.- Parameters:
index- parameter index- Returns:
- parameter name
-
getArgumentTypes
public java.lang.String[] getArgumentTypes()
Get argument types as array of fully qualified class names.- Returns:
- array of argument types
-
getAccessFlags
public int getAccessFlags()
Get access flags.- Returns:
- flags for access type of field or method
-
setAccessFlags
public void setAccessFlags(int flags)
Set access flags.- Parameters:
flags- access flags for field or method
-
makeAccessible
public void makeAccessible(ClassFile src)
Make accessible item. Check if this field or method is accessible from another class, and if not decreases the access restrictions to make it accessible.- Parameters:
src- class file for required access
-
isStatic
public boolean isStatic()
Check if item is a static.- Returns:
trueif a static,falseif member
-
getSignature
public java.lang.String getSignature()
Get method signature.- Returns:
- encoded method signature
-
isMethod
public boolean isMethod()
Check if item is a method.- Returns:
trueif a method,falseif a field
-
isInitializer
public boolean isInitializer()
Check if item is an initializer.- Returns:
trueif an initializer,falseif a field or normal method
-
getExceptions
public java.lang.String[] getExceptions()
Get names of exceptions thrown by method.- Returns:
- array of exceptions thrown by method, or
nullif a field
-
getGenericsSignature
public java.lang.String getGenericsSignature()
Get the generics signature information for item.- Returns:
- generics signature (
nullif none)
-
isPrimitive
public static boolean isPrimitive(java.lang.String type)
Check if type is a primitive.- Parameters:
type-- Returns:
trueif a primitive,falseif not
-
getPrimitiveSignature
public static java.lang.String getPrimitiveSignature(java.lang.String type)
Get the signature for a primitive.- Parameters:
type-- Returns:
- signature for a primitive type
-
getParametersFromSignature
public static java.lang.String[] getParametersFromSignature(java.lang.String sig)
Get parameter type names from method signature.- Parameters:
sig- method signature to be decoded- Returns:
- array of argument type names
-
getTypeFromSignature
public static java.lang.String getTypeFromSignature(java.lang.String sig)
Get return type names from method signature.- Parameters:
sig- method signature to be decoded- Returns:
- return type name
-
typeFromName
public static Type typeFromName(java.lang.String name)
Create type from name.- Parameters:
name- fully qualified type name- Returns:
- corresponding type
-
findVirtualMethod
public static ClassItem findVirtualMethod(java.lang.String name, java.lang.String[] sigs) throws JiBXException
Get virtual method by fully qualified name. This splits the class name from the method name, finds the class, and then tries to find a matching method name in that class or a superclass.- Parameters:
name- fully qualified class and method namesigs- possible method signatures- Returns:
- information for the method, or
nullif not found - Throws:
JiBXException- if configuration error
-
findStaticMethod
public static ClassItem findStaticMethod(java.lang.String name, java.lang.String[] sigs) throws JiBXException
Get static method by fully qualified name. This splits the class name from the method name, finds the class, and then tries to find a matching method name in that class.- Parameters:
name- fully qualified class and method namesigs- possible method signatures- Returns:
- information for the method, or
nullif not found - Throws:
JiBXException- if configuration error
-
getSignatureVariants
public static java.lang.String[] getSignatureVariants(java.lang.String name) throws JiBXExceptionGet all variant signatures for a fully qualified class name. The returned array gives all signatures (for interfaces or classes) which instances of the class can match.- Parameters:
name- fully qualified class name- Returns:
- possible signature variations for instances of the class
- Throws:
JiBXException- if configuration error
-
isAssignable
public static boolean isAssignable(java.lang.String from, java.lang.String to) throws JiBXExceptionCheck if a value of one type can be directly assigned to another type. This is basically the equivalent of the instanceof operator, but with application to primitive types as well as object types.- Parameters:
from- fully qualified class name of initial typeto- fully qualified class name of assignment type- Returns:
trueif assignable,falseif not- Throws:
JiBXException- if configuration error
-
-