当前位置: 首页>>代码示例>>Java>>正文


Java State.equals方法代码示例

本文整理汇总了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);

}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:31,代码来源:StatefulHandlerCallback.java

示例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);

}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:31,代码来源:StatefulHandlerCallback.java

示例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);
            }
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:22,代码来源:SqueezeBoxPlayerHandler.java

示例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);
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:63,代码来源:AutelisHandler.java


注:本文中的org.eclipse.smarthome.core.types.State.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。