Java Code Examples for org.eclipse.smarthome.core.library.types.StringType#toString()

The following examples show how to use org.eclipse.smarthome.core.library.types.StringType#toString() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
 * Transforms the given {@link StringType} into a light state containing the {@link AlertMode} to be triggered.
 * @param alertType {@link StringType} representing the required {@link AlertMode} . <br>
 *            Supported values are:
 *            <ul>
 *            <li>{@value #ALERT_MODE_NONE}.
 *            <li>{@value #ALERT_MODE_SELECT}.
 *            <li>{@value #ALERT_MODE_LONG_SELECT}.
 *            <ul>
 * @return light state containing the {@link AlertMode} or <b><code>null </code></b> if the provided
 *         {@link StringType} represents unsupported mode.
public static @Nullable StateUpdate toAlertState(StringType alertType) {
    AlertMode alertMode;

    switch (alertType.toString()) {
        case ALERT_MODE_NONE:
            alertMode = State.AlertMode.NONE;
        case ALERT_MODE_SELECT:
            alertMode = State.AlertMode.SELECT;
            alertMode = State.AlertMode.LSELECT;
            return null;
    return new StateUpdate().setAlert(alertMode);
Example 2
protected Object toBinding(StringType type, HmDatapoint dp) throws ConverterException {
    if (dp.isStringType()) {
        return type.toString();
    } else {
        int idx = dp.getOptionIndex(type.toString());
        if (idx == -1) {
            throw new ConverterException(String.format("Option value '%s' not found in datapoint '%s'",
                    type.toString(), new HmDatapointInfo(dp)));
        return idx;