org.eclipse.smarthome.core.items.Item.getStateDescription()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中org.eclipse.smarthome.core.items.Item.getStateDescription()方法的一些代码示例,展示了Item.getStateDescription()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Item.getStateDescription()方法的具体详情如下:
包路径:org.eclipse.smarthome.core.items.Item
类名称:Item
方法名:getStateDescription

Item.getStateDescription介绍

[英]Returns the first provided state description (uses the default locale). If options are defined on the channel, they are included in the returned state description.
[中]返回第一个提供的状态描述(使用默认区域设置)。如果在通道上定义了选项,则它们将包含在返回状态描述中。

代码示例

代码示例来源:origin: org.eclipse.smarthome.core/org.eclipse.smarthome.core.semantics

/**
 * Determines the semantic entity type of an item, i.e. a sub-type of Location, Equipment or Point.
 *
 * @param item the item to get the semantic type for
 * @return a sub-type of Location, Equipment or Point
 */
@Nullable
public static Class<? extends Tag> getSemanticType(Item item) {
  Set<String> tags = item.getTags();
  for (String tag : tags) {
    Class<? extends Tag> type = getById(tag);
    if (type != null && !Property.class.isAssignableFrom(type)) {
      return type;
    }
  }
  // we haven't found any type as a tag, but if there is a Property tag, we can conclude that it is a Point
  if (getProperty(item) != null) {
    StateDescription stateDescription = item.getStateDescription();
    if (stateDescription != null && stateDescription.isReadOnly()) {
      return Measurement.class;
    } else {
      return Control.class;
    }
  } else {
    return null;
  }
}

代码示例来源:origin: openhab/openhab-core

/**
 * Determines the semantic entity type of an item, i.e. a sub-type of Location, Equipment or Point.
 *
 * @param item the item to get the semantic type for
 * @return a sub-type of Location, Equipment or Point
 */
@Nullable
public static Class<? extends Tag> getSemanticType(Item item) {
  Set<String> tags = item.getTags();
  for (String tag : tags) {
    Class<? extends Tag> type = getById(tag);
    if (type != null && !Property.class.isAssignableFrom(type)) {
      return type;
    }
  }
  // we haven't found any type as a tag, but if there is a Property tag, we can conclude that it is a Point
  if (getProperty(item) != null) {
    StateDescription stateDescription = item.getStateDescription();
    if (stateDescription != null && stateDescription.isReadOnly()) {
      return Measurement.class;
    } else {
      return Control.class;
    }
  } else {
    return null;
  }
}

代码示例来源:origin: openhab/openhab-core

transformedState = null;
StateDescription stateDescription = considerTransformation(item.getStateDescription(locale));
String link = null != uri ? uri.toASCIIString() + ItemResource.PATH_ITEMS + "/" + itemDTO.name : null;

代码示例来源:origin: openhab/openhab-core

private static String considerTransformation(String state, Item item, Locale locale) {
    StateDescription stateDescription = item.getStateDescription(locale);
    if (stateDescription != null && stateDescription.getPattern() != null && state != null) {
      try {
        return TransformationHelper.transform(RESTCoreActivator.getBundleContext(),
            stateDescription.getPattern(), state.toString());
      } catch (NoClassDefFoundError ex) {
        // TransformationHelper is optional dependency, so ignore if class not found
        // return state as it is without transformation
        return state;
      } catch (TransformationException e) {
        LOGGER.warn("Failed transforming the state '{}' on item '{}' with pattern '{}': {}", state,
            item.getName(), stateDescription.getPattern(), e.getMessage());
        return state;
      }
    } else {
      return state;
    }
  }
}

代码示例来源:origin: org.eclipse.smarthome.ui/org.eclipse.smarthome.ui

stateDescription = item.getStateDescription();
if (formatPattern == null) {
  if (stateDescription != null) {

代码示例来源:origin: openhab/openhab-core

stateDescription = item.getStateDescription();
if (formatPattern == null && stateDescription != null && stateDescription.getPattern() != null) {
  label = label + " [" + stateDescription.getPattern() + "]";

相关文章