1 |
/* |
2 |
* jlscp - a java LinuxSampler control protocol API |
3 |
* |
4 |
* Copyright (C) 2005-2007 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 |
/** |
26 |
* |
27 |
* @author Grigor Iliev |
28 |
*/ |
29 |
public abstract class AbstractInstrument implements Parseable { |
30 |
private String name = "Untitled"; |
31 |
private String description = ""; |
32 |
private String path = null; |
33 |
private int instrumentIndex = 0; |
34 |
|
35 |
/** |
36 |
* Creates a new instance of <code>AbstractInstrument</code>. |
37 |
*/ |
38 |
public AbstractInstrument() { |
39 |
} |
40 |
|
41 |
/** |
42 |
* Gets the name of this instrument. |
43 |
* @return The name of this instrument. |
44 |
*/ |
45 |
public String |
46 |
getName() { return name; } |
47 |
|
48 |
/** |
49 |
* Sets the name of this instrument. |
50 |
* @param name The name of this instrument. |
51 |
*/ |
52 |
public void |
53 |
setName(String name) { this.name = name; } |
54 |
|
55 |
/** |
56 |
* Gets a brief description about this instrument. |
57 |
* @return A brief description about this instrument. |
58 |
*/ |
59 |
public String |
60 |
getDescription() { return description; } |
61 |
|
62 |
/** |
63 |
* Returns the absolute path name of the instrument file. |
64 |
* @return The absolute path name of the instrument file. |
65 |
*/ |
66 |
public String |
67 |
getFilePath() { return path; } |
68 |
|
69 |
/** |
70 |
* Sets the absolute path name of the instrument file. |
71 |
* @param path Specifies the absolute path name of the instrument file. |
72 |
*/ |
73 |
public void |
74 |
setFilePath(String path) { this.path = path; } |
75 |
|
76 |
/** |
77 |
* Returns the index of the instrument in the instrument file. |
78 |
* @return The index of the instrument in the instrument file. |
79 |
*/ |
80 |
public int |
81 |
getInstrumentIndex() { return instrumentIndex; } |
82 |
|
83 |
/** |
84 |
* Sets the index of the instrument in the instrument file. |
85 |
* @param idx The index of the instrument in the instrument file. |
86 |
*/ |
87 |
public void |
88 |
setInstrumentIndex(int idx) { instrumentIndex = idx; } |
89 |
|
90 |
/** |
91 |
* Parses a line of text. |
92 |
* @param s The string to be parsed. |
93 |
* @return <code>true</code> if the line has been processed, <code>false</code> otherwise. |
94 |
* @throws LscpException If some error occurs. |
95 |
*/ |
96 |
public boolean |
97 |
parse(String s) throws LscpException { |
98 |
if(s.startsWith("NAME: ")) { |
99 |
setName(s.substring("NAME: ".length())); |
100 |
} else if(s.startsWith("DESCRIPTION: ")) { |
101 |
description = s.substring("DESCRIPTION: ".length()); |
102 |
} else if(s.startsWith("INSTRUMENT_FILE: ")) { |
103 |
setFilePath(s.substring("INSTRUMENT_FILE: ".length())); |
104 |
} else if(s.startsWith("INSTRUMENT_NR: ")) { |
105 |
s = s.substring("INSTRUMENT_NR: ".length()); |
106 |
setInstrumentIndex(Parser.parseInt(s)); |
107 |
} else return false; |
108 |
|
109 |
return true; |
110 |
} |
111 |
} |