1 |
/* |
2 |
* jlscp - a java LinuxSampler control protocol API |
3 |
* |
4 |
* Copyright (C) 2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of jlscp. |
7 |
* |
8 |
* jlscp is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* jlscp is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with jlscp; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
package org.linuxsampler.lscp; |
24 |
|
25 |
import static org.linuxsampler.lscp.Parser.*; |
26 |
|
27 |
/** |
28 |
* |
29 |
* @author Grigor Iliev |
30 |
*/ |
31 |
public class Effect implements Parseable { |
32 |
private int effectId = -1; |
33 |
private String system = null; |
34 |
private String module = null; |
35 |
private String name = null; |
36 |
private String description = ""; |
37 |
|
38 |
/** Creates a new instance of <code>Effect</code> */ |
39 |
public |
40 |
Effect() { } |
41 |
|
42 |
/** |
43 |
* Creates a new instance of <code>Effect</code> and parses the information |
44 |
* about a specific effect described by <code>resultSet</code>. |
45 |
* @param resultSet An array with information categories about an effect entity. |
46 |
* @throws LscpException If the parse fail. |
47 |
*/ |
48 |
public |
49 |
Effect(String[] resultSet) throws LscpException { |
50 |
for(String s : resultSet) |
51 |
if(!parse(s)) Client.getLogger().info(LscpI18n.getLogMsg("unknownLine", s)); |
52 |
} |
53 |
|
54 |
/** |
55 |
* Gets the numerical ID of this effect. |
56 |
* @return The numerical ID of this effect |
57 |
* or -1 if the effect ID is not set. |
58 |
*/ |
59 |
public int |
60 |
getEffectId() { return effectId; } |
61 |
|
62 |
/** |
63 |
* Sets the numerical ID of this effect. |
64 |
* @param id The new effect ID. |
65 |
*/ |
66 |
public void |
67 |
setEffectId(int id) { effectId = id; } |
68 |
|
69 |
/** |
70 |
* Gets the name of the effect plugin system the effect is based on (e.g. "LADSPA"). |
71 |
*/ |
72 |
public String |
73 |
getSystem() { return system; } |
74 |
|
75 |
/** |
76 |
* Gets the module of the effect plugin system that contains this effect. |
77 |
* The module is usually the dynamic-linked library (DLL) filename of |
78 |
* the effect plugin, including full path. |
79 |
* @return The module of the effect plugin system that contains this effect. |
80 |
*/ |
81 |
public String |
82 |
getModule() { return module; } |
83 |
|
84 |
/** |
85 |
* Gets the unique name of the effect within its module. |
86 |
* @return The unique name of the effect within its module. |
87 |
*/ |
88 |
public String |
89 |
getName() { return name; } |
90 |
|
91 |
/** |
92 |
* Gets human readable name of the effect, |
93 |
* intended to be displayed in user interfaces. |
94 |
* @return The human readable name of the effect, |
95 |
* intended to be displayed in user interfaces. |
96 |
*/ |
97 |
public String |
98 |
getDescription() { return description; } |
99 |
|
100 |
/** |
101 |
* Parses a line of text. |
102 |
* @param s The string to be parsed. |
103 |
* @return <code>true</code> if the line has been processed, <code>false</code> otherwise. |
104 |
* @throws LscpException If some error occurs. |
105 |
*/ |
106 |
public boolean |
107 |
parse(String s) throws LscpException { |
108 |
if(s.startsWith("SYSTEM: ")) { |
109 |
system = s.substring("SYSTEM: ".length()); |
110 |
} else if(s.startsWith("MODULE: ")) { |
111 |
module = toNonEscapedString(s.substring("MODULE: ".length())); |
112 |
} else if(s.startsWith("NAME: ")) { |
113 |
name = toNonEscapedString(s.substring("NAME: ".length())); |
114 |
} else if(s.startsWith("DESCRIPTION: ")) { |
115 |
description = toNonEscapedString(s.substring("DESCRIPTION: ".length())); |
116 |
} else return false; |
117 |
|
118 |
return true; |
119 |
} |
120 |
} |