1 19 20 package org.netbeans.modules.web.jsps.parserapi; 21 22 import java.util.*; 23 import javax.servlet.jsp.tagext.FunctionInfo ; 24 import javax.servlet.jsp.JspException ; 25 26 32 33 public abstract class ELNode { 34 35 public abstract void accept(Visitor v) throws JspException ; 36 37 40 41 42 45 public static class Root extends ELNode { 46 47 private ELNode.Nodes expr; 48 49 public Root(ELNode.Nodes expr) { 50 this.expr = expr; 51 } 52 53 public void accept(Visitor v) throws JspException { 54 v.visit(this); 55 } 56 57 public ELNode.Nodes getExpression() { 58 return expr; 59 } 60 } 61 62 65 public static class Text extends ELNode { 66 67 private String text; 68 69 public Text(String text) { 70 this.text = text; 71 } 72 73 public void accept(Visitor v) throws JspException { 74 v.visit(this); 75 } 76 77 public String getText() { 78 return text; 79 } 80 } 81 82 85 public static class ELText extends ELNode { 86 87 private String text; 88 89 public ELText(String text) { 90 this.text = text; 91 } 92 93 public void accept(Visitor v) throws JspException { 94 v.visit(this); 95 } 96 97 public String getText() { 98 return text; 99 } 100 } 101 102 106 public static class Function extends ELNode { 107 108 private String prefix; 109 private String name; 110 private String uri; 111 private FunctionInfo functionInfo; 112 private String methodName; 113 private String [] parameters; 114 115 Function(String prefix, String name) { 116 this.prefix = prefix; 117 this.name = name; 118 } 119 120 public void accept(Visitor v) throws JspException { 121 v.visit(this); 122 } 123 124 public String getPrefix() { 125 return prefix; 126 } 127 128 public String getName() { 129 return name; 130 } 131 132 public void setUri(String uri) { 133 this.uri = uri; 134 } 135 136 public String getUri() { 137 return uri; 138 } 139 140 public void setFunctionInfo(FunctionInfo f) { 141 this.functionInfo = f; 142 } 143 144 public FunctionInfo getFunctionInfo() { 145 return functionInfo; 146 } 147 148 public void setMethodName(String methodName) { 149 this.methodName = methodName; 150 } 151 152 public String getMethodName() { 153 return methodName; 154 } 155 156 public void setParameters(String [] parameters) { 157 this.parameters = parameters; 158 } 159 160 public String [] getParameters() { 161 return parameters; 162 } 163 } 164 165 168 public static class Nodes { 169 170 173 String mapName = null; 174 private List<ELNode> list; 175 176 public Nodes() { 177 list = new ArrayList<ELNode>(); 178 } 179 180 public void add(ELNode en) { 181 list.add(en); 182 } 183 184 188 public void visit(Visitor v) throws JspException { 189 for (ELNode n: list) { 190 n.accept(v); 191 } 192 } 193 194 public Iterator<ELNode> iterator() { 195 return list.iterator(); 196 } 197 198 public boolean isEmpty() { 199 return list.size() == 0; 200 } 201 202 205 public boolean containsEL() { 206 Iterator<ELNode> iter = list.iterator(); 207 while (iter.hasNext()) { 208 ELNode n = iter.next(); 209 if (n instanceof Root) { 210 return true; 211 } 212 } 213 return false; 214 } 215 216 public void setMapName(String name) { 217 this.mapName = name; 218 } 219 220 public String getMapName() { 221 return mapName; 222 } 223 } 224 225 public static class Visitor { 226 227 public void visit(Root n) throws JspException { 228 n.getExpression().visit(this); 229 } 230 231 public void visit(Function n) throws JspException { 232 } 233 234 public void visit(Text n) throws JspException { 235 } 236 237 public void visit(ELText n) throws JspException { 238 } 239 } 240 } 241 242 | Popular Tags |