]> git.basschouten.com Git - openhab-addons.git/blob
d79470e4d7e3af28a899020a8ec7ec9a4d0aac0f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.lcn.internal.connection;
14
15 import java.io.IOException;
16 import java.io.OutputStream;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.lcn.internal.common.LcnDefs;
20 import org.openhab.binding.lcn.internal.common.PckGenerator;
21
22 /**
23  * A plain text to be send to LCN-PCHK.
24  *
25  * @author Tobias Jüttner - Initial Contribution
26  * @author Fabian Wolter - Migration to OH2
27  */
28 @NonNullByDefault
29 class SendDataPlainText extends SendData {
30     /** The text. */
31     private final String text;
32
33     /**
34      * Constructor.
35      *
36      * @param text the text
37      */
38     SendDataPlainText(String text) {
39         this.text = text;
40     }
41
42     /**
43      * Gets the text.
44      *
45      * @return the text
46      */
47     String getText() {
48         return this.text;
49     }
50
51     @Override
52     boolean write(OutputStream buffer, int localSegId) throws IOException {
53         buffer.write((this.text + PckGenerator.TERMINATION).getBytes(LcnDefs.LCN_ENCODING));
54         return true;
55     }
56
57     @Override
58     public String toString() {
59         return text;
60     }
61 }