From 4e88f48a7149e0cdba1e4fe920eff47aa1048b02 Mon Sep 17 00:00:00 2001 From: lsiepel Date: Thu, 9 Jan 2025 12:07:50 +0100 Subject: [PATCH] [tacmi] Fix SAT errors (#18046) Signed-off-by: Leo Siepel --- .../tacmi/internal/schema/ApiPageParser.java | 17 +++++++++-------- .../tacmi/internal/schema/ChangerX2Parser.java | 8 ++++---- .../internal/schema/TACmiSchemaHandler.java | 4 ++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ApiPageParser.java b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ApiPageParser.java index c9e00e65853..44bcd7badcc 100644 --- a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ApiPageParser.java +++ b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ApiPageParser.java @@ -185,6 +185,7 @@ public class ApiPageParser extends AbstractSimpleMarkupHandler { } else if ("durchsichtig".equals(classFlag)) { // link this.fieldType = FieldType.IGNORE; } else if ("bord".equals(classFlag)) { // special button style - not of our interest... + continue; } else { logger.debug("Unhanndled class in {}:{}:{}: '{}' ", id, line, col, classFlag); } @@ -192,7 +193,7 @@ public class ApiPageParser extends AbstractSimpleMarkupHandler { } } else if (this.parserState == ParserState.DATA_ENTRY && this.fieldType == FieldType.BUTTON && "span".equals(elementName)) { - // ignored... + return; // ignored... } else { logger.debug("Unexpected OpenElement in {}:{}: {} [{}]", line, col, elementName, attributes); } @@ -245,14 +246,14 @@ public class ApiPageParser extends AbstractSimpleMarkupHandler { getApiPageEntry(id, line, col, shortName, description, this.buttonValue); } } else if (this.fieldType == FieldType.IGNORE) { - // ignore + return; // ignore } else { logger.debug("Unhandled setting {}:{}:{} [{}] : {}", id, line, col, this.fieldType, sb); } } } else if (this.parserState == ParserState.DATA_ENTRY && this.fieldType == FieldType.BUTTON && "span".equals(elementName)) { - // ignored... + return;// ignored... } else { logger.debug("Unexpected CloseElement in {}:{}: {}", line, col, elementName); } @@ -307,7 +308,7 @@ public class ApiPageParser extends AbstractSimpleMarkupHandler { } } else if (this.parserState == ParserState.INIT && ((len == 1 && buffer[offset] == '\n') || (len == 2 && buffer[offset] == '\r' && buffer[offset + 1] == '\n'))) { - // single newline - ignore/drop it... + return; // single newline - ignore/drop it... } else { String msg = new String(buffer, offset, len).replace("\n", "\\n").replace("\r", "\\r"); logger.debug("Unexpected Text {}:{}: ParserState: {} ({}) `{}`", line, col, parserState, len, msg); @@ -400,9 +401,9 @@ public class ApiPageParser extends AbstractSimpleMarkupHandler { // failed to get unit... if ("Imp".equals(unitStr) || "€$".contains(unitStr)) { // special case - unitData = taCmiSchemaHandler.SPECIAL_MARKER; + unitData = TACmiSchemaHandler.SPECIAL_MARKER; } else { - unitData = taCmiSchemaHandler.NULL_MARKER; + unitData = TACmiSchemaHandler.NULL_MARKER; logger.warn( "Unhandled UoM '{}' - seen on channel {} '{}'; Message from QuantityType: {}", valParts[1], shortName, description, iae.getMessage()); @@ -410,12 +411,12 @@ public class ApiPageParser extends AbstractSimpleMarkupHandler { } taCmiSchemaHandler.unitsCache.put(unitStr, unitData); } - if (unitData == taCmiSchemaHandler.NULL_MARKER) { + if (unitData == TACmiSchemaHandler.NULL_MARKER) { // no UoM mappable - just send value channelType = "Number"; unit = null; state = new DecimalType(bd); - } else if (unitData == taCmiSchemaHandler.SPECIAL_MARKER) { + } else if (unitData == TACmiSchemaHandler.SPECIAL_MARKER) { // special handling for unknown UoM if ("Imp".equals(unitStr)) { // Number of Pulses // impulses - no idea how to map this to something useful here? diff --git a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ChangerX2Parser.java b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ChangerX2Parser.java index c50de9bacfe..ee9bbc45df2 100644 --- a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ChangerX2Parser.java +++ b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ChangerX2Parser.java @@ -102,7 +102,7 @@ public class ChangerX2Parser extends AbstractSimpleMarkupHandler { this.optionFieldName = attributes == null ? null : attributes.get("name"); } else if ((this.parserState == ParserState.INIT || this.parserState == ParserState.INPUT) && "br".equals(elementName)) { - // ignored + return; // ignored } else if ((this.parserState == ParserState.INIT || this.parserState == ParserState.INPUT) && "input".equals(elementName) && "changeto".equals(id)) { this.parserState = ParserState.INPUT_DATA; @@ -171,7 +171,6 @@ public class ChangerX2Parser extends AbstractSimpleMarkupHandler { } this.options.put(ChangerX2Entry.TIME_PERIOD_PARTS, timeParts); } else { - logger.warn("Error parsing options for {}: Unhandled input field in {}:{}: {}", channelName, line, col, attributes); } @@ -218,7 +217,7 @@ public class ChangerX2Parser extends AbstractSimpleMarkupHandler { } } } else if (this.parserState == ParserState.INPUT && "span".equals(elementName)) { - // span's are ignored... + return; // span's are ignored... } else { logger.debug("Error parsing options for {}: Unexpected CloseElement in {}:{}: {}", channelName, line, col, elementName); @@ -275,10 +274,11 @@ public class ChangerX2Parser extends AbstractSimpleMarkupHandler { sb.append(buffer, offset, len); } } else if (this.parserState == ParserState.INIT && len == 1 && buffer[offset] == '\n') { - // single newline - ignore/drop it... + return; // single newline - ignore/drop it... } else if (this.parserState == ParserState.INPUT) { // this is a label next to the value input field - we currently have no use for it so // it's dropped... + return; } else { logger.debug("Error parsing options for {}: Unexpected Text {}:{}: (ctx: {} len: {}) '{}' ", this.channelName, line, col, this.parserState, len, new String(buffer, offset, len)); diff --git a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/TACmiSchemaHandler.java b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/TACmiSchemaHandler.java index 7bc0d7b85b3..bec455e4c43 100644 --- a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/TACmiSchemaHandler.java +++ b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/TACmiSchemaHandler.java @@ -90,9 +90,9 @@ public class TACmiSchemaHandler extends BaseThingHandler { // this is the units lookup cache. protected final Map unitsCache = new ConcurrentHashMap<>(); // marks an entry with known un-resolveable unit - protected final UnitAndType NULL_MARKER = new UnitAndType(Units.ONE, ""); + protected static final UnitAndType NULL_MARKER = new UnitAndType(Units.ONE, ""); // marks an entry with special handling - i.e. 'Imp' - protected final UnitAndType SPECIAL_MARKER = new UnitAndType(Units.ONE, "s"); + protected static final UnitAndType SPECIAL_MARKER = new UnitAndType(Units.ONE, "s"); public TACmiSchemaHandler(final Thing thing, final HttpClient httpClient, final TACmiChannelTypeProvider channelTypeProvider) {