List of usage examples for org.apache.commons.configuration HierarchicalConfiguration configurationAt
public SubnodeConfiguration configurationAt(String key)
From source file:org.onosproject.drivers.oplink.OplinkRoadmPowerConfig.java
private Long acquirePortPower(PortNumber port, String selection) { String reply = netconfGetConfig(getPortPowerFilter(port)); HierarchicalConfiguration cfg = XmlConfigParser.loadXml(new ByteArrayInputStream(reply.getBytes())); HierarchicalConfiguration info = cfg.configurationAt("data.open-oplink-device.ports.port"); return info.getLong(selection); }
From source file:org.onosproject.drivers.oplink.OplinkRoadmPowerConfig.java
private Long acquireChannelPower(PortNumber port, OchSignal channel, String selection) { String reply = netconfGetConfig(getChannelPowerFilter(port, channel)); HierarchicalConfiguration cfg = XmlConfigParser.loadXml(new ByteArrayInputStream(reply.getBytes())); HierarchicalConfiguration info = cfg.configurationAt("data.open-oplink-device.ports.port.used-wavelengths"); return info.getLong(selection); }
From source file:org.onosproject.drivers.polatis.netconf.PolatisNetconfUtility.java
/** * Retrieves specified node hierarchical configuration from the xml information. * * @param content the xml information/*from w w w. j a v a 2s .co m*/ * @param key the configuration key node * @return the hierarchical configuration, null if exception happens */ public static HierarchicalConfiguration configAt(String content, String key) { HierarchicalConfiguration info; try { HierarchicalConfiguration cfg = XmlConfigParser.loadXmlString(content); info = cfg.configurationAt(key); } catch (IllegalArgumentException e) { // Accept null for information polling return null; } return info; }
From source file:org.pivot4j.ui.AbstractPivotRenderer.java
/** * @see org.pivot4j.ui.property.DefaultRenderPropertyList#saveSettings(org.apache.commons.configuration.HierarchicalConfiguration) *//*from ww w. j av a 2 s .co m*/ @Override public void saveSettings(HierarchicalConfiguration configuration) { if (configuration == null) { throw new NullArgumentException("configuration"); } configuration.setDelimiterParsingDisabled(true); if (configuration.getLogger() == null) { configuration.setLogger(LogFactory.getLog(getClass())); } configuration.addProperty("drillDown[@mode]", drillDownMode); configuration.addProperty("drillDown[@enabled]", enableDrillDown); configuration.addProperty("sort[@enabled]", enableSort); if (sortMode != null) { configuration.addProperty("sort[@mode]", sortMode.getName()); } configuration.addProperty("drillThrough[@enabled]", enableDrillThrough); if (!aggregatorNames.isEmpty()) { int index = 0; for (AggregatorKey key : aggregatorNames.keySet()) { Axis axis = key.getAxis(); AggregatorPosition position = key.getPosition(); List<String> names = aggregatorNames.get(key); for (String name : names) { configuration.addProperty(String.format("aggregations.aggregation(%s)[@name]", index), name); configuration.addProperty(String.format("aggregations.aggregation(%s)[@axis]", index), axis.name()); configuration.addProperty(String.format("aggregations.aggregation(%s)[@position]", index), position.name()); index++; } } } for (String category : renderProperties.keySet()) { RenderPropertyList properties = renderProperties.get(category); if (properties != null) { String propertyConfigName = "properties." + category; configuration.addProperty(propertyConfigName, ""); properties.saveSettings(configuration.configurationAt(propertyConfigName)); } } configuration.addProperty("filter[@visible]", renderSlicer); }
From source file:org.pivot4j.ui.AbstractPivotRenderer.java
/** * @see org.pivot4j.state.Configurable#restoreSettings(org.apache.commons.configuration.HierarchicalConfiguration) *///from w ww .jav a2 s. c om @Override public void restoreSettings(HierarchicalConfiguration configuration) { if (configuration == null) { throw new NullArgumentException("configuration"); } this.drillDownMode = configuration.getString("drillDown[@mode]", DrillDownCommand.MODE_POSITION); this.enableDrillDown = configuration.getBoolean("drillDown[@enabled]", true); this.enableSort = configuration.getBoolean("sort[@enabled]", true); // TODO Need to support a custom implementation. String sortModeName = configuration.getString("sort[@mode]", SortMode.BASIC.getName()); this.sortMode = SortMode.fromName(sortModeName); if (sortMode == null) { Logger logger = LoggerFactory.getLogger(getClass()); if (logger.isWarnEnabled()) { logger.warn("Ignoring unknown sort mode name : {}", sortModeName); } this.sortMode = SortMode.BASIC; } this.enableDrillThrough = configuration.getBoolean("drillThrough[@enabled]", false); List<HierarchicalConfiguration> aggregationSettings = configuration .configurationsAt("aggregations.aggregation"); this.aggregatorNames.clear(); for (HierarchicalConfiguration aggConfig : aggregationSettings) { String name = aggConfig.getString("[@name]"); if (name != null) { Axis axis = Axis.Standard.valueOf(aggConfig.getString("[@axis]")); AggregatorPosition position = AggregatorPosition.valueOf(aggConfig.getString("[@position]")); AggregatorKey key = new AggregatorKey(axis, position); List<String> names = aggregatorNames.get(key); if (names == null) { names = new LinkedList<String>(); aggregatorNames.put(key, names); } if (!names.contains(name)) { names.add(name); } } } initializeRenderProperties(); for (String category : getRenderPropertyCategories()) { RenderPropertyList properties = renderProperties.get(category); if (properties != null) { try { properties.restoreSettings(configuration.configurationAt("properties." + category)); } catch (IllegalArgumentException e) { } } } this.renderSlicer = configuration.getBoolean("filter[@visible]", false); String collectorType = configuration.getString("propertyCollector[@type]"); // TODO At this time, we're not sure how to make property collector // configurable. So, let's just treat it as a read-only property. if ("non-internal".equalsIgnoreCase(collectorType)) { this.propertyCollector = new NonInternalPropertyCollector(); } else { this.propertyCollector = null; } }
From source file:org.pivot4j.ui.property.DefaultRenderPropertyList.java
/** * @see org.pivot4j.state.Configurable#saveSettings(org.apache.commons.configuration.HierarchicalConfiguration) *//*from www. j a va2 s.co m*/ @Override public void saveSettings(HierarchicalConfiguration configuration) { int index = 0; for (RenderProperty property : properties.values()) { String name = String.format("property(%s)", index++); configuration.setProperty(name, ""); SubnodeConfiguration propertyConfig = configuration.configurationAt(name); property.saveSettings(propertyConfig); } }