Search in sources :

Example 1 with NodeList

use of org.eclipse.smarthome.config.xml.util.NodeList in project smarthome by eclipse.

the class EventDescriptionConverter method unmarshal.

@Override
public final Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    List<EventOption> eventOptions = null;
    NodeList nodes = (NodeList) context.convertAnother(context, NodeList.class);
    NodeIterator nodeIterator = new NodeIterator(nodes.getList());
    NodeList optionNodes = (NodeList) nodeIterator.next();
    if (optionNodes != null) {
        eventOptions = toListOfEventOptions(optionNodes);
    }
    nodeIterator.assertEndOfType();
    EventDescription eventDescription = new EventDescription(eventOptions);
    return eventDescription;
}
Also used : NodeIterator(org.eclipse.smarthome.config.xml.util.NodeIterator) NodeList(org.eclipse.smarthome.config.xml.util.NodeList) EventDescription(org.eclipse.smarthome.core.types.EventDescription) EventOption(org.eclipse.smarthome.core.types.EventOption)

Example 2 with NodeList

use of org.eclipse.smarthome.config.xml.util.NodeList in project smarthome by eclipse.

the class StateDescriptionConverter method unmarshal.

@Override
public final Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    Map<String, String> attributes = this.attributeMapValidator.readValidatedAttributes(reader);
    BigDecimal minimum = toBigDecimal(attributes, "min", null);
    BigDecimal maximum = toBigDecimal(attributes, "max", null);
    BigDecimal step = toBigDecimal(attributes, "step", null);
    String pattern = attributes.get("pattern");
    boolean readOnly = toBoolean(attributes, "readOnly", false);
    List<StateOption> channelOptions = null;
    NodeList nodes = (NodeList) context.convertAnother(context, NodeList.class);
    NodeIterator nodeIterator = new NodeIterator(nodes.getList());
    NodeList optionNodes = (NodeList) nodeIterator.next();
    if (optionNodes != null) {
        channelOptions = toListOfChannelState(optionNodes);
    }
    nodeIterator.assertEndOfType();
    StateDescription stateDescription = new StateDescription(minimum, maximum, step, pattern, readOnly, channelOptions);
    return stateDescription;
}
Also used : NodeIterator(org.eclipse.smarthome.config.xml.util.NodeIterator) NodeList(org.eclipse.smarthome.config.xml.util.NodeList) BigDecimal(java.math.BigDecimal) StateOption(org.eclipse.smarthome.core.types.StateOption) StateDescription(org.eclipse.smarthome.core.types.StateDescription)

Aggregations

NodeIterator (org.eclipse.smarthome.config.xml.util.NodeIterator)2 NodeList (org.eclipse.smarthome.config.xml.util.NodeList)2 BigDecimal (java.math.BigDecimal)1 EventDescription (org.eclipse.smarthome.core.types.EventDescription)1 EventOption (org.eclipse.smarthome.core.types.EventOption)1 StateDescription (org.eclipse.smarthome.core.types.StateDescription)1 StateOption (org.eclipse.smarthome.core.types.StateOption)1