/** * Removes the specified node from this configuration. This method ensures * that parent nodes that become undefined by this operation are also * removed. * * @param node the node to be removed */ protected void removeNode(ConfigurationNode node) { ConfigurationNode parent = node.getParentNode(); if (parent != null) { parent.removeChild(node); if (!nodeDefined(parent)) { removeNode(parent); } } }
/** * Removes the specified node from this configuration. This method ensures * that parent nodes that become undefined by this operation are also * removed. * * @param node the node to be removed */ protected void removeNode(ConfigurationNode node) { ConfigurationNode parent = node.getParentNode(); if (parent != null) { parent.removeChild(node); if (!nodeDefined(parent)) { removeNode(parent); } } }
public void saveTo(Configuration conf) { boolean removed = false; List<HierarchicalConfiguration> fields = ((HierarchicalConfiguration) getConfig()).configurationsAt(PSCANS_KEY); for (HierarchicalConfiguration sub : fields) { if (isPluginConfiguration(sub)) { sub.getRootNode().getParentNode().removeChild(sub.getRootNode()); removed = true; break; } } boolean persistId = false; String entryKey = PSCANS_KEY + "(" + (removed ? fields.size() - 1 : fields.size()) + ")."; if (getAlertThreshold() != AlertThreshold.MEDIUM) { conf.setProperty(entryKey + ALERT_THRESHOLD_KEY, getAlertThreshold().name()); // For compatibility with older versions: conf.setProperty(entryKey + LEVEL_KEY, getAlertThreshold().name()); persistId = true; } if (!isEnabled()) { conf.setProperty(entryKey + ENABLED_KEY, Boolean.FALSE); persistId = true; } if (persistId) { conf.setProperty(entryKey + ID_KEY, getPluginId()); } }