List of usage examples for org.apache.commons.beanutils DynaProperty isIndexed
public boolean isIndexed()
From source file:es.caib.zkib.jxpath.ri.model.dynabeans.DynaBeanPropertyPointer.java
/** * Learn whether the property referenced is an indexed property. * @return boolean/*w ww .ja v a2s . c o m*/ */ protected boolean isIndexedProperty() { DynaClass dynaClass = dynaBean.getDynaClass(); DynaProperty property = dynaClass.getDynaProperty(name); return property.isIndexed(); }
From source file:ddf.catalog.data.dynamic.impl.DynamicMetacardImpl.java
/** * Adds another value to the given attribute. If the attribute is not a multi-valued * attribute, it replaces the current value with the provided value. * * @param name name of the attribute to set * @param value the value to be set/*from www.j a v a 2 s . c o m*/ */ @Override public void addAttribute(String name, Object value) { if (name == null) { LOGGER.warn("Call to add attribute with null name - no action taken."); return; } DynaProperty dynaProperty = attributesBean.getDynaClass().getDynaProperty(name); if (value instanceof URI) { value = ((URI) value).toString(); } try { if (dynaProperty == null) { attributesBean.set(name, 0, value); } else { if (dynaProperty.isIndexed()) { if (value instanceof Collection) { // add all attributes individually for (Object o : (Collection) value) { attributesBean.set(name, attributesBean.size(name), o); } } else { attributesBean.set(name, attributesBean.size(name), value); } } else { LOGGER.debug("Can't add another value to a simple attribute {} - replacing value.", name); attributesBean.set(name, value); } } } catch (ConversionException e) { if (value != null && dynaProperty != null) { LOGGER.warn( "Unable to to convert provided value of class {} to attribute {} value of class {} - no action taken.", value.getClass().getSimpleName(), name, dynaProperty.getContentType().getSimpleName()); } } catch (IllegalArgumentException e) { LOGGER.warn("Attribute {} has different than expected cardinality - no action taken", name); } catch (IndexOutOfBoundsException e) { LOGGER.warn("Trying to set attribute {} at index {} which is out of range.", name, attributesBean.size(name)); } catch (NullPointerException e) { LOGGER.warn("Trying to set primitive type for attribute {} to a null value - no action taken", name); } }
From source file:ddf.catalog.data.dynamic.impl.DynamicMetacardImpl.java
/** * Sets the value of the given attribute. If the attribute is a multi-valued * attribute, it adds the given value to the current collection. If the value * is multi-valued, it replaces the values of the named attribute. * * @param name name of the attribute to set * @param value the value to be set//w w w. j a va 2s . c o m */ @Override public void setAttribute(String name, Object value) { if (name == null) { LOGGER.warn("Call to set attribute with null name - no action taken."); return; } DynaProperty dynaProperty = attributesBean.getDynaClass().getDynaProperty(name); if (value == null) { attributesBean.set(name, value); return; } if (value instanceof URI) { value = ((URI) value).toString(); } try { if (dynaProperty == null) { attributesBean.set(name, value); } else { if ((dynaProperty.getType() == Byte[].class) || !dynaProperty.isIndexed()) { attributesBean.set(name, value); } else { if (value instanceof Collection<?>) { LOGGER.debug("Replacing current value of attribute {} with provided collection", name); attributesBean.set(name, value); } else { LOGGER.debug("Adding provided value to attribute {}", name); attributesBean.set(name, attributesBean.size(name), value); } } } } catch (ConversionException e) { if (value != null && dynaProperty != null) { String classname = dynaProperty.getContentType() == null ? dynaProperty.getType().getSimpleName() : dynaProperty.getContentType().getSimpleName(); LOGGER.warn( "Unable to to convert provided value of class {} to attribute {} value of class {} - no action taken.", value.getClass().getSimpleName(), name, classname); } } catch (IllegalArgumentException e) { LOGGER.warn("Attribute {} has different than expected cardinality - no action taken", name); } catch (IndexOutOfBoundsException e) { LOGGER.warn("Trying to set attribute {} at index {} which is out of range.", name, attributesBean.size(name)); } catch (NullPointerException e) { LOGGER.warn("Trying to set primitive type for attribute {} to a null value - no action taken", name); } }
From source file:org.hyperic.lather.util.Latherize.java
private boolean isLatherStyleProp(DynaProperty prop) { if (prop.getName().equals("class") || (prop.isIndexed() && prop.getType() != byte[].class) || prop.isMapped()) {// ww w . j a va2s. c om return false; } return true; }