2 * Copyright (c) 2010-2024 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.vdr.internal.svdrp;
15 import java.util.ArrayList;
16 import java.util.List;
17 import java.util.StringTokenizer;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
22 * The {@link SVDRPTimerList} contains SVDRP Response Data for a Timer list
24 * @author Matthias Klocke - Initial contribution
27 public class SVDRPTimerList {
29 private List<String> timers = new ArrayList<String>();
32 * parse object from SVDRP Client Response
34 * @param message SVDRP Client Response
35 * @return Timer List Object
37 public static SVDRPTimerList parse(String message) {
38 SVDRPTimerList timers = new SVDRPTimerList();
39 List<String> lines = new ArrayList<String>();
41 StringTokenizer st = new StringTokenizer(message, System.lineSeparator());
42 while (st.hasMoreTokens()) {
43 String timer = st.nextToken();
46 timers.setTimers(lines);
51 * Is there currently an active Recording on SVDRP Client
53 * @return returns true if there is an active recording
55 public boolean isRecordingActive() {
56 for (String line : timers) {
57 String timerContent = line.substring(line.indexOf(" ") + 1);
58 String timerStatus = timerContent.substring(0, timerContent.indexOf(":"));
59 byte b = Byte.parseByte(timerStatus);
60 if (((b >> 3) & 0x0001) == 1) {
68 * Set timers object of SVDRPTimerList
70 * @param timers timers to set
72 private void setTimers(List<String> timers) {