1 |
/* |
2 |
* jlscp - a java LinuxSampler control protocol API |
3 |
* |
4 |
* Copyright (C) 2005 Grigor Kirilov Iliev |
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 |
/** |
26 |
* Provides information about a specific sampler engine. |
27 |
* @author Grigor Iliev |
28 |
*/ |
29 |
public class SamplerEngine implements Parseable { |
30 |
private String name = null; |
31 |
private String desc = null; |
32 |
private String ver = null; |
33 |
|
34 |
|
35 |
/** Creates a new instance of <code>SamplerEngine</code> */ |
36 |
public SamplerEngine() { |
37 |
} |
38 |
|
39 |
/** |
40 |
* Creates a new instance of <code>SamplerEngine</code> and parses the information |
41 |
* about a sampler engine described by <code>resultSet</code>. |
42 |
* @param resultSet An array of information categories about a sampler engine. |
43 |
*/ |
44 |
public |
45 |
SamplerEngine(String[] resultSet) { |
46 |
for(String s : resultSet) |
47 |
if(!parse(s)) Client.getLogger().info(LscpI18n.getLogMsg("unknownLine", s)); |
48 |
} |
49 |
|
50 |
/** |
51 |
* Gets the name of this sampler engine. |
52 |
* @return The name of this sampler engine. |
53 |
*/ |
54 |
public String |
55 |
getName() { return name; } |
56 |
|
57 |
/** |
58 |
* Sets the name of this sampler engine. |
59 |
* @param name A <code>String</code> instance containing the new name for |
60 |
* this sampler engine. |
61 |
*/ |
62 |
public void |
63 |
setName(String name) { this.name = name; } |
64 |
|
65 |
/** |
66 |
* Gets a description about this sampler engine. |
67 |
* @return A description about this sampler engine. |
68 |
*/ |
69 |
public String |
70 |
getDescription() { return desc; } |
71 |
|
72 |
/** |
73 |
* Gets the version of this sampler engine. |
74 |
* @return The version of this sampler engine. |
75 |
*/ |
76 |
public String |
77 |
getVersion() { return ver; } |
78 |
|
79 |
/** |
80 |
* Parses a line of text. |
81 |
* @param s The string to be parsed. |
82 |
* @return <code>true</code> if the line has been processed, <code>false</code> otherwise. |
83 |
*/ |
84 |
public boolean |
85 |
parse(String s) { |
86 |
if(s.startsWith("DESCRIPTION: ")) { |
87 |
desc = s.substring("DESCRIPTION: ".length(), s.length()); |
88 |
} else if(s.startsWith("VERSION: ")) { |
89 |
ver = s.substring("VERSION: ".length(), s.length()); |
90 |
} else return false; |
91 |
|
92 |
return true; |
93 |
} |
94 |
|
95 |
/** |
96 |
* Compares this <code>SamplerEngine</code> instance to the specified object. |
97 |
* The result is <code>true</code> if <code>obj</code> is reference to |
98 |
* <code>this</code>, or if <code>obj</code> is a <code>SamplerEngine</code> instance |
99 |
* and has non-<code>null</code> name equal to the name of this engine. |
100 |
* |
101 |
* @return <code>true</code> if <code>obj</code> is reference to |
102 |
* <code>this</code>, or if <code>obj</code> is a <code>SamplerEngine</code> instance |
103 |
* and has non-<code>null</code> name equal to the name of this engine; |
104 |
* <code>false</code> otherwise. |
105 |
* @see #getName |
106 |
*/ |
107 |
public boolean |
108 |
equals(Object obj) { |
109 |
if(this == obj) return true; |
110 |
|
111 |
if(getName() == null || obj == null) return false; |
112 |
|
113 |
if(obj instanceof SamplerEngine) |
114 |
return getName().equals(((SamplerEngine)obj).getName()); |
115 |
|
116 |
return false; |
117 |
} |
118 |
|
119 |
/** |
120 |
* Returns the description of this sampler engine. |
121 |
* @return The description of this sampler engine. |
122 |
*/ |
123 |
public String |
124 |
toString() { return getDescription(); } |
125 |
} |