2 * Copyright (c) 2010-2022 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
36 * @throws SVDRPParseResponseException thrown if response data is not parseable
38 public static SVDRPTimerList parse(String message) {
39 SVDRPTimerList timers = new SVDRPTimerList();
40 List<String> lines = new ArrayList<String>();
42 StringTokenizer st = new StringTokenizer(message, System.lineSeparator());
43 while (st.hasMoreTokens()) {
44 String timer = st.nextToken();
47 timers.setTimers(lines);
52 * Is there currently an active Recording on SVDRP Client
54 * @return returns true if there is an active recording
56 public boolean isRecordingActive() {
57 for (String line : timers) {
58 String timerContent = line.substring(line.indexOf(" ") + 1);
59 String timerStatus = timerContent.substring(0, timerContent.indexOf(":"));
60 byte b = Byte.parseByte(timerStatus);
61 if (((b >> 3) & 0x0001) == 1) {
69 * Set timers object of SVDRPTimerList
71 * @param timers timers to set
73 private void setTimers(List<String> timers) {