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

StringType

public class StringType extends Type
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen

Fields Summary
Constructors Summary
protected StringType()

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 java.lang.StringgetClassName()
Returns the class name of an internal type's external representation.

	return(STRING_CLASS);
    
public booleanidenticalTo(com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type other)

	return this == other;
    
public booleanisSimple()

	return true;
    
public com.sun.org.apache.bcel.internal.generic.TypetoJCType()

	return com.sun.org.apache.bcel.internal.generic.Type.STRING;
    
public java.lang.StringtoSignature()

	return "Ljava/lang/String;";
    
public java.lang.StringtoString()

	return "string";
    
public voidtranslateBox(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen)
Translates an object of this type to its boxed representation.

	translateTo(classGen, methodGen, Type.Reference);
    
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 (primitive) Java type into a string.

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

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

	if (clazz.getName().equals("java.lang.String")) {
	    // same internal representation, convert null to ""
	    il.append(DUP);
	    final BranchHandle ifNonNull = il.append(new IFNONNULL(null));
	    il.append(POP);
	    il.append(new PUSH(cpg, ""));
	    ifNonNull.setTarget(il.append(NOP));
	}
	else {
	    ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
					toString(), clazz.getName());
	    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.ReferenceType type)
Expects a string on the stack and pushes a boxed string. Strings are already boxed so the translation is just a NOP.

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

	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, java.lang.Class clazz)
Translates a internal string into an external (Java) string.

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

        // Is String <: clazz? I.e. clazz in { String, Object }
        if (clazz.isAssignableFrom(java.lang.String.class)) {
	    methodGen.getInstructionList().append(NOP);
	}
	else {
	    ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
					toString(), clazz.getName());
	    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.Type type)
Translates a string into an object of internal type type. The translation to int is undefined since strings are always converted to reals in arithmetic expressions.

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

	if (type == Type.Boolean) {
	    translateTo(classGen, methodGen, (BooleanType) type);
	}
	else if (type == Type.Real) {
	    translateTo(classGen, methodGen, (RealType) type);
	}
	else if (type == Type.Reference) {
	    translateTo(classGen, methodGen, (ReferenceType) type);
	}
        else if (type == Type.ObjectString) {
            // NOP -> same representation
        }
	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.BooleanType type)
Translates a string into a synthesized boolean.

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

	final InstructionList il = methodGen.getInstructionList();
	FlowList falsel = translateToDesynthesized(classGen, methodGen, type);
	il.append(ICONST_1);
	final BranchHandle truec = il.append(new GOTO(null));
	falsel.backPatch(il.append(ICONST_0));
	truec.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, com.sun.org.apache.xalan.internal.xsltc.compiler.util.RealType type)
Translates a string into a real by calling stringToReal() from the basis library.

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

	final ConstantPoolGen cpg = classGen.getConstantPool();
	final InstructionList il = methodGen.getInstructionList();
	il.append(new INVOKESTATIC(cpg.addMethodref(BASIS_LIBRARY_CLASS,
						    STRING_TO_REAL,
						    STRING_TO_REAL_SIG)));
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.FlowListtranslateToDesynthesized(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.BooleanType type)
Translates a string into a non-synthesized boolean. It does not push a 0 or a 1 but instead returns branchhandle list to be appended to the false list.

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

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

	il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS,
						     "length", "()I")));
	return new FlowList(il.append(new IFEQ(null)));
    
public voidtranslateUnBox(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen)
Translates an object of this type to its unboxed representation.

	methodGen.getInstructionList().append(NOP);