Rework more commons-lang usages (#10314)
* Reworks many commons-lang usages to use standard Java * Updates all remaining commons.lang imports to commons.lang3 Related to openhab/openhab-addons#7722 Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -12,8 +12,6 @@
|
||||
*/
|
||||
package org.openhab.binding.hdanywhere.internal.handler;
|
||||
|
||||
import static org.apache.commons.lang.StringUtils.isNotBlank;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -93,27 +91,25 @@ public class Mhub4K431Handler extends BaseThingHandler {
|
||||
String content = "{tag:ptn}";
|
||||
InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
if (isNotBlank(httpMethod) && isNotBlank(url)) {
|
||||
String response = HttpUtil.executeUrl(httpMethod, url, null, stream, null, timeout);
|
||||
response = response.trim();
|
||||
response = response.substring(1, response.length() - 1);
|
||||
String response = HttpUtil.executeUrl(httpMethod, url, null, stream, null, timeout);
|
||||
response = response.trim();
|
||||
response = response.substring(1, response.length() - 1);
|
||||
|
||||
if (response != null) {
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
if (response != null) {
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
|
||||
java.lang.reflect.Type type = new TypeToken<Map<String, String>>() {
|
||||
}.getType();
|
||||
Map<String, String> map = gson.fromJson(response, type);
|
||||
java.lang.reflect.Type type = new TypeToken<Map<String, String>>() {
|
||||
}.getType();
|
||||
Map<String, String> map = gson.fromJson(response, type);
|
||||
|
||||
String inputChannel = map.get("Inputchannel");
|
||||
String inputChannel = map.get("Inputchannel");
|
||||
|
||||
for (int i = 0; i < numberOfPorts; i++) {
|
||||
DecimalType decimalType = new DecimalType(String.valueOf(inputChannel.charAt(i)));
|
||||
updateState(new ChannelUID(getThing().getUID(), Port.get(i + 1).channelID()), decimalType);
|
||||
}
|
||||
} else {
|
||||
updateStatus(ThingStatus.OFFLINE);
|
||||
for (int i = 0; i < numberOfPorts; i++) {
|
||||
DecimalType decimalType = new DecimalType(String.valueOf(inputChannel.charAt(i)));
|
||||
updateState(new ChannelUID(getThing().getUID(), Port.get(i + 1).channelID()), decimalType);
|
||||
}
|
||||
} else {
|
||||
updateStatus(ThingStatus.OFFLINE);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.debug("An exception occurred while polling the HDanwywhere matrix: '{}'", e.getMessage());
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
*/
|
||||
package org.openhab.binding.hdanywhere.internal.handler;
|
||||
|
||||
import static org.apache.commons.lang.StringUtils.isNotBlank;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@@ -69,24 +67,22 @@ public class MultiroomPlusHandler extends BaseThingHandler {
|
||||
String httpMethod = "GET";
|
||||
String url = "http://" + host + "/status_show.shtml";
|
||||
|
||||
if (isNotBlank(httpMethod) && isNotBlank(url)) {
|
||||
String response = HttpUtil.executeUrl(httpMethod, url, null, null, null, timeout);
|
||||
String response = HttpUtil.executeUrl(httpMethod, url, null, null, null, timeout);
|
||||
|
||||
if (response != null) {
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
if (response != null) {
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
|
||||
for (int i = 1; i <= numberOfPorts; i++) {
|
||||
Pattern p = Pattern.compile("var out" + i + "var = (.*);");
|
||||
Matcher m = p.matcher(response);
|
||||
for (int i = 1; i <= numberOfPorts; i++) {
|
||||
Pattern p = Pattern.compile("var out" + i + "var = (.*);");
|
||||
Matcher m = p.matcher(response);
|
||||
|
||||
while (m.find()) {
|
||||
DecimalType decimalType = new DecimalType(m.group(1));
|
||||
updateState(new ChannelUID(getThing().getUID(), Port.get(i).channelID()), decimalType);
|
||||
}
|
||||
while (m.find()) {
|
||||
DecimalType decimalType = new DecimalType(m.group(1));
|
||||
updateState(new ChannelUID(getThing().getUID(), Port.get(i).channelID()), decimalType);
|
||||
}
|
||||
} else {
|
||||
updateStatus(ThingStatus.OFFLINE);
|
||||
}
|
||||
} else {
|
||||
updateStatus(ThingStatus.OFFLINE);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("An exception occurred while polling the HDanwywhere matrix: '{}'", e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user