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;
}
Aggregations