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.kodi.internal.model;
15 import java.util.regex.Matcher;
16 import java.util.regex.Pattern;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
22 * Class representing a Kodi favorite.
24 * @author Christoph Weitkamp - Initial contribution
27 public class KodiFavorite {
28 // handle titles which are wrapped e.g. [COLOR FFE95E01]Title[/COLOR]
29 private static final Pattern TITLE_PATTERN = Pattern.compile("(\\[COLOR\\s\\w{8}\\])|(\\[/COLOR\\])");
32 * The title of the favorite
37 * The type of the favorite
39 private String favoriteType = "unknown";
42 * The path of the favorite
48 * The window of the favorite
51 private String window;
54 * The parameters of the favorites window
57 private String windowParameter;
60 * Constructs a favorite with the given title.
62 * @param title title of the favorite
64 public KodiFavorite(final String title) {
69 * Returns the title of the favorite.
71 * @return the title of the favorite
73 public String getTitle() {
78 * Sets the title of the favorite.
80 * @param title title of the favorite
82 public void setTitle(final String title) {
83 Matcher m = TITLE_PATTERN.matcher(title);
84 this.title = m.replaceAll("");
88 * Returns the type of the favorite.
90 * @return the type of the favorite
92 public String getFavoriteType() {
97 * Sets the type of the favorite.
99 * @param favoriteType type of the favorite. Valid values are: "media", "window", "script" or "unknown"
101 public void setFavoriteType(final String favoriteType) {
102 this.favoriteType = favoriteType;
106 * Returns the path of the favorite.
108 * @return the path of the favorite
111 public String getPath() {
116 * Sets the path of the favorite.
118 * @param path path of the favorite
120 public void setPath(final String path) {
125 * Returns the window of the favorite.
127 * @return the window of the favorite
130 public String getWindow() {
135 * Sets the window of the favorite.
137 * @param window the window of the favorite
139 public void setWindow(final String window) {
140 this.window = window;
144 * Returns the parameters of the favorites window.
146 * @return the parameters of the favorites window
149 public String getWindowParameter() {
150 return windowParameter;
154 * Sets the parameters of the favorites window.
156 * @param windowParameter the parameters of the favorites window
158 public void setWindowParameter(final String windowParameter) {
159 this.windowParameter = windowParameter;