Search in sources :

Example 1 with NamedValueI

use of org.cdp1802.xpl.NamedValueI in project openhab1-addons by openhab.

the class XplGenericBindingProvider method hasMessage.

/**
     * {@inheritDoc}
     */
@Override
public List<String> hasMessage(xPL_MessageI theMessage) {
    List<String> matching = new ArrayList<String>();
    if (theMessage.getType() != xPL_MessageI.MessageType.COMMAND) {
        // the message must not be is not a xpl-cmnd
        for (String key : bindingConfigs.keySet()) {
            XplBindingConfig config = (XplBindingConfig) bindingConfigs.get(key);
            NamedValuesI theBody = config.Message.getMessageBody();
            if ((theBody != null) && (!theBody.isEmpty()) && (config.Message.getTarget().isBroadcastIdentifier() || config.Message.getTarget().equals(theMessage.getSource())) && config.Message.getSchemaClass().equalsIgnoreCase(theMessage.getSchemaClass()) && config.Message.getSchemaType().equalsIgnoreCase(theMessage.getSchemaType())) {
                boolean bodyMatched = true;
                for (NamedValueI theValue : theBody.getAllNamedValues()) {
                    // iterate through the item body to
                    // see if ...
                    String aKey = theValue.getName();
                    String aValue = theValue.getValue();
                    String bValue = theMessage.getNamedValue(aKey);
                    boolean lineMatched = (bValue != null) && (aKey.equalsIgnoreCase(config.NamedParameter) || aValue.equalsIgnoreCase(bValue));
                    bodyMatched = bodyMatched && lineMatched;
                }
                if (bodyMatched) {
                    matching.add(key);
                }
            }
        }
    }
    return matching;
}
Also used : NamedValueI(org.cdp1802.xpl.NamedValueI) XplBindingConfig(org.openhab.binding.xpl.XplBindingConfig) NamedValuesI(org.cdp1802.xpl.NamedValuesI) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 NamedValueI (org.cdp1802.xpl.NamedValueI)1 NamedValuesI (org.cdp1802.xpl.NamedValuesI)1 XplBindingConfig (org.openhab.binding.xpl.XplBindingConfig)1