/** * Return the value of the attribute. Get the value from the DOM Node * or from the cache, depending on the existance of the DOM Node. */ String getAttributeValue(BeanProp prop, String name) { if (this.node != null) { // Get the value from the DOM Node Attr a = ((Element)this.node).getAttributeNode(name); if (a != null) return a.getValue(); else return null; } else { // Get the value from the cache BeanProperty bp = this.getBeanProperty(prop); if (bp != null && bp.attributes != null) { CacheAttr ca = findCacheAttr(bp, name); if (ca != null) return ca.value; } } return null; }
protected Boolean nodeToBoolean(BeanProp prop) { // If there is a node, that means the empty node exists (true) // If there is no node set, we might just not be attached to // a parent node right now, check our prop //System.out.println("node="+node+" getBean(prop)="+this.getBean(prop)); if (node == null) { Object result = getBean(prop); if (result == null) return Boolean.FALSE; //System.out.println("!!! node was null, but prop has something. prop="+prop); return (Boolean) result; } else { String ret = getDomValue(node); //System.out.println("ret="+ret); if (ret == null) return Boolean.TRUE; ret = ret.toLowerCase().intern(); if (ret == "false" || ret == "0") return Boolean.FALSE; // Just the node being there and not saying false is enough to // be true. return Boolean.TRUE; } }
/** * Return the BeanProp object where this bean belongs. */ public BeanProp beanProp() { if (this.binding != null) return this.binding.getBeanProp(this); else return null; }
Node node1 = domBinding1.getNode(); Node node2 = domBinding2.getNode(); b = new DOMBinding(); b.register(this, value); b.setDefaultAttributeValues(this); oldValue = b.setValue(this, value); b.syncNodes(this, new Action(Action.ADD)); b.notifyBeansForChange(oldValue, value, null);
BeanProperty bp = this.getBeanProperty(prop); bp.value = getDomValue(node); this.removeNode(prop); prop.notifyInternal(e, false); BeanProp.Action a2; a2 = new BeanProp.Action(a.REMOVE); syncNodes(this.prop.beanProp, a2); (nodeToBoolean(prop)).booleanValue() != v) {
BeanProperty bp = this.getBeanProperty(prop); oldValue = this.getValue(prop); prefix); } else { declaredNS = findNamespace(prefix); prefix}); } else { declaredNS = findNamespace(prefix); bp.value = this.getWrapperValue(value); } else bp.value = value;
ret = this.getDomValue(this.node); else ret = (String)this.getBean(prop); prefix = ret.substring(0, colonPos); localPart = ret.substring(colonPos+1, ret.length()); ns = findNamespace(prefix); return this.getBean(prop); return nodeToBoolean(prop); default: throw new Schema2BeansRuntimeException(Common.getMessage(
if ((b.getNode() == node) || (binding == b)) throw new Schema2BeansException(Common. getMessage("NodeAlreadyReferenced_msg", node)); if (b.getNode() != null) { count++; binding = new DOMBinding(node); binding.register(this, bean); binding.setValue(this, bean);
Object oldValue = b.getAttributeValue(this, ap.getDtdName()); b.setAttributeValue(this, ap.getDtdName(), normalizedAttrValue(value)); b.notifyBeansForChange(oldValue, value, name);
/** * 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); } } }
/** * Retreive the last known index stored before removal. */ int getLastKnownIndex(BeanProp prop) { BeanProperty bp = this.getBeanProperty(prop); if (bp != null) return bp.lastIndex; else 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); } }
return calendarToString((java.util.Calendar) value); } else if (value instanceof org.netbeans.modules.schema2beans.QName) { org.netbeans.modules.schema2beans.QName q =
/** * 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; }
bean = (BaseBean)newBinding.getBean(matchingProp); else bean = null;
/** * Used when we remove a property to set the index it used to be * in the BeanProp bindings array. This is how when we build on event * that reference an element which has been removed we know about * its previous index. */ void setLastKnownIndex(BeanProp prop, int index) { BeanProperty bp = this.getBeanProperty(prop); if (bp != null) bp.lastIndex = index; }
/** * 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; } }
BeanProperty bp = this.getBeanProperty(prop); if (bp.attributes == null) bp.attributes = new ArrayList(); CacheAttr ca = findCacheAttr(bp, name); if (ca == null) { ca = new CacheAttr(name, value);
/** * Build the current path up to the root node. See the BeanProp object * for more details. */ protected void buildPathName(StringBuffer str) { if (this.binding != null) { BeanProp p = this.binding.getBeanProp(this); if (p != null) p.buildPathName(this.binding, str); } }
/** * This method returns the bean associated to the BeanProp object. * Since there can be only one Node per BeanProp (single content as * one bean or one distinct Node per each element if indexed prop), * there is only one entry for this BeanProp object. * * The object returned can be either a bean or a wrapper object. */ Object getBean(BeanProp prop) { BeanProperty bp = this.getBeanProperty(prop); if (bp != null) return bp.value; else return null; }