/** * Convert an unique internal index value into the user visible * index value. The property name specified must be an indexed * property. * This method may return -1 if we cannot figure out the index. */ public int idToIndex(String name, int id) { return this.beanProp(name).idToIndex(id); }
/** * Set the value of an element for the indexed property named name, * using the unique internal index. */ public void setValueById(String name, int id, Object value) { BeanProp bp = this.beanProp(name); int index = bp.idToIndex(id); bp.setValue(index, value); }
public static int getPropertyIndex(Bean theRoot, String name) { String index = extractPropertyIndex(name); if (index != null) { int i = index.lastIndexOf('i'); if (i != -1) { // This is a removed property - return the old value return Integer.parseInt(index.substring(i+1)); } else { // Get the current index value Bean bean = getPropertyParent(theRoot, name); if (bean != null) { BeanProp bp = bean.beanProp(getPropertyName(name)); if (bp != null) return bp.idToIndex(Integer.parseInt(index, 16)); } } } return -1; }
/** * Set the attribute value on the current property bean */ public void setAttributeValue(String name, String value) { if (name == null) return; BeanProp bp = this.beanProp(); if (bp != null) { // Find out what our index is within the BeanProp object int i = bp.idToIndex(this.binding.getId()); bp.setAttributeValue(i, name, value); } else { // // There is no BeanProp/DOMBinding for this bean yet, // cache the value. // if (this.attrCache == null) this.attrCache = new HashMap(); this.attrCache.put(name, value); } }
/** * Get the attribute value on the current property bean. * If there is no current attribute (or element for that matter), * then null is returned. */ public String getAttributeValue(String name) { BeanProp bp = this.beanProp(); if (bp != null) { // Find out what our index is within the BeanProp object int i = bp.idToIndex(this.binding.getId()); if (i < 0) // I guess we're not part of the BeanProp yet. return null; return bp.getAttributeValue(i, name); } else { // // That's a brand new bean not attached yet to a graph. Try // to get the value from the cache. // if (this.attrCache != null) return (String)this.attrCache.get(name); else return null; } }
int i = prop.idToIndex(this.id); if (i != -1) bp.lastIndex = i;