Package org.jibx.binding.classes
Class ClassItem
java.lang.Object
org.jibx.binding.classes.ClassItem
Wrapper 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
FieldsModifier and TypeFieldDescriptionprivate String[]
Argument types for method.private ClassFile
Owning class information.private FieldOrMethod
Wrapped existing item.private String
Item name.private String[]
Parameter names for method (null
if not yet found).private String
Encoded signature.private String
Fully qualified class name of item type.private static HashMap
Map for primitive type signature variants.private static HashMap
Map from method signature to array of argument types.private static HashMap
Map from method signature to return type.private static HashMap
Map from type name to BCEL type.private static final byte
Tag value for signature attribute. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassItem
findStaticMethod
(String name, String[] sigs) Get static method by fully qualified name.static ClassItem
findVirtualMethod
(String name, String[] sigs) Get virtual method by fully qualified name.int
Get access flags.int
Get number of arguments for method.getArgumentType
(int index) Get argument type as fully qualified class name.String[]
Get argument types as array of fully qualified class names.Get owning class information.String[]
Get names of exceptions thrown by method.Get fully-qualified class and method name.Get the generics signature information for item.getName()
Get item name.getParameterName
(int index) Get method parameter name.static String[]
Get parameter type names from method signature.static String
getPrimitiveSignature
(String type) Get the signature for a primitive.Get method signature.static String[]
getSignatureVariants
(String name) Get all variant signatures for a fully qualified class name.static String
Get return type names from method signature.Get item type as fully qualified class name.static boolean
isAssignable
(String from, String to) Check if a value of one type can be directly assigned to another type.boolean
Check if item is an initializer.boolean
isMethod()
Check if item is a method.static boolean
isPrimitive
(String type) Check if type is a primitive.boolean
isStatic()
Check if item is a static.void
makeAccessible
(ClassFile src) Make accessible item.void
setAccessFlags
(int flags) Set access flags.static Type
typeFromName
(String name) Create type from name.
-
Field Details
-
SIGNATURE_ATTRIBUTE_TAG
private static final byte SIGNATURE_ATTRIBUTE_TAGTag value for signature attribute.- See Also:
-
s_primitiveMap
Map for primitive type signature variants. -
s_typeMap
Map from type name to BCEL type. -
s_signatureParamsMap
Map from method signature to array of argument types. -
s_signatureTypeMap
Map from method signature to return type. -
m_classFile
Owning class information. -
m_name
Item name. -
m_signature
Encoded signature. -
m_typeName
Fully qualified class name of item type. -
m_argTypes
Argument types for method. -
m_parmNames
Parameter names for method (null
if not yet found). -
m_item
private FieldOrMethod m_itemWrapped existing item.
-
-
Constructor Details
-
ClassItem
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 Details
-
getClassFile
Get owning class information.- Returns:
- owning class information
-
getName
Get item name.- Returns:
- item name
-
getFullName
Get fully-qualified class and method name.- Returns:
- fully-qualified class and method name
-
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
Get argument type as fully qualified class name.- Parameters:
index
- argument number- Returns:
- argument type name
-
getParameterName
Get method parameter name.- Parameters:
index
- parameter index- Returns:
- parameter name
-
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
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:
true
if a static,false
if member
-
getSignature
Get method signature.- Returns:
- encoded method signature
-
isMethod
public boolean isMethod()Check if item is a method.- Returns:
true
if a method,false
if a field
-
isInitializer
public boolean isInitializer()Check if item is an initializer.- Returns:
true
if an initializer,false
if a field or normal method
-
getExceptions
Get names of exceptions thrown by method.- Returns:
- array of exceptions thrown by method, or
null
if a field
-
getGenericsSignature
Get the generics signature information for item.- Returns:
- generics signature (
null
if none)
-
isPrimitive
Check if type is a primitive.- Parameters:
type
-- Returns:
true
if a primitive,false
if not
-
getPrimitiveSignature
Get the signature for a primitive.- Parameters:
type
-- Returns:
- signature for a primitive type
-
getParametersFromSignature
Get parameter type names from method signature.- Parameters:
sig
- method signature to be decoded- Returns:
- array of argument type names
-
getTypeFromSignature
Get return type names from method signature.- Parameters:
sig
- method signature to be decoded- Returns:
- return type name
-
typeFromName
Create type from name.- Parameters:
name
- fully qualified type name- Returns:
- corresponding type
-
findVirtualMethod
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
null
if not found - Throws:
JiBXException
- if configuration error
-
findStaticMethod
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
null
if not found - Throws:
JiBXException
- if configuration error
-
getSignatureVariants
Get 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
Check 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:
true
if assignable,false
if not- Throws:
JiBXException
- if configuration error
-