* class {@link ZoneControlXML}, {@link InputWithPlayControlXML} and {@link InputWithNavigationControlXML}
* for communication.
*
- * @author David Graeff <david.graeff@web.de>
+ * @author David Graeff - Initial contribution
* @author Tomasz Maruszak - [yamaha] Tuner band selection and preset feature for dual band models (RX-S601D), added
* config object
*/
zoneControl.setVolumeDB(((DecimalType) command).floatValue());
break;
case CHANNEL_VOLUME:
- if (command instanceof DecimalType) {
- zoneControl.setVolume(((DecimalType) command).floatValue());
- } else if (command instanceof IncreaseDecreaseType) {
+ if (command instanceof DecimalType decimalCommand) {
+ zoneControl.setVolume(decimalCommand.floatValue());
+ } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
zoneControl.setVolumeRelative(zoneState,
- (((IncreaseDecreaseType) command) == IncreaseDecreaseType.INCREASE ? 1 : -1)
+ (increaseDecreaseCommand == IncreaseDecreaseType.INCREASE ? 1 : -1)
* zoneConfig.getVolumeRelativeChangeFactor());
}
break;
return;
}
- if (command instanceof DecimalType) {
- inputWithPresetControl.selectItemByPresetNumber(((DecimalType) command).intValue());
- } else if (command instanceof StringType) {
+ if (command instanceof DecimalType decimalCommand) {
+ inputWithPresetControl.selectItemByPresetNumber(decimalCommand.intValue());
+ } else if (command instanceof StringType stringCommand) {
try {
- int v = Integer.valueOf(((StringType) command).toString());
+ int v = Integer.valueOf(stringCommand.toString());
inputWithPresetControl.selectItemByPresetNumber(v);
} catch (NumberFormatException e) {
logger.warn("Provide a number for {}", id);
return;
}
- if (command instanceof PlayPauseType) {
- PlayPauseType t = ((PlayPauseType) command);
+ if (command instanceof PlayPauseType t) {
switch (t) {
case PAUSE:
inputWithPlayControl.pause();
inputWithPlayControl.play();
break;
}
- } else if (command instanceof NextPreviousType) {
- NextPreviousType t = ((NextPreviousType) command);
+ } else if (command instanceof NextPreviousType t) {
switch (t) {
case NEXT:
inputWithPlayControl.nextTrack();
inputWithPlayControl.previousTrack();
break;
}
- } else if (command instanceof DecimalType) {
- int v = ((DecimalType) command).intValue();
+ } else if (command instanceof DecimalType decimalCommand) {
+ int v = decimalCommand.intValue();
if (v < 0) {
inputWithPlayControl.skipREV();
} else if (v > 0) {
inputWithPlayControl.skipFF();
}
- } else if (command instanceof StringType) {
- String v = ((StringType) command).toFullString();
+ } else if (command instanceof StringType stringCommand) {
+ String v = stringCommand.toFullString();
switch (v) {
case "Play":
inputWithPlayControl.play();
} else if (id.equals(grpZone(CHANNEL_SURROUND))) {
updateState(channelUID, new StringType(zoneState.surroundProgram));
} else if (id.equals(grpZone(CHANNEL_SCENE))) {
- // no state updates available
+ logger.debug("No state updates available");
} else if (id.equals(grpZone(CHANNEL_DIALOGUE_LEVEL))) {
updateState(channelUID, new DecimalType(zoneState.dialogueLevel));
} else if (id.equals(grpZone(CHANNEL_HDMI1OUT))) {
stateUpdatable.update();
} catch (IOException e) {
logger.debug("State update error. Changing thing to offline", e);
- updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
+ updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
} catch (ReceivedMessageParseException e) {
String message = e.getMessage();
updateProperty(PROPERTY_LAST_PARSE_ERROR, message != null ? message : "");
private static final Logger LOG = LoggerFactory.getLogger(XMLUtils.class);
// We need a lot of xml parsing. Create a document builder beforehand.
- static final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ static final DocumentBuilderFactory DBF = DocumentBuilderFactory.newInstance();
static Node getNode(Node parent, String[] nodePath, int offset) {
if (parent == null) {
try {
// see https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html
- dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
- dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
- dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
- dbf.setXIncludeAware(false);
- dbf.setExpandEntityReferences(false);
- return dbf.newDocumentBuilder().parse(new InputSource(new StringReader(response)));
+ DBF.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ DBF.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ DBF.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ DBF.setXIncludeAware(false);
+ DBF.setExpandEntityReferences(false);
+ return DBF.newDocumentBuilder().parse(new InputSource(new StringReader(response)));
} catch (SAXException | ParserConfigurationException e) {
throw new ReceivedMessageParseException(e);
}