org.jibx.binding.model
Class ClassUtils

java.lang.Object
  extended by org.jibx.binding.model.ClassUtils

public class ClassUtils
extends java.lang.Object

Utilities for working with class, field, or method information.

Author:
Dennis M. Sosnoski

Field Summary
private static java.util.HashMap s_signatureMap
          Map for signatures corresponding to class names.
private static java.util.HashMap s_variantMap
          Map for primitive type signature variants.
 
Constructor Summary
ClassUtils()
           
 
Method Summary
static IClassItem findStaticMethod(java.lang.String name, java.lang.String[] sigs, ValidationContext vctx)
          Get static method by fully qualified name.
static IClassItem findVirtualMethod(java.lang.String name, java.lang.String[] sigs, ValidationContext vctx)
          Get virtual method by fully qualified name.
static java.lang.String getSignature(java.lang.String type)
          Gets the signature string corresponding to a type.
static java.lang.String[] getSignatureVariants(java.lang.String name, ValidationContext vctx)
          Get all variant signatures for a fully qualified class name.
static boolean isAssignable(java.lang.String from, java.lang.String to, ValidationContext vctx)
          Check if a value of one type can be directly assigned to another type.
static boolean isPrimitive(java.lang.String type)
          Check if type name is a primitive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_variantMap

private static java.util.HashMap s_variantMap
Map for primitive type signature variants.


s_signatureMap

private static java.util.HashMap s_signatureMap
Map for signatures corresponding to class names.

Constructor Detail

ClassUtils

public ClassUtils()
Method Detail

isPrimitive

public static boolean isPrimitive(java.lang.String type)
Check if type name is a primitive.

Parameters:
type -
Returns:
true if a primitive, false if not

findVirtualMethod

public static IClassItem findVirtualMethod(java.lang.String name,
                                           java.lang.String[] sigs,
                                           ValidationContext vctx)
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 name
sigs - possible method signatures
vctx - validation context (used for class lookup)
Returns:
information for the method, or null if not found

findStaticMethod

public static IClassItem findStaticMethod(java.lang.String name,
                                          java.lang.String[] sigs,
                                          ValidationContext vctx)
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 name
sigs - possible method signatures
vctx - validation context (used for class lookup)
Returns:
information for the method, or null if not found

getSignatureVariants

public static java.lang.String[] getSignatureVariants(java.lang.String name,
                                                      ValidationContext vctx)
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
vctx - validation context (used for class lookup)
Returns:
possible signature variations for instances of the class

getSignature

public static java.lang.String getSignature(java.lang.String type)
Gets the signature string corresponding to a type. The base for the type may be a primitive or class name, and may include trailing array brackets.

Parameters:
type - type name
Returns:
signature string for type

isAssignable

public static boolean isAssignable(java.lang.String from,
                                   java.lang.String to,
                                   ValidationContext vctx)
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 type
to - fully qualified class name of assignment type
vctx - validation context (used for class lookup)
Returns:
true if assignable, false if not


Project Web Site