]> git.basschouten.com Git - openhab-addons.git/blob
ef3f82387066ceb536316472d73a815e1d0e820a
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.voice.voicerss.internal;
14
15 import java.util.Locale;
16
17 import org.openhab.core.voice.Voice;
18
19 /**
20  * Implementation of the Voice interface for VoiceRSS. Label is only "default"
21  * as only voice supported.
22  *
23  * @author Jochen Hiller - Initial contribution and API
24  */
25 public class VoiceRSSVoice implements Voice {
26
27     /**
28      * Voice locale
29      */
30     private final Locale locale;
31
32     /**
33      * Voice label
34      */
35     private final String label;
36
37     /**
38      * Constructs a VoiceRSS Voice for the passed data
39      *
40      * @param locale
41      *            The Locale of the voice
42      * @param label
43      *            The label of the voice
44      */
45     public VoiceRSSVoice(Locale locale, String label) {
46         this.locale = locale;
47         this.label = label;
48     }
49
50     /**
51      * Globally unique identifier of the voice.
52      *
53      * @return A String uniquely identifying the voice globally
54      */
55     @Override
56     public String getUID() {
57         return "voicerss:" + locale.toLanguageTag().replaceAll("[^a-zA-Z0-9_]", "");
58     }
59
60     /**
61      * The voice label, used for GUI's or VUI's
62      *
63      * @return The voice label, may not be globally unique
64      */
65     @Override
66     public String getLabel() {
67         return label;
68     }
69
70     /**
71      * @inheritDoc
72      */
73     @Override
74     public Locale getLocale() {
75         return locale;
76     }
77 }