ResourceExpression implements Map { protected String getELType(ResourceExpression expr) { while(expr != null) { if (expr.m_parent instanceof ResBeanExpression) { return expr.getKey(); } expr = expr.m_parent; } return null; } ResourceExpression(String key, ResourceExpression parent);  ResourceExpression(String key, ResourceExpression parent, ResourceExpressionType type);  ResourceExpression(String key, ResourceExpression parent, ResourceExpressionType type, Object... args); Object call(Object key, Object[] arguments); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override Set entrySet(); Object evaluate(); String evaluateAsString(); @Override Object get(Object expr); Object[] getArguments(); String getKey(); ResourceExpression getParent(); @Override boolean isEmpty(); @Override Set keySet(); @Override Object put(Object key, Object value); @Override void putAll(Map m); @Override Object remove(Object key); void setArguments(Object[] arguments); @Override int size(); @Override String toString(); @Override Collection values(); ResourceExpressionType getType(); void setType(ResourceExpressionType type); static final ResourceELEvaluator DEFAULT_EVALUATOR; }
@Test public void testExpression() { ResBeanExpression bean = new ResBeanExpression(); ResourceExpression expr = eval(bean, "a.b.c"); String type = expr.getELType(expr); Assert.assertEquals("a", type); }
@Test public void testGetELType() { ResourceExpression exp = new ResBeanExpression(); Assert.assertTrue(exp.getELType(exp) == null); exp = (ResourceExpression)exp.get("js"); Assert.assertTrue(exp instanceof ResTypeExpression); exp = (ResourceExpression)exp.get("local"); Assert.assertTrue(exp instanceof ResNamespaceExpression); exp = (ResourceExpression)exp.get("foo_js"); Assert.assertEquals(exp.getELType(exp), "js"); }