use of java.beans.FeatureDescriptor in project tomcat by apache.
the class ImplicitObjectELResolver method getFeatureDescriptors.
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
List<FeatureDescriptor> feats = new ArrayList<>(SCOPE_NAMES.length);
FeatureDescriptor feat;
for (int i = 0; i < SCOPE_NAMES.length; i++) {
feat = new FeatureDescriptor();
feat.setDisplayName(SCOPE_NAMES[i]);
feat.setExpert(false);
feat.setHidden(false);
feat.setName(SCOPE_NAMES[i]);
feat.setPreferred(true);
feat.setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
feat.setValue(TYPE, String.class);
feats.add(feat);
}
return feats.iterator();
}
use of java.beans.FeatureDescriptor in project tomcat by apache.
the class MapELResolver method getFeatureDescriptors.
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
if (base instanceof Map<?, ?>) {
Iterator<?> itr = ((Map<?, ?>) base).keySet().iterator();
List<FeatureDescriptor> feats = new ArrayList<>();
Object key;
FeatureDescriptor desc;
while (itr.hasNext()) {
key = itr.next();
desc = new FeatureDescriptor();
desc.setDisplayName(key.toString());
desc.setShortDescription("");
desc.setExpert(false);
desc.setHidden(false);
desc.setName(key.toString());
desc.setPreferred(true);
desc.setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
desc.setValue(TYPE, key.getClass());
feats.add(desc);
}
return feats.iterator();
}
return null;
}
use of java.beans.FeatureDescriptor in project tomcat by apache.
the class TestBeanELResolver method testGetFeatureDescriptors02.
/**
* Tests that a valid FeatureDescriptors are returned.
*/
@Test
public void testGetFeatureDescriptors02() {
BeanELResolver resolver = new BeanELResolver();
ELContext context = new StandardELContext(ELManager.getExpressionFactory());
Iterator<FeatureDescriptor> result = resolver.getFeatureDescriptors(context, new Bean());
while (result.hasNext()) {
PropertyDescriptor featureDescriptor = (PropertyDescriptor) result.next();
Assert.assertEquals(featureDescriptor.getPropertyType(), featureDescriptor.getValue(ELResolver.TYPE));
Assert.assertEquals(Boolean.TRUE, featureDescriptor.getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME));
}
}
use of java.beans.FeatureDescriptor in project j2objc by google.
the class FeatureDescriptorTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
fd = new FeatureDescriptor();
}
use of java.beans.FeatureDescriptor in project Activiti by Activiti.
the class JsonNodeELResolver method getFeatureDescriptors.
/**
* If the base object is not null, returns an Iterator containing the set of JavaBeans
* properties available on the given object. Otherwise, returns null. The Iterator returned must
* contain zero or more instances of java.beans.FeatureDescriptor. Each info object contains
* information about a property in the bean, as obtained by calling the
* BeanInfo.getPropertyDescriptors method. The FeatureDescriptor is initialized using the same
* fields as are present in the PropertyDescriptor, with the additional required named
* attributes "type" and "resolvableAtDesignTime" set as follows:
* <ul>
* <li>{@link ELResolver#TYPE} - The runtime type of the property, from
* PropertyDescriptor.getPropertyType().</li>
* <li>{@link ELResolver#RESOLVABLE_AT_DESIGN_TIME} - true.</li>
* </ul>
*
* @param context
* The context of this evaluation.
* @param base
* The bean to analyze.
* @return An Iterator containing zero or more FeatureDescriptor objects, each representing a
* property on this bean, or null if the base object is null.
*/
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
if (isResolvable(base)) {
JsonNode node = (JsonNode) base;
final Iterator<String> keys = node.fieldNames();
return new Iterator<FeatureDescriptor>() {
public boolean hasNext() {
return keys.hasNext();
}
public FeatureDescriptor next() {
Object key = keys.next();
FeatureDescriptor feature = new FeatureDescriptor();
feature.setDisplayName(key == null ? "null" : key.toString());
feature.setName(feature.getDisplayName());
feature.setShortDescription("");
feature.setExpert(true);
feature.setHidden(false);
feature.setPreferred(true);
feature.setValue(TYPE, key == null ? "null" : key.getClass());
feature.setValue(RESOLVABLE_AT_DESIGN_TIME, true);
return feature;
}
public void remove() {
throw new UnsupportedOperationException("cannot remove");
}
};
}
return null;
}
Aggregations