/** * If the base object is a ResourceBundle, returns the most general type that this resolver * accepts for the property argument. Otherwise, returns null. Assuming the base is a * ResourceBundle, this method will always return String.class. * * @param context * The context of this evaluation. * @param base * The bundle to analyze. Only bases of type ResourceBundle are handled by this * resolver. * @return null if base is not a ResourceBundle; otherwise String.class. */ @Override public Class<?> getCommonPropertyType(ELContext context, Object base) { return isResolvable(base) ? String.class : null; }
private ELResolver createElResolver() { CompositeELResolver compositeResolver = new CompositeELResolver(); compositeResolver.add(new ArrayELResolver()); compositeResolver.add(new ListELResolver()); compositeResolver.add(new MapELResolver()); compositeResolver.add(new JsonNodeELResolver()); compositeResolver.add(new ResourceBundleELResolver()); compositeResolver.add(new DynamicBeanPropertyELResolver(ItemInstance.class, "getFieldValue", "setFieldValue")); compositeResolver.add(new BeanELResolver()); return new SimpleResolver(compositeResolver); }
private ELResolver createElResolver() { CompositeELResolver compositeResolver = new CompositeELResolver(); compositeResolver.add(new ArrayELResolver()); compositeResolver.add(new ListELResolver()); compositeResolver.add(new MapELResolver()); compositeResolver.add(new JsonNodeELResolver()); compositeResolver.add(new ResourceBundleELResolver()); compositeResolver.add(new DynamicBeanPropertyELResolver(ItemInstance.class, "getFieldValue", "setFieldValue")); compositeResolver.add(new BeanELResolver()); compositeResolver.add(new CouldNotResolvePropertyELResolver()); return new SimpleResolver(compositeResolver); }
if (isResolvable(base)) { final Enumeration<String> keys = ((ResourceBundle) base).getKeys(); return new Iterator<FeatureDescriptor>() {
/** * If the base object is not null and an instanceof java.util.ResourceBundle, return true. * * @return If the propertyResolved property of ELContext was set to true, then true; otherwise * undefined. * @throws NullPointerException * if context is null. */ @Override public boolean isReadOnly(ELContext context, Object base, Object property) { if (context == null) { throw new NullPointerException("context is null"); } if (isResolvable(base)) { context.setPropertyResolved(true); } return true; }
/** * If the base object is a ResourceBundle, throw a {@link PropertyNotWritableException}. * * @param context * The context of this evaluation. * @param base * The bundle to analyze. Only bases of type ResourceBundle are handled by this * resolver. * @param property * The name of the property to analyze. Will be coerced to a String. * @param value * The value to be set. * @throws NullPointerException * if context is null. * @throws PropertyNotWritableException * Always thrown if base is an instance of ResourceBundle. */ @Override public void setValue(ELContext context, Object base, Object property, Object value) { if (context == null) { throw new NullPointerException("context is null"); } if (isResolvable(base)) { throw new PropertyNotWritableException("resolver is read-only"); } }
/** * If the base object is an instance of ResourceBundle, return null, since the resolver is read * only. If the base is ResourceBundle, the propertyResolved property of the ELContext object * must be set to true by this resolver, before returning. If this property is not true after * this method is called, the caller should ignore the return value. * * @param context * The context of this evaluation. * @param base * The bundle to analyze. Only bases of type ResourceBundle are handled by this * resolver. * @param property * The name of the property to analyze. * @return If the propertyResolved property of ELContext was set to true, then null; otherwise * undefined. * @throws NullPointerException * if context is null */ @Override public Class<?> getType(ELContext context, Object base, Object property) { if (context == null) { throw new NullPointerException("context is null"); } if (isResolvable(base)) { context.setPropertyResolved(true); } return null; }
if (isResolvable(base)) { if (property != null) { try {