FileDocCategorySizeDatePackage
When.javaAPI DocJava SE 6 API3396Tue Jun 10 00:22:30 BST 2008com.sun.org.apache.xalan.internal.xsltc.compiler

When

public final class When extends Instruction
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen
author
Morten Jorgensen

Fields Summary
private Expression
_test
private boolean
_ignore
Constructors Summary
Methods Summary
public voiddisplay(int indent)


        
	indent(indent);
	Util.println("When");
	indent(indent + IndentIncrement);
	System.out.print("test ");
	Util.println(_test.toString());
	displayContents(indent + IndentIncrement);
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.ExpressiongetTest()

	return _test;
    
public booleanignore()

	return(_ignore);
    
public voidparseContents(com.sun.org.apache.xalan.internal.xsltc.compiler.Parser parser)

	_test = parser.parseExpression(this, "test", null);

	// Ignore xsl:if when test is false (function-available() and
	// element-available())
	Object result = _test.evaluateAtCompileTime();
	if (result != null && result instanceof Boolean) {
	    _ignore = !((Boolean) result).booleanValue();
	}

	parseChildren(parser);

	// Make sure required attribute(s) have been set
	if (_test.isDummy()) {
	    reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "test");
	}
    
public voidtranslate(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen)
This method should never be called. An Otherwise object will explicitly translate the "test" expression and and contents of this element.

	final ErrorMsg msg = new ErrorMsg(ErrorMsg.STRAY_WHEN_ERR, this);
	getParser().reportError(Constants.ERROR, msg);
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypetypeCheck(com.sun.org.apache.xalan.internal.xsltc.compiler.SymbolTable stable)
Type-check this when element. The test should always be type checked, while we do not bother with the contents if we know the test fails. This is important in cases where the "test" expression tests for the support of a non-available element, and the body contains this non-available element.

	// Type-check the test expression
	if (_test.typeCheck(stable) instanceof BooleanType == false) {
	    _test = new CastExpr(_test, Type.Boolean);
	}
	// Type-check the contents (if necessary)
	if (!_ignore) {
	    typeCheckContents(stable);
	}

	return Type.Void;