/** * Misc: return the property of name 'name' */ public AttrProp getAttrProp(String name) { return this.getAttrProp(name, false); }
protected void addKnownValue(String name, Object value) { this.beanProp(name).addKnownValue(value); }
public void addPropertyChangeListener(String n, PropertyChangeListener l) { BeanProp p = this.beanProp(n); if (p != null) p.addPCListener(l); }
/** * Create a change event for the current property */ PropertyChangeEvent createEvent(DOMBinding b, Object oldValue, Object newValue, String attrName) { if (!useEvents() && !useVetoEvents()) return null; StringBuffer name = new StringBuffer(); if (attrName != null) { name.append(":"); // NOI18N name.append(attrName); } this.buildPathName(b, name); return new PropertyChangeEvent(this.bean, name.toString(), oldValue, newValue); }
public void removeValue(int index) { if (index >= this.bindingsSize() && Common.isVetoable(this.type) && useVetoEvents()) { DOMBinding b = (DOMBinding)this.bindings.get(index); if (b != null) { Object value = b.getValue(this); // Check before doing any change if this is ok this.raiseVetoableEvent(value, 0, OP_SETTER_REMOVE); } // If we reach this point, no exception has been raised, // and the change can happen. } this.removeElement(index, true); }
protected Object[] getObjectArray(int extraElements) { int size = this.bindingsSize(); Object a = Array.newInstance(this.propClass, if (extraElements >= 0) { for (i=0; i<size; i++) Array.set(a, i, this.getValue(i)); System.err.println("bean: " + this.getName() + "dtdname: " + this.getDtdName() + "class: " + this.getPropertyClass()); Object o = this.getValue(i); if (o != null) System.err.println("elt: " + o.toString() + " - " + this.getBean().write(System.err); System.err.println(this.getBean().dumpDomNode()); } catch (java.io.IOException e2) {
String dtdName = p.getDtdName(); String beanName = p.getDtdName(); Class beanClass = p.getPropClass(); for(int j=0; j<attrs.length; j++) { String a = attrs[j]; if (!this.beanProp().getAttrProp(a).isFixed()) { String v = this.getAttributeValue(a); if (bean.getAttributeValue(a) != v) String name = prop.getBeanName(); int size = prop.size(); if (Common.isBean(prop.type)) { for(int i=0; i<size; i++) { BaseBean b = (BaseBean)prop.getValue(i); if (b != null) b = (BaseBean)b.clone(); bean.addValue(name, prop.getValue(i)); attrs = prop.getAttributeNames(); for(int j=0; j<attrs.length; j++) { String a = attrs[j]; if (!prop.getAttrProp(a).isFixed()) { for(int i=0; i<size; i++) { String v = prop.getAttributeValue(i, a); if (bean.getAttributeValue(name, i, a) != v) bean.setAttributeValue(name, i, a, v);
if (Common.isVetoable(this.type) && useVetoEvents()) { this.raiseVetoableEvent(value, 0, OP_SETTER_SETARRAY); int size = this.bindingsSize(); boolean found; boolean skipNew[] = null; if (useEvents()) { oldValue = Array.newInstance(this.propClass, size); Object o = this.getValue(i); if (o == null) continue; if (useEvents()) { if (Common.isBean(this.type)) Array.set(oldValue, i, ((BaseBean)o).clone()); this.removeElement(i, false); if (useEvents()) { Array.set(oldValue, i, o); if (i != j) int idx = this.setElement(0, value[i], true); b = (DOMBinding)this.bindings.get(idx); newBindings.add(null); newBindings.ensureCapacity(newSize+1);
Object []arrValue; curValue = this.getValues(); switch(op) { case OP_SETTER_SETARRAY: case OP_SETTER_SETELT: arrValue = this.getObjectArray(0); arrValue[index] = value; newValue = arrValue; arrValue = this.getObjectArray(1); arrValue[this.bindingsSize()] = value; newValue = arrValue; break; arrValue = this.getObjectArray(-1); curValue = this.getValue(0); newValue = value; PropertyChangeEvent e = this.createEvent(this.bean.binding, curValue, newValue, null); this.notifyInternal(new InternalEvent(InternalEvent.VETOABLE, e), true);
TraceLogger.put(TraceLogger.DEBUG, TraceLogger.SVC_DD, DDLogFlags.DBG_UBN, 1, DDLogFlags.FINDATTR, bp.getName() + "." + name + " for value " + value); int size = bp.size(); if (bp.isIndexed()) { for (int k=0; k<size; k++) { String v = bp.getAttributeValue(k, name); v = (String)Common.getComparableObject(v); DDLogFlags.DBG_UBN, 1, DDLogFlags.FINDCMP, bp.getName() + "." + name + " = " + v); if ((bean == null || bean == bp.getValue(k)) && value.equals(v)) { if (DDLogFlags.debug) { found.add(bp.buildFullName(k, name)); String v = bp.getAttributeValue(0, name); v = (String)Common.getComparableObject(v); DDLogFlags.DBG_UBN, 1, DDLogFlags.FINDCMP, bp.getName() + "." + name + " = " + v);
AttrProp ap = this.getAttrProp(name); this.checkParams(index, null, false); if (index != 0 || this.bindingsSize() != 0) { b = (DOMBinding)this.bindings.get(index); } else if (DDLogFlags.debug) { b.setAttributeValue(this, ap.getDtdName(), normalizedAttrValue(value));
/** * Get the attribute value */ public String getAttributeValue(int index, String name) { String ret = null; AttrProp ap = this.getAttrProp(name); if (!Common.isArray(this.type)) { // Value not set for single type property - return null if ((index > 0) || (this.bindingsSize() == 0)) return null; } DOMBinding b = (DOMBinding)this.bindings.get(index); if (b != null) ret = b.getAttributeValue(this, ap.getDtdName()); if (DDLogFlags.debug) { TraceLogger.put(TraceLogger.DEBUG, TraceLogger.SVC_DD, DDLogFlags.DBG_BLD, 10, DDLogFlags.GETATTR, this.beanName + "[" + index + "]." + ap.getDtdName() + ": " + ret + " " + ((b==null)?"<no binding>":("B("+b.hashCode()+")"))+ " BP(" + this.hashCode() + ")"); } return ret; }
this.checkParams(index, value, add); this.removeElement(index, false); empty = (this.bindingsSize() == 0); if (!empty) b = (DOMBinding)this.bindings.get(index); index = this.bindingsSize(); String[] names = bb.cachedAttributeNames(); for (int i=0; i<names.length; i++) { this.setAttributeValue(index, names[i], bb.cachedAttributeValue(names[i])); this.removeElement(index, false);
public class IterateChoiceProperties implements java.util.Iterator { private ArrayList groups; private int index; public IterateChoiceProperties() { this.groups = new ArrayList(); this.index = 0; } void add(BeanProp prop) { if (prop.group != null && !this.groups.contains(prop.group)) this.groups.add(prop.group); } public boolean hasNext() { return (this.index < this.groups.size()); } public Object next() throws NoSuchElementException { if (hasNext()) { BeanProp.GroupProp gp = (BeanProp.GroupProp)this.groups.get(this.index++); return (BaseProperty[])gp.list(); } else throw new NoSuchElementException(); } public void remove() throws UnsupportedOperationException, IllegalStateException { throw new UnsupportedOperationException();
/** * Searches node corresponding to the path * @param bean * @param path * @return the node if found, otherwise null */ private static Node findNode(BaseBean bean, String path) { if (path.startsWith(bean.fullName())) { BaseBean matchingChild; while ((matchingChild = getMatchingChild(bean, path)) != null) { bean = matchingChild; } if (path.equals(bean.fullName())) { return bean.binding.node; } BeanProp[] beanProps = bean.beanProps(); for (int i = 0; i < beanProps.length; i++) { BeanProp prop = beanProps[i]; int n = prop.bindingsSize(); for (int j = 0; j < n; j++) { if (path.equals(prop.getFullName(j))) { return prop.getBinding(j).node; } } } } return null; }
DOMBinding b; if (index >= this.bindingsSize()) { b.setLastKnownIndex(this, index); PropertyChangeEvent e = this.createEvent(b, oldValue, null, null); this.notifyInternal(e, true);
public int size() { return this.bindingsSize(); }
String buildFullName(int index, String attr) { StringBuffer name = new StringBuffer(); if (!Common.isArray(this.type)) { // Value not set for single type property - return null if ((index > 0) || (this.bindingsSize() == 0)) return null; } DOMBinding b = (DOMBinding)this.bindings.get(index); if (b != null) { if (attr != null) { name.append(":"); // NOI18N name.append(attr); } this.buildPathName(b, name); } else return null; return name.toString(); }
BaseBean bean) throws Schema2BeansException { int count = 0; int size = this.bindingsSize(); bean = this.newBeanInstance();
public void addVetoableChangeListener(String n, java.beans.VetoableChangeListener l) { BeanProp p = this.beanProp(n); if (p != null) p.addVCListener(l); }