2 * Copyright (c) 2010-2023 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 org.eclipse.jdt.annotation.NonNullByDefault;
18 * The {@link SVDRPChannel} contains SVDRP Response Data for Channels
20 * @author Matthias Klocke - Initial contribution
23 public class SVDRPChannel {
25 private String name = "";
27 private SVDRPChannel() {
31 * parse object from SVDRP Client Response
33 * @param message SVDRP Client Response
34 * @return Channel Object
35 * @throws SVDRPParseResponseException thrown if response data is not parseable
37 public static SVDRPChannel parse(String message) throws SVDRPParseResponseException {
38 String number = message.substring(0, message.indexOf(" "));
39 String name = message.substring(message.indexOf(" ") + 1, message.length());
40 SVDRPChannel channel = new SVDRPChannel();
42 channel.setNumber(Integer.parseInt(number));
43 } catch (NumberFormatException e) {
44 throw new SVDRPParseResponseException(e.getMessage(), e);
46 channel.setName(name);
53 * @return Channel Number
55 public int getNumber() {
62 * @param number Channel Number
64 public void setNumber(int number) {
71 * @return Channel Name
73 public String getName() {
80 * @param name Channel Name
82 public void setName(String name) {
87 * String Representation of SVDRPChannel Object
90 public String toString() {
91 StringBuilder sb = new StringBuilder();
93 sb.append("Number: " + number + System.lineSeparator());
95 sb.append("Name: " + name + System.lineSeparator());