FileDocCategorySizeDatePackage
ElementAvailableCall.javaAPI DocJava SE 5 API3133Fri Aug 26 14:55:34 BST 2005com.sun.org.apache.xalan.internal.xsltc.compiler

ElementAvailableCall

public final class ElementAvailableCall extends FunctionCall
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen

Fields Summary
Constructors Summary
public ElementAvailableCall(QName fname, Vector arguments)

	super(fname, arguments);
    
Methods Summary
public java.lang.ObjectevaluateAtCompileTime()
Returns an object representing the compile-time evaluation of an expression. We are only using this for function-available and element-available at this time.

	return getResult() ? Boolean.TRUE : Boolean.FALSE;
    
public booleangetResult()
Returns the result that this function will return

	try {
	    final LiteralExpr arg = (LiteralExpr) argument();
	    final String qname = arg.getValue();
	    final int index = qname.indexOf(':");
	    final String localName = (index > 0) ? 
		qname.substring(index + 1) : qname;
	    return getParser().elementSupported(arg.getNamespace(), 
					        localName);
	}
	catch (ClassCastException e) {
	    return false;
	}
    
public voidtranslate(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen)
Calls to 'element-available' are resolved at compile time since the namespaces declared in the stylsheet are not available at run time. Consequently, arguments to this function must be literals.

	final ConstantPoolGen cpg = classGen.getConstantPool();
	final boolean result = getResult();
	methodGen.getInstructionList().append(new PUSH(cpg, result));
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypetypeCheck(com.sun.org.apache.xalan.internal.xsltc.compiler.SymbolTable stable)
Force the argument to this function to be a literal string.

	if (argument() instanceof LiteralExpr) {
	    return _type = Type.Boolean;
	}
	ErrorMsg err = new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
				    "element-available", this);
	throw new TypeCheckError(err);