1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.compiler; 21 22 import java.util.StringTokenizer ; 23 import java.util.Vector ; 24 25 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; 26 import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; 27 import com.sun.org.apache.bcel.internal.generic.InstructionList; 28 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; 29 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; 30 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; 31 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; 32 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; 33 34 39 final class UseAttributeSets extends Instruction { 40 41 private final static String ATTR_SET_NOT_FOUND = 43 ""; 44 45 private final Vector _sets = new Vector (2); 47 48 51 public UseAttributeSets(String setNames, Parser parser) { 52 setParser(parser); 53 addAttributeSets(setNames); 54 } 55 56 61 public void addAttributeSets(String setNames) { 62 if ((setNames != null) && (!setNames.equals(Constants.EMPTYSTRING))) { 63 final StringTokenizer tokens = new StringTokenizer (setNames); 64 while (tokens.hasMoreTokens()) { 65 final QName qname = 66 getParser().getQNameIgnoreDefaultNs(tokens.nextToken()); 67 _sets.add(qname); 68 } 69 } 70 } 71 72 75 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 76 return Type.Void; 77 } 78 79 82 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 83 84 final ConstantPoolGen cpg = classGen.getConstantPool(); 85 final InstructionList il = methodGen.getInstructionList(); 86 final SymbolTable symbolTable = getParser().getSymbolTable(); 87 88 for (int i=0; i<_sets.size(); i++) { 90 final QName name = (QName)_sets.elementAt(i); 92 final AttributeSet attrs = symbolTable.lookupAttributeSet(name); 94 if (attrs != null) { 96 final String methodName = attrs.getMethodName(); 97 il.append(classGen.loadTranslet()); 98 il.append(methodGen.loadDOM()); 99 il.append(methodGen.loadIterator()); 100 il.append(methodGen.loadHandler()); 101 final int method = cpg.addMethodref(classGen.getClassName(), 102 methodName, ATTR_SET_SIG); 103 il.append(new INVOKESPECIAL(method)); 104 } 105 else { 107 final Parser parser = getParser(); 108 final String atrs = name.toString(); 109 reportError(this, parser, ErrorMsg.ATTRIBSET_UNDEF_ERR, atrs); 110 } 111 } 112 } 113 } 114 | Popular Tags |