FileDocCategorySizeDatePackage
IdKeyPattern.javaAPI DocJava SE 6 API3946Tue Jun 10 00:22:28 BST 2008com.sun.org.apache.xalan.internal.xsltc.compiler

IdKeyPattern

public abstract class IdKeyPattern extends LocationPathPattern
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen

Fields Summary
protected RelativePathPattern
_left
private String
_index
private String
_value
Constructors Summary
public IdKeyPattern(String index, String value)


         
	_index = index;
	_value = value;
    
Methods Summary
public java.lang.StringgetIndexName()

	return(_index);
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.StepPatterngetKernelPattern()

	return(null);
    
public booleanisWildcard()

	return false;
    
public voidreduceKernelPattern()

 
public voidsetLeft(com.sun.org.apache.xalan.internal.xsltc.compiler.RelativePathPattern left)

	_left = left;
    
public java.lang.StringtoString()

	return "id/keyPattern(" + _index + ", " + _value + ')";
    
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 is called when the constructor is compiled in Stylesheet.compileConstructor() and not as the syntax tree is traversed.


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

	// Returns the KeyIndex object of a given name
	final int getKeyIndex = cpg.addMethodref(TRANSLET_CLASS,
						 "getKeyIndex",
						 "(Ljava/lang/String;)"+
						 KEY_INDEX_SIG);
	
	// Initialises a KeyIndex to return nodes with specific values
	final int lookupId = cpg.addMethodref(KEY_INDEX_CLASS,
					      "containsID",
					      "(ILjava/lang/Object;)I");
	final int lookupKey = cpg.addMethodref(KEY_INDEX_CLASS,
					       "containsKey",
					       "(ILjava/lang/Object;)I");
	final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF,
							   "getNodeIdent",
							   "(I)"+NODE_SIG);				       

	// Call getKeyIndex in AbstractTranslet with the name of the key
	// to get the index for this key (which is also a node iterator).
	il.append(classGen.loadTranslet());
	il.append(new PUSH(cpg,_index));
	il.append(new INVOKEVIRTUAL(getKeyIndex));
	
	// Now use the value in the second argument to determine what nodes
	// the iterator should return.
	il.append(SWAP);
	il.append(new PUSH(cpg,_value));
	if (this instanceof IdPattern)
	{
	    il.append(new INVOKEVIRTUAL(lookupId));
	}
	else
	{
	    il.append(new INVOKEVIRTUAL(lookupKey));
	}

	_trueList.add(il.append(new IFNE(null)));
	_falseList.add(il.append(new GOTO(null)));
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypetypeCheck(com.sun.org.apache.xalan.internal.xsltc.compiler.SymbolTable stable)

	return Type.NodeSet;