protected void copyProperty(BeanProp prop, BaseBean bean, int index, Object value) { boolean isArray = Common.isArray(prop.type); String name = prop.getName(); // Copy the property value if (value == null) { if (isArray) value = bean.getValue(name, index); else value = bean.getValue(name, 0); } int newIndex = 0; if (isArray) { newIndex = addValue(prop, value); } else { setValue(prop, 0, value); index = 0; } this.copyAttributes(prop, newIndex, bean, index); }
/** * If you call this method, you're responsible for setting up the * right encoding for the Writer @param w. */ public void write(java.io.Writer w) throws IOException, Schema2BeansException { write(w, null); }
/** * Create a new property for the current bean, selecting default option * values. */ public void createProperty(String dtdName, String beanName, Class type) { int o = Common.TYPE_0_1; if (type.isInstance(java.lang.String.class)) o |= Common.TYPE_STRING; else o |= Common.TYPE_BEAN; this.createProperty(dtdName, beanName, o, type); }
public void removeValue() { if (this.index != -1) { this.root.removeValue(this.name, this.root.getValueById(this.name, this.index)); } else this.root.setValue(this.name, null); }
this.getClass().getName() + "/" + (bean==null?"<getAttributeValue(\"Id\")null>":bean.getClass().getName()) + " - " + mergeModeToString(mode)); if (!mergeAttributes(bean, mode)) { return false; Iterator it = beanPropsIterator(); int size2 = bean.size(name); boolean toRemove[] = new boolean[size1]; boolean toAdd[] = new boolean[size2]; o2 = bean.getValue(name, j); mergeTree((BaseBean)o2, mode); hasKey = this.setHasKeyDefaultValue(prop); removeValue(prop, i-j); j++; BaseBean srcBean = (BaseBean) bean.getValue(name, j); o2 = srcBean.clone(); addValue(prop, o2); ((BaseBean)o2).mergeTree(srcBean, mode); } else {
public void dump(StringBuffer str, String indent){ String s; Object o; org.netbeans.modules.schema2beans.BaseBean n; str.append(indent); str.append("Name"); // NOI18N str.append(indent+"\t"); // NOI18N str.append("<"); // NOI18N s = this.getName(); str.append((s==null?"null":s.trim())); // NOI18N str.append(">\n"); // NOI18N this.dumpAttributes(NAME, 0, str, indent); str.append(indent); str.append("Parameters"); // NOI18N n = (org.netbeans.modules.schema2beans.BaseBean) this.getParameters(); if (n != null) n.dump(str, indent + "\t"); // NOI18N else str.append(indent+"\tnull"); // NOI18N this.dumpAttributes(PARAMETERS, 0, str, indent); } public String dumpBeanNode(){
String[] attrs = this.getAttributeNames(); if (attrs != null) { 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) bean.setAttributeValue(a, v); Iterator it = beanPropsIterator(); BaseBean b = (BaseBean)prop.getValue(i); if (b != null) b = (BaseBean)b.clone(); bean.addValue(name, b); bean.addValue(name, prop.getValue(i)); 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); BaseBean b = (BaseBean)prop.getValue(0); if (b != null) b = (BaseBean)b.clone(); bean.setValue(name, b); } else { bean.setValue(name, prop.getValue(0));
return; BaseProperty[] props = bean.listProperties(); BaseAttribute[] attrs = bean.listAttributes(); if (propName == null && attrs != null && attrs.length > 0) { BeanProp bp = bean.beanProp(); this.lookForAttribute(found, bp, bean, attrs, attrName, value); this.lookForAttribute(found, bp, null, attrs, attrName, value); BaseBean[] ba = (BaseBean[])bean.getValues(name); for (int k=0; k<ba.length; k++) find(ba[k], found, propName, attrName, value); } else if (p.isBean()) { BaseBean b = (BaseBean)bean.getValue(name); find(b, found, propName, attrName, value);
public int getCardinal(){ String name = baseBean.name(); BaseBean parent = baseBean.parent(); BaseProperty baseProperty = parent.getProperty(name); return baseProperty.getInstanceType(); }
void setValues(BaseBean b) { this.curParent = b; if (baseProp.isIndexed()) { this.values = b.getValues(this.name); } else { this.values = new Object[1]; this.values[0] = b.getValue(this.name); if (bb != null) { Object o2 = Common. getComparableObject(bb.getValue(this.keyName)); if (this.autoCreate) { if (this.baseProp.isBean()) { BaseBean bb = b.newInstance(this.name); if (this.keyName != null) bb.setValue(this.keyName, this.keyValue); if (this.baseProp.isIndexed()) b.addValue(this.name, bb); else b.setValue(this.name, bb); this.values = new Object[] {this.keyValue}; if (this.baseProp.isIndexed()) { b.setValue(this.name, this.values); } else { b.setValue(this.name, this.keyValue);
Iterator it = curBean.beanPropsIterator(); boolean useKeys = useMddKeys; useKeys = false; if (curBean.getProperty() != null && curBean.getProperty().isKey()) { BaseAttribute[] ba = curBean.listAttributes(); if (!ba[j].isFixed()) { String attrName = ba[j].getName(); String curValue = curBean.getAttributeValue(attrName); String otherValue = newBean.getAttributeValue(attrName); int size2 = newBean.size(name); o2 = newBean.getValue(name, i); o3 = this.compareProperty(name, curBean, o1, i, newBean, o2, i); if (!isBean && isKey) { o1 = prop.getValue(0); o2 = newBean.getValue(name); o3 = this.compareProperty(name, curBean, o1, -1, newBean, o2, -1);
/** * Return the entry for the BaseBean, if any. */ RegEntry getRegEntry(BaseBean bean, boolean raise) { for (int i=0; i<this.scopes.size(); i++) { RegEntry se = (RegEntry)this.scopes.get(i); if (se.getBean() == bean) { return se; } } // Didn't find it - try to look for the root if ((bean != null) && !bean.isRoot()) { do { bean = bean.parent(); } while(bean != null && !bean.isRoot()); return this.getRegEntry(bean, raise); } if (raise) { throw new IllegalArgumentException(Common.getMessage( "BeanGraphEntryNotInRegistry_msg", bean.name())); } else return null; }
public String getXPath(){ ///String format = BundleReader.getValue("Name_Value_Pair_Format");//NOI18N ///Object[] arguments = new Object[]{"Name", baseBean.name()}; //NOI18N ///System.out.println(MessageFormat.format(format, arguments)); ///arguments = new Object[]{"FullName", baseBean.fullName()}; //NOI18N ///System.out.println(MessageFormat.format(format, arguments)); BaseBean bean = baseBean; BaseBean parentBean = null; String xpath = bean.dtdName(); ///boolean root = bean.isRoot(); boolean root = isRootElement(bean); parentBean = bean.parent(); while(!root){ xpath = parentBean.dtdName() + Constants.XPATH_DELIMITER + xpath; bean = parentBean; parentBean = bean.parent(); ///root = bean.isRoot(); root = isRootElement(bean); } xpath = Constants.XPATH_DELIMITER + xpath; return xpath; }
n = parse.substring(pos, i); pos = i+1; if (root.getProperty() == null) { System.out.println("root.getProperty="+root.getProperty()); System.out.println("parse="+parse); System.out.println("n="+n); continue; if (!root.getProperty().hasName(n) || last) { cur = new PropParser(n, autoCreate); if (prev != null) { BaseProperty[] p = bean.listProperties(); String name = cur.name; boolean found = false; throw new NoSuchElementException(Common.getMessage( "NotFoundInPropertyList_msg", name, root.toString()));