BeanELResolverpublic class BeanELResolver extends ELResolver
Fields Summary |
---|
private final boolean | readOnly | private final ConcurrentCache | cache |
Constructors Summary |
---|
public BeanELResolver()
this.readOnly = false;
| public BeanELResolver(boolean readOnly)
this.readOnly = readOnly;
|
Methods Summary |
---|
public java.lang.Class | getCommonPropertyType(javax.el.ELContext context, java.lang.Object base)
if (context == null) {
throw new NullPointerException();
}
if (base != null) {
return Object.class;
}
return null;
| public java.util.Iterator | getFeatureDescriptors(javax.el.ELContext context, java.lang.Object base)
if (context == null) {
throw new NullPointerException();
}
if (base == null) {
return null;
}
try {
BeanInfo info = Introspector.getBeanInfo(base.getClass());
PropertyDescriptor[] pds = info.getPropertyDescriptors();
for (int i = 0; i < pds.length; i++) {
pds[i].setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
pds[i].setValue(TYPE, pds[i].getPropertyType());
}
return Arrays.asList((FeatureDescriptor[]) pds).iterator();
} catch (IntrospectionException e) {
//
}
return null;
| private static final java.lang.reflect.Method | getMethod(java.lang.Class type, java.lang.reflect.Method m)
if (m == null || Modifier.isPublic(type.getModifiers())) {
return m;
}
Class[] inf = type.getInterfaces();
Method mp = null;
for (int i = 0; i < inf.length; i++) {
try {
mp = inf[i].getMethod(m.getName(), (Class[]) m.getParameterTypes());
mp = getMethod(mp.getDeclaringClass(), mp);
if (mp != null) {
return mp;
}
} catch (NoSuchMethodException e) {
}
}
Class sup = type.getSuperclass();
if (sup != null) {
try {
mp = sup.getMethod(m.getName(), (Class[]) m.getParameterTypes());
mp = getMethod(mp.getDeclaringClass(), mp);
if (mp != null) {
return mp;
}
} catch (NoSuchMethodException e) {
}
}
return null;
| public java.lang.Class | getType(javax.el.ELContext context, java.lang.Object base, java.lang.Object property)
if (context == null) {
throw new NullPointerException();
}
if (base == null || property == null) {
return null;
}
context.setPropertyResolved(true);
return this.property(context, base, property).getPropertyType();
| public java.lang.Object | getValue(javax.el.ELContext context, java.lang.Object base, java.lang.Object property)
if (context == null) {
throw new NullPointerException();
}
if (base == null || property == null) {
return null;
}
context.setPropertyResolved(true);
Method m = this.property(context, base, property).read(context);
try {
return m.invoke(base, (Object[]) null);
} catch (IllegalAccessException e) {
throw new ELException(e);
} catch (InvocationTargetException e) {
throw new ELException(message(context, "propertyReadError",
new Object[] { base.getClass().getName(),
property.toString() }), e.getCause());
} catch (Exception e) {
throw new ELException(e);
}
| public boolean | isReadOnly(javax.el.ELContext context, java.lang.Object base, java.lang.Object property)
if (context == null) {
throw new NullPointerException();
}
if (base == null || property == null) {
return false;
}
context.setPropertyResolved(true);
return this.readOnly
|| this.property(context, base, property).isReadOnly();
| private final javax.el.BeanELResolver$BeanProperty | property(javax.el.ELContext ctx, java.lang.Object base, java.lang.Object property)
Class<?> type = base.getClass();
String prop = property.toString();
BeanProperties props = this.cache.get(type.getName());
if (props == null || type != props.getType()) {
props = new BeanProperties(type);
this.cache.put(type.getName(), props);
}
return props.get(ctx, prop);
| public void | setValue(javax.el.ELContext context, java.lang.Object base, java.lang.Object property, java.lang.Object value)
if (context == null) {
throw new NullPointerException();
}
if (base == null || property == null) {
return;
}
context.setPropertyResolved(true);
if (this.readOnly) {
throw new PropertyNotWritableException(message(context,
"resolverNotWriteable", new Object[] { base.getClass()
.getName() }));
}
Method m = this.property(context, base, property).write(context);
try {
m.invoke(base, value);
} catch (IllegalAccessException e) {
throw new ELException(e);
} catch (InvocationTargetException e) {
throw new ELException(message(context, "propertyWriteError",
new Object[] { base.getClass().getName(),
property.toString() }), e.getCause());
} catch (Exception e) {
throw new ELException(e);
}
|
|