1 17 18 package org.apache.jasper.el; 19 20 import java.util.Iterator ; 21 22 import javax.el.ArrayELResolver; 23 import javax.el.BeanELResolver; 24 import javax.el.CompositeELResolver; 25 import javax.el.ELContext; 26 import javax.el.ELException; 27 import javax.el.ELResolver; 28 import javax.el.ListELResolver; 29 import javax.el.MapELResolver; 30 import javax.el.PropertyNotFoundException; 31 import javax.el.PropertyNotWritableException; 32 import javax.el.ResourceBundleELResolver; 33 import javax.servlet.jsp.el.VariableResolver ; 34 35 public final class ELResolverImpl extends ELResolver { 36 37 public final static ELResolver DefaultResolver = new CompositeELResolver(); 38 39 static { 40 ((CompositeELResolver) DefaultResolver).add(new MapELResolver()); 41 ((CompositeELResolver) DefaultResolver).add(new ResourceBundleELResolver()); 42 ((CompositeELResolver) DefaultResolver).add(new ListELResolver()); 43 ((CompositeELResolver) DefaultResolver).add(new ArrayELResolver()); 44 ((CompositeELResolver) DefaultResolver).add(new BeanELResolver()); 45 } 46 47 private final VariableResolver variableResolver; 48 49 public ELResolverImpl(VariableResolver variableResolver) { 50 this.variableResolver = variableResolver; 51 } 52 53 public Object getValue(ELContext context, Object base, Object property) 54 throws NullPointerException , PropertyNotFoundException, ELException { 55 if (context == null) { 56 throw new NullPointerException (); 57 } 58 59 if (base == null) { 60 context.setPropertyResolved(true); 61 if (property != null) { 62 try { 63 return this.variableResolver.resolveVariable(property 64 .toString()); 65 } catch (javax.servlet.jsp.el.ELException e) { 66 throw new ELException(e.getMessage(), e.getCause()); 67 } 68 } 69 } 70 71 if (!context.isPropertyResolved()) { 72 return DefaultResolver.getValue(context, base, property); 73 } 74 return null; 75 } 76 77 public Class <?> getType(ELContext context, Object base, Object property) 78 throws NullPointerException , PropertyNotFoundException, ELException { 79 if (context == null) { 80 throw new NullPointerException (); 81 } 82 83 if (base == null) { 84 context.setPropertyResolved(true); 85 if (property != null) { 86 try { 87 Object obj = this.variableResolver.resolveVariable(property 88 .toString()); 89 return (obj != null) ? obj.getClass() : null; 90 } catch (javax.servlet.jsp.el.ELException e) { 91 throw new ELException(e.getMessage(), e.getCause()); 92 } 93 } 94 } 95 96 if (!context.isPropertyResolved()) { 97 return DefaultResolver.getType(context, base, property); 98 } 99 return null; 100 } 101 102 public void setValue(ELContext context, Object base, Object property, 103 Object value) throws NullPointerException , 104 PropertyNotFoundException, PropertyNotWritableException, 105 ELException { 106 if (context == null) { 107 throw new NullPointerException (); 108 } 109 110 if (base == null) { 111 context.setPropertyResolved(true); 112 throw new PropertyNotWritableException( 113 "Legacy VariableResolver wrapped, not writable"); 114 } 115 116 if (!context.isPropertyResolved()) { 117 DefaultResolver.setValue(context, base, property, value); 118 } 119 } 120 121 public boolean isReadOnly(ELContext context, Object base, Object property) 122 throws NullPointerException , PropertyNotFoundException, ELException { 123 if (context == null) { 124 throw new NullPointerException (); 125 } 126 127 if (base == null) { 128 context.setPropertyResolved(true); 129 return true; 130 } 131 132 return DefaultResolver.isReadOnly(context, base, property); 133 } 134 135 public Iterator <java.beans.FeatureDescriptor > getFeatureDescriptors(ELContext context, Object base) { 136 return DefaultResolver.getFeatureDescriptors(context, base); 137 } 138 139 public Class <?> getCommonPropertyType(ELContext context, Object base) { 140 if (base == null) { 141 return String .class; 142 } 143 return DefaultResolver.getCommonPropertyType(context, base); 144 } 145 146 } 147 | Popular Tags |