mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
fixed potential StringIndexOutOfBoundsExceptions (#14000)
fixed compiler warnings Signed-off-by: Michael Weger <weger.michael@gmx.net>
This commit is contained in:
parent
debdfa5f8b
commit
6dd8cd52c5
@ -268,7 +268,7 @@ public class AirqHandler extends BaseThingHandler {
|
||||
break;
|
||||
case "logLevel":
|
||||
String ll = command.toString();
|
||||
if (ll.equals("Error") || ll.equals("Warning") || ll.equals("Info")) {
|
||||
if ("Error".equals(ll) || "Warning".equals(ll) || "Info".equals(ll)) {
|
||||
newobj.addProperty("logging", ll);
|
||||
changeSettings(newobj);
|
||||
} else {
|
||||
@ -288,7 +288,7 @@ public class AirqHandler extends BaseThingHandler {
|
||||
break;
|
||||
case "powerFreqSuppression":
|
||||
String newFreq = command.toString();
|
||||
if (newFreq.equals("50Hz") || newFreq.equals("60Hz") || newFreq.equals("50Hz+60Hz")) {
|
||||
if ("50Hz".equals(newFreq) || "60Hz".equals(newFreq) || "50Hz+60Hz".equals(newFreq)) {
|
||||
newobj.addProperty("Rejection", newFreq);
|
||||
changeSettings(newobj);
|
||||
} else {
|
||||
@ -710,7 +710,12 @@ public class AirqHandler extends BaseThingHandler {
|
||||
for (JsonElement el : arr) {
|
||||
str.append(el.getAsString() + ", ");
|
||||
}
|
||||
updateState(channelName, new StringType(str.substring(0, str.length() - 2)));
|
||||
if (str.length() >= 2) {
|
||||
updateState(channelName, new StringType(str.substring(0, str.length() - 2)));
|
||||
} else {
|
||||
logger.trace("air-Q - airqHandler - processType(): cannot handle this as an array: {}",
|
||||
jsonarr);
|
||||
}
|
||||
} else {
|
||||
logger.warn("air-Q - airqHandler - processType(): cannot handle this as an array: {}", jsonarr);
|
||||
}
|
||||
@ -730,7 +735,13 @@ public class AirqHandler extends BaseThingHandler {
|
||||
str = str + attributeName + ": offset=" + attributeValue.get("offset").getAsString() + " ["
|
||||
+ timecalibString + "]";
|
||||
}
|
||||
updateState(channelName, new StringType(str.substring(0, str.length() - 1)));
|
||||
if (!str.isEmpty()) {
|
||||
updateState(channelName, new StringType(str.substring(0, str.length() - 1)));
|
||||
} else {
|
||||
logger.trace(
|
||||
"air-Q - airqHandler - processType(): Cannot extract calibration data from this string: {}",
|
||||
dec.get(airqName).toString());
|
||||
}
|
||||
} else {
|
||||
logger.warn(
|
||||
"air-Q - airqHandler - processType(): Cannot extract calibration data from this string: {}",
|
||||
@ -749,9 +760,14 @@ public class AirqHandler extends BaseThingHandler {
|
||||
for (JsonElement el : arr) {
|
||||
arrstr = arrstr + el.getAsString() + ", ";
|
||||
}
|
||||
logger.trace("air-Q - airqHandler - processType(): property array {} set to {}", channelName,
|
||||
arrstr.substring(0, arrstr.length() - 2));
|
||||
getThing().setProperty(channelName, arrstr.substring(0, arrstr.length() - 2));
|
||||
if (arrstr.length() >= 2) {
|
||||
logger.trace("air-Q - airqHandler - processType(): property array {} set to {}",
|
||||
channelName, arrstr.substring(0, arrstr.length() - 2));
|
||||
getThing().setProperty(channelName, arrstr.substring(0, arrstr.length() - 2));
|
||||
} else {
|
||||
logger.trace("air-Q - airqHandler - processType(): cannot handle this as an array: {}",
|
||||
proparr);
|
||||
}
|
||||
} else {
|
||||
logger.warn("air-Q - airqHandler - processType(): cannot handle this as an array: {}", proparr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user