1 17 18 package org.apache.jasper.compiler; 19 20 import java.util.*; 21 import javax.servlet.jsp.tagext.FunctionInfo ; 22 import org.apache.jasper.JasperException; 23 24 32 33 abstract class ELNode { 34 35 abstract public void accept(Visitor v) throws JasperException; 36 37 40 41 42 45 public static class Root extends ELNode { 46 47 private ELNode.Nodes expr; 48 private char type; 49 50 Root(ELNode.Nodes expr, char type) { 51 this.expr = expr; 52 this.type = type; 53 } 54 55 public void accept(Visitor v) throws JasperException { 56 v.visit(this); 57 } 58 59 public ELNode.Nodes getExpression() { 60 return expr; 61 } 62 63 public char getType() { 64 return type; 65 } 66 } 67 68 71 public static class Text extends ELNode { 72 73 private String text; 74 75 Text(String text) { 76 this.text = text; 77 } 78 79 public void accept(Visitor v) throws JasperException { 80 v.visit(this); 81 } 82 83 public String getText() { 84 return text; 85 } 86 } 87 88 92 public static class ELText extends ELNode { 93 94 private String text; 95 96 ELText(String text) { 97 this.text = text; 98 } 99 100 public void accept(Visitor v) throws JasperException { 101 v.visit(this); 102 } 103 104 public String getText() { 105 return text; 106 } 107 } 108 109 114 public static class Function extends ELNode { 115 116 private String prefix; 117 private String name; 118 private String uri; 119 private FunctionInfo functionInfo; 120 private String methodName; 121 private String [] parameters; 122 123 Function(String prefix, String name) { 124 this.prefix = prefix; 125 this.name = name; 126 } 127 128 public void accept(Visitor v) throws JasperException { 129 v.visit(this); 130 } 131 132 public String getPrefix() { 133 return prefix; 134 } 135 136 public String getName() { 137 return name; 138 } 139 140 public void setUri(String uri) { 141 this.uri = uri; 142 } 143 144 public String getUri() { 145 return uri; 146 } 147 148 public void setFunctionInfo(FunctionInfo f) { 149 this.functionInfo = f; 150 } 151 152 public FunctionInfo getFunctionInfo() { 153 return functionInfo; 154 } 155 156 public void setMethodName(String methodName) { 157 this.methodName = methodName; 158 } 159 160 public String getMethodName() { 161 return methodName; 162 } 163 164 public void setParameters(String [] parameters) { 165 this.parameters = parameters; 166 } 167 168 public String [] getParameters() { 169 return parameters; 170 } 171 } 172 173 176 public static class Nodes { 177 178 181 String mapName = null; private List<ELNode> list; 183 184 public Nodes() { 185 list = new ArrayList<ELNode>(); 186 } 187 188 public void add(ELNode en) { 189 list.add(en); 190 } 191 192 196 public void visit(Visitor v) throws JasperException { 197 Iterator<ELNode> iter = list.iterator(); 198 while (iter.hasNext()) { 199 ELNode n = iter.next(); 200 n.accept(v); 201 } 202 } 203 204 public Iterator<ELNode> iterator() { 205 return list.iterator(); 206 } 207 208 public boolean isEmpty() { 209 return list.size() == 0; 210 } 211 212 215 public boolean containsEL() { 216 Iterator<ELNode> iter = list.iterator(); 217 while (iter.hasNext()) { 218 ELNode n = iter.next(); 219 if (n instanceof Root) { 220 return true; 221 } 222 } 223 return false; 224 } 225 226 public void setMapName(String name) { 227 this.mapName = name; 228 } 229 230 public String getMapName() { 231 return mapName; 232 } 233 234 } 235 236 239 public static class Visitor { 240 241 public void visit(Root n) throws JasperException { 242 n.getExpression().visit(this); 243 } 244 245 public void visit(Function n) throws JasperException { 246 } 247 248 public void visit(Text n) throws JasperException { 249 } 250 251 public void visit(ELText n) throws JasperException { 252 } 253 } 254 } 255 256 | Popular Tags |