FileDocCategorySizeDatePackage
ObjectType.javaAPI DocJava SE 6 API5599Tue Jun 10 00:22:32 BST 2008com.sun.org.apache.xalan.internal.xsltc.compiler.util

ObjectType

public final class ObjectType extends Type
author
Todd Miller
author
Santiago Pericas-Geertsen

Fields Summary
private String
_javaClassName
private Class
_clazz
Constructors Summary
protected ObjectType(String javaClassName)
Used to represent a Java Class type such is required to support non-static java functions.

param
javaClassName name of the class such as 'com.foo.Processor'


                                   
       
	_javaClassName = javaClassName;

	try {
          _clazz = ObjectFactory.findProviderClass(
            javaClassName, ObjectFactory.findClassLoader(), true);
	}
	catch (ClassNotFoundException e) {
	  _clazz = null;
	}
    
protected ObjectType(Class clazz)

        _clazz = clazz;
        _javaClassName = clazz.getName();	
    
Methods Summary
public com.sun.org.apache.bcel.internal.generic.InstructionLOAD(int slot)

	return new ALOAD(slot);
    
public com.sun.org.apache.bcel.internal.generic.InstructionSTORE(int slot)

	return new ASTORE(slot);
    
public booleanequals(java.lang.Object obj)

        return (obj instanceof ObjectType);
    
public java.lang.ClassgetJavaClass()

        return _clazz;	
    
public java.lang.StringgetJavaClassName()

	return _javaClassName;
    
public inthashCode()
Must return the same value for all ObjectType instances. This is needed in CastExpr to ensure the mapping table is used correctly.

        return java.lang.Object.class.hashCode();
    
public booleanidenticalTo(com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type other)

	return this == other;
    
public com.sun.org.apache.bcel.internal.generic.TypetoJCType()

	return Util.getJCRefType(toSignature());
    
public java.lang.StringtoSignature()

	final StringBuffer result = new StringBuffer("L");
	result.append(_javaClassName.replace('.", '/")).append(';");
	return result.toString();
    
public java.lang.StringtoString()

	return _javaClassName;
    
public voidtranslateFrom(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen, java.lang.Class clazz)
Translates an external Java type into an Object type

	methodGen.getInstructionList().append(NOP);
    
public voidtranslateTo(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type type)
Translates a void into an object of internal type type. This translation is needed when calling external functions that return void.

see
com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo

	if (type == Type.String) {
	    translateTo(classGen, methodGen, (StringType) type);
	}
	else {
	    ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
					toString(), type.toString());
	    classGen.getParser().reportError(Constants.FATAL, err);
	}
    
public voidtranslateTo(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType type)
Expects an integer on the stack and pushes its string value by calling Integer.toString(int i).

see
com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo

	final ConstantPoolGen cpg = classGen.getConstantPool();
	final InstructionList il = methodGen.getInstructionList();

	il.append(DUP);
	final BranchHandle ifNull = il.append(new IFNULL(null));
	il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
						    "toString",
						    "()" + STRING_SIG)));
	final BranchHandle gotobh = il.append(new GOTO(null));
	ifNull.setTarget(il.append(POP));
	il.append(new PUSH(cpg, ""));
	gotobh.setTarget(il.append(NOP));
    
public voidtranslateTo(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen, java.lang.Class clazz)
Translates an object of this type to the external (Java) type denoted by clazz. This method is used to translate parameters when external functions are called.

        if (clazz.isAssignableFrom(_clazz))
	    methodGen.getInstructionList().append(NOP);
	else {
	    ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
			       toString(), clazz.getClass().toString());
	    classGen.getParser().reportError(Constants.FATAL, err);	  	
	}