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 java.util.NoSuchElementException;
16 import java.util.StringTokenizer;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
21 * The {@link SVDRPWelcome} contains SVDRP Response Data that is sent after Connection has been established
23 * @author Matthias Klocke - Initial contribution
26 public class SVDRPWelcome {
28 private String version = "";
29 private String charset = "";
30 private String dateAndTime = "";
32 private SVDRPWelcome() {
36 * Parse SVDRPResponse into SVDRPWelcome Object
38 * @param message SVDRP Client Response
39 * Example: VDRHOST SVDRP VideoDiskRecorder 2.4.5; Sat Jan 9 22:28:11 2021; UTF-8
40 * @return Welcome Object
41 * @throws SVDRPParseResponseException thrown if response data is not parseable
43 public static SVDRPWelcome parse(String message) throws SVDRPParseResponseException {
44 SVDRPWelcome welcome = new SVDRPWelcome();
45 StringTokenizer st = new StringTokenizer(message, ";");
47 String hostAndVersion = st.nextToken();
48 String dateAndTime = st.nextToken();
49 String charset = st.nextToken();
50 welcome.setCharset(charset.trim());
51 welcome.setVersion(hostAndVersion.substring(hostAndVersion.lastIndexOf(" ")).trim());
52 welcome.setDateAndTime(dateAndTime.trim());
53 } catch (NoSuchElementException nex) {
54 throw new SVDRPParseResponseException(nex.getMessage(), nex);
62 * @return VDR version String
64 public String getVersion() {
71 * @param version VDR version String
73 public void setVersion(String version) {
74 this.version = version;
82 public String getCharset() {
89 * @param charset VDR charset
91 public void setCharset(String charset) {
92 this.charset = charset;
96 * Get VDR Date and Time String
98 * @return VDR Date and Time String
100 public String getDateAndTime() {
105 * Set VDR Date and Time String
107 * @param dateAndTime VDR Date and Time String
109 public void setDateAndTime(String dateAndTime) {
110 this.dateAndTime = dateAndTime;