Skip to content

Commit 4e88f48

Browse files
authored
[tacmi] Fix SAT errors (openhab#18046)
Signed-off-by: Leo Siepel <[email protected]>
1 parent e69c44b commit 4e88f48

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ApiPageParser.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,15 @@ public void handleOpenElement(final @Nullable String elementName, final @Nullabl
185185
} else if ("durchsichtig".equals(classFlag)) { // link
186186
this.fieldType = FieldType.IGNORE;
187187
} else if ("bord".equals(classFlag)) { // special button style - not of our interest...
188+
continue;
188189
} else {
189190
logger.debug("Unhanndled class in {}:{}:{}: '{}' ", id, line, col, classFlag);
190191
}
191192
}
192193
}
193194
} else if (this.parserState == ParserState.DATA_ENTRY && this.fieldType == FieldType.BUTTON
194195
&& "span".equals(elementName)) {
195-
// ignored...
196+
return; // ignored...
196197
} else {
197198
logger.debug("Unexpected OpenElement in {}:{}: {} [{}]", line, col, elementName, attributes);
198199
}
@@ -245,14 +246,14 @@ public void handleCloseElement(final @Nullable String elementName, final int lin
245246
getApiPageEntry(id, line, col, shortName, description, this.buttonValue);
246247
}
247248
} else if (this.fieldType == FieldType.IGNORE) {
248-
// ignore
249+
return; // ignore
249250
} else {
250251
logger.debug("Unhandled setting {}:{}:{} [{}] : {}", id, line, col, this.fieldType, sb);
251252
}
252253
}
253254
} else if (this.parserState == ParserState.DATA_ENTRY && this.fieldType == FieldType.BUTTON
254255
&& "span".equals(elementName)) {
255-
// ignored...
256+
return;// ignored...
256257
} else {
257258
logger.debug("Unexpected CloseElement in {}:{}: {}", line, col, elementName);
258259
}
@@ -307,7 +308,7 @@ public void handleText(final char @Nullable [] buffer, final int offset, final i
307308
}
308309
} else if (this.parserState == ParserState.INIT && ((len == 1 && buffer[offset] == '\n')
309310
|| (len == 2 && buffer[offset] == '\r' && buffer[offset + 1] == '\n'))) {
310-
// single newline - ignore/drop it...
311+
return; // single newline - ignore/drop it...
311312
} else {
312313
String msg = new String(buffer, offset, len).replace("\n", "\\n").replace("\r", "\\r");
313314
logger.debug("Unexpected Text {}:{}: ParserState: {} ({}) `{}`", line, col, parserState, len, msg);
@@ -400,22 +401,22 @@ private void getApiPageEntry(@Nullable String id2, int line, int col, String sho
400401
// failed to get unit...
401402
if ("Imp".equals(unitStr) || "€$".contains(unitStr)) {
402403
// special case
403-
unitData = taCmiSchemaHandler.SPECIAL_MARKER;
404+
unitData = TACmiSchemaHandler.SPECIAL_MARKER;
404405
} else {
405-
unitData = taCmiSchemaHandler.NULL_MARKER;
406+
unitData = TACmiSchemaHandler.NULL_MARKER;
406407
logger.warn(
407408
"Unhandled UoM '{}' - seen on channel {} '{}'; Message from QuantityType: {}",
408409
valParts[1], shortName, description, iae.getMessage());
409410
}
410411
}
411412
taCmiSchemaHandler.unitsCache.put(unitStr, unitData);
412413
}
413-
if (unitData == taCmiSchemaHandler.NULL_MARKER) {
414+
if (unitData == TACmiSchemaHandler.NULL_MARKER) {
414415
// no UoM mappable - just send value
415416
channelType = "Number";
416417
unit = null;
417418
state = new DecimalType(bd);
418-
} else if (unitData == taCmiSchemaHandler.SPECIAL_MARKER) {
419+
} else if (unitData == TACmiSchemaHandler.SPECIAL_MARKER) {
419420
// special handling for unknown UoM
420421
if ("Imp".equals(unitStr)) { // Number of Pulses
421422
// impulses - no idea how to map this to something useful here?

bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ChangerX2Parser.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void handleOpenElement(final String elementName, final Map<String, String
102102
this.optionFieldName = attributes == null ? null : attributes.get("name");
103103
} else if ((this.parserState == ParserState.INIT || this.parserState == ParserState.INPUT)
104104
&& "br".equals(elementName)) {
105-
// ignored
105+
return; // ignored
106106
} else if ((this.parserState == ParserState.INIT || this.parserState == ParserState.INPUT)
107107
&& "input".equals(elementName) && "changeto".equals(id)) {
108108
this.parserState = ParserState.INPUT_DATA;
@@ -171,7 +171,6 @@ public void handleOpenElement(final String elementName, final Map<String, String
171171
}
172172
this.options.put(ChangerX2Entry.TIME_PERIOD_PARTS, timeParts);
173173
} else {
174-
175174
logger.warn("Error parsing options for {}: Unhandled input field in {}:{}: {}", channelName, line,
176175
col, attributes);
177176
}
@@ -218,7 +217,7 @@ public void handleCloseElement(final @Nullable String elementName, final int lin
218217
}
219218
}
220219
} else if (this.parserState == ParserState.INPUT && "span".equals(elementName)) {
221-
// span's are ignored...
220+
return; // span's are ignored...
222221
} else {
223222
logger.debug("Error parsing options for {}: Unexpected CloseElement in {}:{}: {}", channelName, line, col,
224223
elementName);
@@ -275,10 +274,11 @@ public void handleText(final char @Nullable [] buffer, final int offset, final i
275274
sb.append(buffer, offset, len);
276275
}
277276
} else if (this.parserState == ParserState.INIT && len == 1 && buffer[offset] == '\n') {
278-
// single newline - ignore/drop it...
277+
return; // single newline - ignore/drop it...
279278
} else if (this.parserState == ParserState.INPUT) {
280279
// this is a label next to the value input field - we currently have no use for it so
281280
// it's dropped...
281+
return;
282282
} else {
283283
logger.debug("Error parsing options for {}: Unexpected Text {}:{}: (ctx: {} len: {}) '{}' ",
284284
this.channelName, line, col, this.parserState, len, new String(buffer, offset, len));

bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/TACmiSchemaHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ record UnitAndType(Unit<?> unit, String channelType) {
9090
// this is the units lookup cache.
9191
protected final Map<String, UnitAndType> unitsCache = new ConcurrentHashMap<>();
9292
// marks an entry with known un-resolveable unit
93-
protected final UnitAndType NULL_MARKER = new UnitAndType(Units.ONE, "");
93+
protected static final UnitAndType NULL_MARKER = new UnitAndType(Units.ONE, "");
9494
// marks an entry with special handling - i.e. 'Imp'
95-
protected final UnitAndType SPECIAL_MARKER = new UnitAndType(Units.ONE, "s");
95+
protected static final UnitAndType SPECIAL_MARKER = new UnitAndType(Units.ONE, "s");
9696

9797
public TACmiSchemaHandler(final Thing thing, final HttpClient httpClient,
9898
final TACmiChannelTypeProvider channelTypeProvider) {

0 commit comments

Comments
 (0)