FileDocCategorySizeDatePackage
FastClass.javaAPI DocHibernate 3.2.53977Fri Dec 15 09:30:56 GMT 2006org.hibernate.bytecode.javassist

FastClass

public class FastClass extends Object implements Serializable
author
Muga Nishizawa

Fields Summary
private static final Class[]
EMPTY_CLASS_ARRAY
private Class
type
Constructors Summary
private FastClass()


	  
	
private FastClass(Class type)

		this.type = type;
	
Methods Summary
public static org.hibernate.bytecode.javassist.FastClasscreate(java.lang.Class type)

		FastClass fc = new FastClass( type );
		return fc;
	
public booleanequals(java.lang.Object o)

		if ( !( o instanceof FastClass ) ) {
			return false;
		}
		return this.type.equals( ( ( FastClass ) o ).type );
	
public intgetIndex(java.lang.String name, java.lang.Class[] parameterTypes)

		Method[] methods = this.type.getMethods();
		boolean eq = true;
		for ( int i = 0; i < methods.length; ++i ) {
			if ( !Modifier.isPublic( methods[i].getModifiers() ) ) {
				continue;
			}
			if ( !methods[i].getName().equals( name ) ) {
				continue;
			}
			Class[] params = methods[i].getParameterTypes();
			if ( params.length != parameterTypes.length ) {
				continue;
			}
			eq = true;
			for ( int j = 0; j < params.length; ++j ) {
				if ( !params[j].equals( parameterTypes[j] ) ) {
					eq = false;
					break;
				}
			}
			if ( eq ) {
				return i;
			}
		}
		return -1;
	
public intgetIndex(java.lang.Class[] parameterTypes)

		Constructor[] conss = this.type.getConstructors();
		boolean eq = true;
		for ( int i = 0; i < conss.length; ++i ) {
			if ( !Modifier.isPublic( conss[i].getModifiers() ) ) {
				continue;
			}
			Class[] params = conss[i].getParameterTypes();
			if ( params.length != parameterTypes.length ) {
				continue;
			}
			eq = true;
			for ( int j = 0; j < params.length; ++j ) {
				if ( !params[j].equals( parameterTypes[j] ) ) {
					eq = false;
					break;
				}
			}
			if ( eq ) {
				return i;
			}
		}
		return -1;
	
public java.lang.ClassgetJavaClass()

		return this.type;
	
public intgetMaxIndex()

		Method[] methods = this.type.getMethods();
		int count = 0;
		for ( int i = 0; i < methods.length; ++i ) {
			if ( Modifier.isPublic( methods[i].getModifiers() ) ) {
				count++;
			}
		}
		return count;
	
public java.lang.StringgetName()

		return this.type.getName();
	
public inthashCode()

		return this.type.hashCode();
	
public java.lang.Objectinvoke(java.lang.String name, java.lang.Class[] parameterTypes, java.lang.Object obj, java.lang.Object[] args)

		return this.invoke( this.getIndex( name, parameterTypes ), obj, args );
	
public java.lang.Objectinvoke(int index, java.lang.Object obj, java.lang.Object[] args)

		Method[] methods = this.type.getMethods();
		try {
			return methods[index].invoke( obj, args );
		}
		catch ( ArrayIndexOutOfBoundsException e ) {
			throw new IllegalArgumentException(
					"Cannot find matching method/constructor"
			);
		}
		catch ( IllegalAccessException e ) {
			throw new InvocationTargetException( e );
		}
	
public java.lang.ObjectnewInstance()

		return this.newInstance( this.getIndex( EMPTY_CLASS_ARRAY ), null );
	
public java.lang.ObjectnewInstance(java.lang.Class[] parameterTypes, java.lang.Object[] args)

		return this.newInstance( this.getIndex( parameterTypes ), args );
	
public java.lang.ObjectnewInstance(int index, java.lang.Object[] args)

		Constructor[] conss = this.type.getConstructors();
		try {
			return conss[index].newInstance( args );
		}
		catch ( ArrayIndexOutOfBoundsException e ) {
			throw new IllegalArgumentException( "Cannot find matching method/constructor" );
		}
		catch ( InstantiationException e ) {
			throw new InvocationTargetException( e );
		}
		catch ( IllegalAccessException e ) {
			throw new InvocationTargetException( e );
		}
	
public java.lang.StringtoString()

		return this.type.toString();