本文整理汇总了Java中org.eclipse.smarthome.core.types.State.equals方法的典型用法代码示例。如果您正苦于以下问题:Java State.equals方法的具体用法?Java State.equals怎么用?Java State.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.smarthome.core.types.State
的用法示例。
在下文中一共展示了State.equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stateChanged
import org.eclipse.smarthome.core.types.State; //导入方法依赖的package包/类
/**
* Overrides the state changed to determine if the state is new or changed and then
* to call the {@link #_wrappedCallback} if it has
*
* @param channelId the channel id that changed
* @param state the new state
*/
@Override
public void stateChanged(String channelId, State state) {
if (StringUtils.isEmpty(channelId)) {
return;
}
final State oldState = _state.get(channelId);
// If both null OR the same value (enums), nothing changed
if (oldState == state) {
return;
}
// If they are equal - nothing changed
if (oldState != null && oldState.equals(state)) {
return;
}
// Something changed - save the new state and call the underlying wrapped
_state.put(channelId, state);
_wrappedCallback.stateChanged(channelId, state);
}
示例2: stateChanged
import org.eclipse.smarthome.core.types.State; //导入方法依赖的package包/类
/**
* Overrides the state changed to determine if the state is new or changed and then
* to call the {@link #wrappedCallback} if it has
*
* @param channelId the channel id that changed
* @param newState the new state
*/
@Override
public void stateChanged(String channelId, State newState) {
if (StringUtils.isEmpty(channelId)) {
return;
}
final State oldState = state.get(channelId);
// If both null OR the same value (enums), nothing changed
if (oldState == newState) {
return;
}
// If they are equal - nothing changed
if (oldState != null && oldState.equals(newState)) {
return;
}
// Something changed - save the new state and call the underlying wrapped
state.put(channelId, newState);
wrappedCallback.stateChanged(channelId, newState);
}
示例3: updateChannel
import org.eclipse.smarthome.core.types.State; //导入方法依赖的package包/类
/**
* Update a channel if the mac matches our own
*
* @param mac
* @param channelID
* @param state
*/
private void updateChannel(String mac, String channelID, State state) {
if (isMe(mac)) {
State prevState = stateMap.put(channelID, state);
if (prevState == null || !prevState.equals(state)) {
logger.trace("Updating channel {} for thing {} with mac {} to state {}", channelID, getThing().getUID(),
mac, state);
try {
updateState(channelID, state);
} catch (Exception e) {
logger.error("Could not update channel", e);
}
}
}
}
示例4: execute
import org.eclipse.smarthome.core.types.State; //导入方法依赖的package包/类
/**
* The polling future executes this every iteration
*/
protected void execute() {
logger.trace("Connecting to {}", baseURL);
clearState(false);
// we will reconstruct the document with all the responses combined for
// XPATH
StringBuilder sb = new StringBuilder("<response>");
// pull down the three xml documents
String[] statuses = { "status", "chem", "pumps" };
for (String status : statuses) {
String response = getUrl(baseURL + "/" + status + ".xml", TIMEOUT);
logger.trace("{}/{}.xml \n {}", baseURL, status, response);
if (response == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR);
return;
}
// get the xml data between the response tags and append to our main
// doc
Matcher m = responsePattern.matcher(response);
if (m.find()) {
sb.append(m.group(1));
}
}
// finish our "new" XML Document
sb.append("</response>");
if (!getThing().getStatus().equals(ThingStatus.ONLINE)) {
updateStatus(ThingStatus.ONLINE);
}
/*
* This xmlDoc will now contain the three XML documents we retrieved
* wrapped in response tags for easier querying in XPath.
*/
String xmlDoc = sb.toString();
for (Channel channel : getThing().getChannels()) {
String key = channel.getUID().getId().replace('-', '/');
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
try {
InputSource is = new InputSource(new StringReader(xmlDoc));
String value = xpath.evaluate("response/" + key, is);
if (StringUtils.isEmpty((value))) {
continue;
}
State state = toState(channel.getAcceptedItemType(), value);
State oldState = stateMap.put(channel.getUID().getAsString(), state);
if (!state.equals(oldState)) {
logger.trace("updating channel {} with state {}", channel, state);
updateState(channel.getUID(), state);
}
} catch (XPathExpressionException e) {
logger.error("could not parse xml", e);
}
}
}