/** * Fill the attribute with the default values - this is typically * called when a new property is created, before it is synced into * a DOM Node. This makes the attributes cached and when the property * is turned into a DOM node, the attributes are also created. */ void setDefaultAttributeValues(BeanProp prop) { BeanProperty bp = this.getBeanProperty(prop); if (bp != null) { // Set the default values BaseAttribute[] ap = prop.getAttributes(); for (int i=0; i<ap.length; i++) { String value = ap[i].getDefaultValue(); if (value != null) this.setAttributeValue(prop, ap[i].getDtdName(), value); } } }
private boolean mergeAttributes(BaseBean bean, int mode) { boolean result = true; // We need to process the attributes of the root first BaseAttribute[] ba = bean.listAttributes(); // We might have no attribute on the root if (ba != null) { for (int j = 0; j < ba.length; j++) { BaseAttribute baseAttribute = ba[j]; if (!baseAttribute.isFixed() && !baseAttribute.isTransient()) { String attrName = baseAttribute.getName(); String curValue = this.getAttributeValue(attrName); String otherValue = bean.getAttributeValue(attrName); if (curValue != otherValue) { // Might have one of the two null, not both if (curValue == null || otherValue == null || !curValue.equals(otherValue)) { if ((mode & MERGE_COMPARE) == MERGE_COMPARE) { return false; } if ((mode & MERGE_UNION) == MERGE_UNION) { this.setAttributeValue(attrName, otherValue); } } } } } } return result; }
private void copyAttributes(BeanProp prop, int propIndex, BaseBean bean, int beanIndex) { // Copy the attributes String name = prop.getName(); BaseAttribute[] ba = bean.listAttributes(name); if (ba != null) { for(int j=0; j<ba.length; j++) { if (!ba[j].isFixed()) { String attrName = ba[j].getName(); String v = bean.getAttributeValue(name, beanIndex, attrName); if (v != prop.getAttributeValue(propIndex, attrName)) { prop.setAttributeValue(propIndex, attrName, v); } } } } }