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;
|
break;
|
||||||
case "logLevel":
|
case "logLevel":
|
||||||
String ll = command.toString();
|
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);
|
newobj.addProperty("logging", ll);
|
||||||
changeSettings(newobj);
|
changeSettings(newobj);
|
||||||
} else {
|
} else {
|
||||||
|
@ -288,7 +288,7 @@ public class AirqHandler extends BaseThingHandler {
|
||||||
break;
|
break;
|
||||||
case "powerFreqSuppression":
|
case "powerFreqSuppression":
|
||||||
String newFreq = command.toString();
|
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);
|
newobj.addProperty("Rejection", newFreq);
|
||||||
changeSettings(newobj);
|
changeSettings(newobj);
|
||||||
} else {
|
} else {
|
||||||
|
@ -710,7 +710,12 @@ public class AirqHandler extends BaseThingHandler {
|
||||||
for (JsonElement el : arr) {
|
for (JsonElement el : arr) {
|
||||||
str.append(el.getAsString() + ", ");
|
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 {
|
} else {
|
||||||
logger.warn("air-Q - airqHandler - processType(): cannot handle this as an array: {}", jsonarr);
|
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() + " ["
|
str = str + attributeName + ": offset=" + attributeValue.get("offset").getAsString() + " ["
|
||||||
+ timecalibString + "]";
|
+ 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 {
|
} else {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"air-Q - airqHandler - processType(): Cannot extract calibration data from this string: {}",
|
"air-Q - airqHandler - processType(): Cannot extract calibration data from this string: {}",
|
||||||
|
@ -749,9 +760,14 @@ public class AirqHandler extends BaseThingHandler {
|
||||||
for (JsonElement el : arr) {
|
for (JsonElement el : arr) {
|
||||||
arrstr = arrstr + el.getAsString() + ", ";
|
arrstr = arrstr + el.getAsString() + ", ";
|
||||||
}
|
}
|
||||||
logger.trace("air-Q - airqHandler - processType(): property array {} set to {}", channelName,
|
if (arrstr.length() >= 2) {
|
||||||
arrstr.substring(0, arrstr.length() - 2));
|
logger.trace("air-Q - airqHandler - processType(): property array {} set to {}",
|
||||||
getThing().setProperty(channelName, arrstr.substring(0, arrstr.length() - 2));
|
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 {
|
} else {
|
||||||
logger.warn("air-Q - airqHandler - processType(): cannot handle this as an array: {}", proparr);
|
logger.warn("air-Q - airqHandler - processType(): cannot handle this as an array: {}", proparr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue