use of org.eclipse.smarthome.config.xml.util.NodeValue in project smarthome by eclipse.
the class ChannelXmlResult method toChannelDefinition.
protected ChannelDefinition toChannelDefinition(String bindingId) throws ConversionException {
String id = getId();
String typeId = getTypeId();
String typeUID = getTypeUID(bindingId, typeId);
// Convert the channel properties into a map
Map<String, String> propertiesMap = new HashMap<>();
for (NodeValue property : getProperties()) {
propertiesMap.put(property.getAttributes().get("name"), (String) property.getValue());
}
ChannelDefinition channelDefinition = new ChannelDefinition(id, new ChannelTypeUID(typeUID), propertiesMap, getLabel(), getDescription());
return channelDefinition;
}
use of org.eclipse.smarthome.config.xml.util.NodeValue in project smarthome by eclipse.
the class ConfigDescriptionParameterConverter method readParameterOptions.
private List<ParameterOption> readParameterOptions(Object rawNodeValueList) {
if (rawNodeValueList instanceof List<?>) {
List<?> list = (List<?>) rawNodeValueList;
List<ParameterOption> result = new ArrayList<>();
for (Object object : list) {
if (object instanceof NodeValue) {
NodeValue nodeValue = (NodeValue) object;
String value = nodeValue.getAttributes().get("value");
String label = nodeValue.getValue().toString();
result.add(new ParameterOption(value, label));
}
}
return result;
}
return null;
}
use of org.eclipse.smarthome.config.xml.util.NodeValue in project smarthome by eclipse.
the class ChannelTypeConverter method readTags.
private Set<String> readTags(NodeIterator nodeIterator) throws ConversionException {
Set<String> tags = null;
List<?> tagsNode = nodeIterator.nextList("tags", false);
if (tagsNode != null) {
tags = new HashSet<>(tagsNode.size());
for (Object tagNodeObject : tagsNode) {
NodeValue tagNode = (NodeValue) tagNodeObject;
if ("tag".equals(tagNode.getNodeName())) {
String tag = (String) tagNode.getValue();
if (tag != null) {
tags.add(tag);
}
} else {
throw new ConversionException("The 'tags' node must only contain 'tag' nodes!");
}
}
}
return tags;
}
Aggregations