1 16 17 package org.apache.taglibs.standard.lang.jpath.expression; 18 19 import javax.servlet.jsp.PageContext ; 20 21 import org.apache.taglibs.standard.lang.jpath.adapter.ConversionException; 22 import org.apache.taglibs.standard.lang.jpath.adapter.Convert; 23 import org.apache.taglibs.standard.lang.jpath.adapter.IterationContext; 24 25 32 public class ScopeLimitOperator extends SimpleNode { 33 34 41 public ScopeLimitOperator(int id) { 42 super(id); 43 } 44 45 53 public ScopeLimitOperator(Parser p, int id) { 54 super(p, id); 55 } 56 57 67 public String toNormalizedString() { 68 69 String normalized = ""; 70 71 normalized = jjtGetChild(0).toNormalizedString() 72 + jjtGetChild(1).toNormalizedString(); 73 74 return normalized; 75 } 76 77 94 public Object evaluate(PageContext pageContext, IterationContext icontext) 95 throws EvaluationException { 96 97 Object result; 98 boolean properScope = false; 99 int scope; 100 101 try { 102 String scopeLimit = 103 Convert.toString(jjtGetChild(0).evaluate(pageContext, 104 icontext)); 105 106 if (scopeLimit.equals("page:")) { 108 properScope = true; 109 scope = PageContext.PAGE_SCOPE; 110 } else if (scopeLimit.equals("request:")) { 111 properScope = true; 112 scope = PageContext.REQUEST_SCOPE; 113 } else if (scopeLimit.equals("session:")) { 114 properScope = true; 115 scope = PageContext.SESSION_SCOPE; 116 } else if (scopeLimit.equals("application:")) { 117 properScope = true; 118 scope = PageContext.APPLICATION_SCOPE; 119 } else { 120 throw new EvaluationException("invalid scope operator [" 121 + scopeLimit + "]"); 122 } 123 124 if (properScope) { 125 result = 126 ((Introspectable) jjtGetChild(1)).evaluate(pageContext, 127 icontext, scope); 128 } else { 129 throw new EvaluationException("invalid scope operator [" 130 + scopeLimit + "]"); 131 } 132 } catch (ConversionException ce) { 133 throw new EvaluationException(this, ce.getMessage()); 134 } 135 136 return result; 137 } 138 } 139 | Popular Tags |