private BeanProperty getBeanProperty(ELContext context, Object base, Object prop) { String property = prop.toString(); Class baseClass = base.getClass(); BeanProperties bps = properties.get(baseClass); if (bps == null) { bps = new BeanProperties(baseClass); properties.putIfAbsent(baseClass, bps); } BeanProperty bp = bps.getBeanProperty(property); if (bp == null) { throw new PropertyNotFoundException( ELUtil.getExceptionMessageString(context, "propertyNotFound", new Object[] { baseClass.getName(), property})); } return bp; }
props = new BeanProperties(cl); setProps(cl, props); BeanProperty prop = props.getBeanProperty(fieldName);
props = new BeanProperties(cl); setProps(cl, props); BeanProperty prop = props.getBeanProperty(fieldName);
props = new BeanProperties(cl); setProps(cl, props); BeanProperty prop = props.getBeanProperty(fieldName);
/** * Lookup BeanProperty for the given (base, property) pair. * * @param base * The bean to analyze. * @param property * The name of the property to analyze. Will be coerced to a String. * @return The BeanProperty representing (base, property). * @throws PropertyNotFoundException * if no BeanProperty can be found. */ private final BeanProperty toBeanProperty(Object base, Object property) { BeanProperties beanProperties = cache.get(base.getClass()); if (beanProperties == null) { BeanProperties newBeanProperties = new BeanProperties(base.getClass()); beanProperties = cache.putIfAbsent(base.getClass(), newBeanProperties); if (beanProperties == null) { // put succeeded, use new value beanProperties = newBeanProperties; } } BeanProperty beanProperty = property == null ? null : beanProperties.getBeanProperty(property.toString()); if (beanProperty == null) { throw new PropertyNotFoundException("Could not find property " + property + " in " + base.getClass()); } return beanProperty; }
/** * Lookup BeanProperty for the given (base, property) pair. * * @param base * The bean to analyze. * @param property * The name of the property to analyze. Will be coerced to a String. * @return The BeanProperty representing (base, property). * @throws PropertyNotFoundException * if no BeanProperty can be found. */ private final BeanProperty toBeanProperty(Object base, Object property) { BeanProperties beanProperties = cache.get(base.getClass()); if (beanProperties == null) { BeanProperties newBeanProperties = new BeanProperties(base.getClass()); beanProperties = cache.putIfAbsent(base.getClass(), newBeanProperties); if (beanProperties == null) { // put succeeded, use new value beanProperties = newBeanProperties; } } BeanProperty beanProperty = property == null ? null : beanProperties.getBeanProperty(property.toString()); if (beanProperty == null) { throw new PropertyNotFoundException("Could not find property " + property + " in " + base.getClass()); } return beanProperty; }
@Override public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) { if (base == null) return null; Class<?> cl = base.getClass(); BeanProperties props = getProps(cl); if (props == null) { if (cl.isArray() || Collection.class.isAssignableFrom(cl) || Map.class.isAssignableFrom(cl)) { return null; } props = new BeanProperties(cl); setProps(cl, props); } ArrayList<FeatureDescriptor> descriptors = new ArrayList<FeatureDescriptor>(); for (BeanProperty prop : props.getProperties()) { descriptors.add(prop.getDescriptor()); } return descriptors.iterator(); }
/** * Lookup BeanProperty for the given (base, property) pair. * * @param base * The bean to analyze. * @param property * The name of the property to analyze. Will be coerced to a String. * @return The BeanProperty representing (base, property). * @throws PropertyNotFoundException * if no BeanProperty can be found. */ private final BeanProperty toBeanProperty(Object base, Object property) { BeanProperties beanProperties = cache.get(base.getClass()); if (beanProperties == null) { BeanProperties newBeanProperties = new BeanProperties(base.getClass()); beanProperties = cache.putIfAbsent(base.getClass(), newBeanProperties); if (beanProperties == null) { // put succeeded, use new value beanProperties = newBeanProperties; } } BeanProperty beanProperty = property == null ? null : beanProperties.getBeanProperty(property.toString()); if (beanProperty == null) { throw new PropertyNotFoundException("Could not find property " + property + " in " + base.getClass()); } return beanProperty; }
private BeanProperties getProp(ELContext context, Object base, Object property) { if (base == null || ! (property instanceof String)) return null; String fieldName = (String) property; if (fieldName.length() == 0) return null; Class<?> cl = base.getClass(); BeanProperties props = getProps(cl); if (props == null) { if (cl.isArray() || Collection.class.isAssignableFrom(cl) || Map.class.isAssignableFrom(cl)) { return null; } props = new BeanProperties(cl); setProps(cl, props); } return props; }
private BeanProperty getBeanProperty(ELContext context, Object base, Object prop) { String property = prop.toString(); Class baseClass = base.getClass(); BeanProperties bps = properties.get(baseClass); if (bps == null) { bps = new BeanProperties(baseClass); properties.put(baseClass, bps); } BeanProperty bp = bps.getBeanProperty(property); if (bp == null) { throw new PropertyNotFoundException( ELUtil.getExceptionMessageString(context, "propertyNotFound", new Object[] { baseClass.getName(), property})); } return bp; } }
private void populateFromInterfaces(Class<?> aClass) throws IntrospectionException { Class<?> interfaces[] = aClass.getInterfaces(); if (interfaces.length > 0) { for (Class<?> ifs : interfaces) { BeanInfo info = Introspector.getBeanInfo(ifs); PropertyDescriptor[] pds = info.getPropertyDescriptors(); for (PropertyDescriptor pd : pds) { if (!this.properties.containsKey(pd.getName())) { this.properties.put(pd.getName(), new BeanProperty( this.type, pd)); } } populateFromInterfaces(ifs); } } Class<?> superclass = aClass.getSuperclass(); if (superclass != null) { populateFromInterfaces(superclass); } }
private BeanProperty getBeanProperty(ELContext context, Object base, Object prop) { String property = prop.toString(); Class baseClass = base.getClass(); BeanProperties bps = properties.get(baseClass); if (bps == null) { bps = new BeanProperties(baseClass); properties.put(baseClass, bps); } BeanProperty bp = bps.getBeanProperty(property); if (bp == null) { throw new PropertyNotFoundException( ELUtil.getExceptionMessageString(context, "propertyNotFound", new Object[] { baseClass.getName(), property})); } return bp; } }
private void populateFromInterfaces(Class<?> aClass) throws IntrospectionException { Class<?> interfaces[] = aClass.getInterfaces(); if (interfaces.length > 0) { for (Class<?> ifs : interfaces) { BeanInfo info = Introspector.getBeanInfo(ifs); PropertyDescriptor[] pds = info.getPropertyDescriptors(); for (PropertyDescriptor pd : pds) { if (!this.properties.containsKey(pd.getName())) { this.properties.put(pd.getName(), new BeanProperty( this.type, pd)); } } populateFromInterfaces(ifs); } } Class<?> superclass = aClass.getSuperclass(); if (superclass != null) { populateFromInterfaces(superclass); } }
private BeanProperty getBeanProperty(ELContext context, Object base, Object prop) { String property = prop.toString(); Class baseClass = base.getClass(); BeanProperties bps = properties.get(baseClass); if (bps == null) { bps = new BeanProperties(baseClass); properties.put(baseClass, bps); } BeanProperty bp = bps.getBeanProperty(property); if (bp == null) { throw new PropertyNotFoundException( ELUtil.getExceptionMessageString(context, "propertyNotFound", new Object[] { baseClass.getName(), property})); } return bp; }
private BeanProperty getBeanProperty(ELContext context, Object base, Object prop) { String property = prop.toString(); Class baseClass = base.getClass(); BeanProperties bps = properties.get(baseClass); if (bps == null) { bps = new BeanProperties(baseClass); properties.putIfAbsent(baseClass, bps); } BeanProperty bp = bps.getBeanProperty(property); if (bp == null) { throw new PropertyNotFoundException( ELUtil.getExceptionMessageString(context, "propertyNotFound", new Object[] { baseClass.getName(), property})); } return bp; }
private BeanProperty getBeanProperty(ELContext context, Object base, Object prop) { String property = prop.toString(); Class baseClass = base.getClass(); BeanProperties bps = properties.get(baseClass); if (bps == null) { bps = new BeanProperties(baseClass); properties.putIfAbsent(baseClass, bps); } BeanProperty bp = bps.getBeanProperty(property); if (bp == null) { throw new PropertyNotFoundException( ELUtil.getExceptionMessageString(context, "propertyNotFound", new Object[] { baseClass.getName(), property})); } return bp; }
private BeanProperty getBeanProperty(ELContext context, Object base, Object prop) { String property = prop.toString(); Class baseClass = base.getClass(); BeanProperties bps = properties.get(baseClass); if (bps == null) { bps = new BeanProperties(baseClass); properties.put(baseClass, bps); } BeanProperty bp = bps.getBeanProperty(property); if (bp == null) { throw new PropertyNotFoundException( ELUtil.getExceptionMessageString(context, "propertyNotFound", new Object[] { baseClass.getName(), property})); } return bp; } }
private BeanProperty getBeanProperty(ELContext context, Object base, Object prop) { String property = prop.toString(); Class baseClass = base.getClass(); BeanProperties bps = properties.get(baseClass); if (bps == null) { bps = new BeanProperties(baseClass); properties.put(baseClass, bps); } BeanProperty bp = bps.getBeanProperty(property); if (bp == null) { throw new PropertyNotFoundException( ELUtil.getExceptionMessageString(context, "propertyNotFound", new Object[] { baseClass.getName(), property})); } return bp; } }
@Override public boolean isReadOnly(ELContext env, Object base, Object property) { if (base == null) return false; BeanProperties props = getProp(env, base, property); if (props != null) { env.setPropertyResolved(true); if (_isReadOnly) return true; BeanProperty prop = props.getBeanProperty((String) property); if (prop != null) return prop.isReadOnly(); } throw new PropertyNotFoundException("'" + property + "' is an unknown bean property of '" + base.getClass().getName() + "'"); }
private BeanProperty getBeanProperty(ELContext context, Object base, Object prop) { String property = prop.toString(); Class baseClass = base.getClass(); BeanProperties bps = properties.get(baseClass); if (bps == null) { bps = new BeanProperties(baseClass); properties.put(baseClass, bps); } BeanProperty bp = bps.getBeanProperty(property); if (bp == null) { throw new PropertyNotFoundException( ELUtil.getExceptionMessageString(context, "propertyNotFound", new Object[] { baseClass.getName(), property})); } return bp; } }