/** * {@inheritDoc} */ public ObjectList copy() { ObjectList newList = new ObjectList(name, _dynamic); for (Object item : this) { if (item instanceof IObjectContainer) { item = ((IObjectContainer) item).copy(); } newList.add(item); } return newList; }
@Override public boolean add(Object e) { return super.add(checkToCopy(e)); }
} else { ObjectList list = new ObjectList(false); ConstNode cn = (ConstNode) childResult; if (cn.getValue() != null) { list.addValue(cn.getName(), cn.getValue()); list.add(childResult); myValue = list.shrink();
public void addValue(String key, Object value) { ObjectTree tree = new ObjectTree(); tree.put(key, checkToCopy(value)); add(tree); }
@Override protected Object doInvoke(Context context) throws Exception { Object val = getValue(); if (val == null) { return null; } Map map = (Map) XmlUtils.fromXml(val.toString(), true); String rootName = map.keySet().iterator().next().toString(); Object obj = XmlUtils.extractSingleMapRoot(map); if(!ignoreRootTag){ ObjectTree tree=new ObjectTree(null); tree.addValue(rootName, obj); return tree; } if (obj instanceof Map) { ObjectTree tree = new ObjectTree(rootName); tree.addValues((Map) obj); return tree; } else if (obj instanceof Collection) { ObjectList list = new ObjectList(rootName, true); list.addAll((Collection) obj); return list; } else { return obj; } }
/** * Construct from a list of existing objects. * * @param existing * the objects to add to initialize the list with, by calling * justAdd(). */ public ObjectList(final boolean dynamic, final Object... existing) { super(existing.length); this._dynamic=dynamic; for (Object e : existing) { add(e); } }
@Override public String toXml() { return toXml(null, null); }
ObjectList list = new ObjectList(valueName, false); ConstNode cn = (ConstNode) childResult; if (cn.getValue() != null) { list.addValue(cn.getName(), cn.getValue()); list.add(childResult); myValue = list.shrink();
@Override public void addValue(String key, Object value) { ObjectTree tree = new ObjectTree(key); tree.put(key, checkToCopy(value)); add(tree); }
/** * Construct from a list of existing objects. * * @param existing * the objects to add to initialize the list with, by calling * justAdd(). */ public ObjectList(String name, boolean dynamic, final Object... existing) { super(existing.length); this.name = name; this._dynamic = dynamic; for (Object e : existing) { add(e); } }
/** * {@inheritDoc} */ public ObjectList copy() { ObjectList newList = new ObjectList(_dynamic); for (Object item : this) { if (item instanceof IObjectContainer) { item = ((IObjectContainer) item).copy(); } newList.add(item); } return newList; }
@Override public Object set(int index, Object element) { return super.set(index, checkToCopy(element)); }
@Override public void addValue(String key, Object value) { Object existing = get(key); if (existing == null) { put(key, value); Object v = get(key); if (v instanceof ObjectList) { ((ObjectList) v)._dynamic = false; } } else if (existing instanceof ObjectList) { ObjectList existingList = ((ObjectList) existing); if (existingList._dynamic) { ObjectList list = (ObjectList) existing; list.add(value); } else { ObjectList list = new ObjectList(true, existing, value); put(key, list); } } else { ObjectList list = new ObjectList(true, existing, value); put(key, list); } }
@Override public boolean add(Object e) { return super.add(checkToCopy(e)); }
@Override public void addValue(String key, Object value) { list.add(value); Object existing = get(key); if (existing == null) { // put will do the copying work, if copy-able put(key, value); // getting a copy of it, if copied Object v = get(key); if (v instanceof ObjectList) { ((ObjectList) v)._dynamic = false; } } else if (existing instanceof ObjectList) { ObjectList existingList = ((ObjectList) existing); if (existingList._dynamic) { ObjectList list = (ObjectList) existing; list.add(value); } else { ObjectList list = new ObjectList(key, true, existing, value); put(key, list); } } else { ObjectList list = new ObjectList(key, true, existing, value); put(key, list); } }
@Override public void add(int index, Object element) { super.add(index, checkToCopy(element)); }
@Override public Object set(int index, Object element) { return super.set(index, checkToCopy(element)); }
@Override public void add(int index, Object element) { super.add(index, checkToCopy(element)); }