protected void attachIfNecessary() { if (!attached) { getParentAttached().attachChild(this); } }
void clear() { for (Iterator<SimpleConfigurationNode> it = iterateChildren().iterator(); it.hasNext();) { SimpleConfigurationNode node = it.next(); node.attached = false; it.remove(); if (node.getParentAttached().equals(holder)) { node.clear(); } } }
SimpleConfigurationNode getParentAttached() { SimpleConfigurationNode parent = this.parent; if (parent.isVirtual()) { parent = parent.getParentAttached().attachChildIfAbsent(parent); } return this.parent = parent; }
protected void attachChild(SimpleConfigurationNode child) { if (isVirtual()) { throw new IllegalStateException("This parent is not currently attached. This is an internal state violation."); } if (!child.getParentAttached().equals(this)) { throw new IllegalStateException("Child " + child + " path is not a direct parent of me (" + this + "), cannot attach"); } ConfigValue oldValue, newValue; synchronized (this) { newValue = oldValue = this.value; if (!(oldValue instanceof MapConfigValue)) { if (child.key instanceof Integer) { if (oldValue instanceof NullConfigValue) { newValue = new ListConfigValue(this); } else if (!(oldValue instanceof ListConfigValue)) { newValue = new ListConfigValue(this, oldValue.getValue()); } } else { newValue = new MapConfigValue(this); } } possiblyDetach(newValue.putChild(child.key, child)); value = newValue; } if (newValue != oldValue) { oldValue.clear(); } child.attached = true; }
throw new IllegalStateException("This parent is not currently attached. This is an internal state violation."); if (!child.getParentAttached().equals(this)) { throw new IllegalStateException("Child " + child + " path is not a direct parent of me (" + this + "), cannot attach");