/[svn]/jlscp/trunk/src/org/linuxsampler/lscp/AbstractInstrument.java
ViewVC logotype

Contents of /jlscp/trunk/src/org/linuxsampler/lscp/AbstractInstrument.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1351 - (show annotations) (download)
Sun Sep 16 23:15:57 2007 UTC (16 years, 7 months ago) by iliev
File size: 3284 byte(s)
* instruments db: slashes-in-names are now escaped with \x2f

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

  ViewVC Help
Powered by ViewVC