1 16 17 package org.apache.taglibs.standard.lang.jpath.expression; 18 19 import java.util.ArrayList ; 20 import java.util.Collection ; 21 22 import javax.servlet.jsp.PageContext ; 23 24 import org.apache.taglibs.standard.lang.jpath.adapter.IterationContext; 25 26 33 public class ListLiteral extends SimpleNode { 34 35 42 public ListLiteral(int id) { 43 super(id); 44 } 45 46 54 public ListLiteral(Parser p, int id) { 55 super(p, id); 56 } 57 58 68 public String toNormalizedString() { 69 70 boolean first = true; 71 String normalized; 72 73 normalized = "{"; 74 75 if (children != null) { 76 for (int i = 0; i < children.length; ++i) { 77 if (!first) { 78 normalized = normalized + ","; 79 } 80 81 first = false; 82 83 SimpleNode n = (SimpleNode) children[i]; 84 85 if (n != null) { 86 normalized = normalized + n.toNormalizedString(); 87 } 88 } 89 } 90 91 normalized = normalized + "}"; 92 93 return normalized; 94 } 95 96 113 public Object evaluate(PageContext pageContext, IterationContext icontext) 114 throws EvaluationException { 115 116 Collection c = new ArrayList (); 117 118 for (int i = 0; i < jjtGetNumChildren(); i++) { 119 c.add(jjtGetChild(i).evaluate(pageContext, icontext)); 120 } 121 122 return c; 123 } 124 } 125 | Popular Tags |