/[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 1539 - (show annotations) (download)
Mon Dec 3 22:59:39 2007 UTC (16 years, 3 months ago) by iliev
File size: 4163 byte(s)
* Added new interface - Instrument
* Client: added new methods - getFileInstrumentCount,
  getFileInstrumentInfo,  getFileInstruments

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 Instrument, Parseable {
32 private String name = "Untitled";
33 private String description = "";
34 private String path = null;
35 private int instrumentIndex = 0;
36 private String formatFamily = "";
37 private String formatVersion = "";
38
39 /**
40 * Creates a new instance of <code>AbstractInstrument</code>.
41 */
42 public
43 AbstractInstrument() { }
44
45 /**
46 * Creates a new instance of <code>AbstractInstrument</code>.
47 * @param resultSet An array with information categories about an instrument.
48 */
49 public
50 AbstractInstrument(String[] resultSet) throws LscpException {
51 for(String s : resultSet)
52 if(!parse(s)) Client.getLogger().info(LscpI18n.getLogMsg("unknownLine", s));
53 }
54
55 /**
56 * Gets the name of this instrument.
57 * @return The name of this instrument.
58 */
59 public String
60 getName() { return name; }
61
62 /**
63 * Sets the name of this instrument.
64 * @param name The name of this instrument.
65 */
66 public void
67 setName(String name) { this.name = name; }
68
69 /**
70 * Gets a brief description about this instrument.
71 * @return A brief description about this instrument.
72 */
73 public String
74 getDescription() { return description; }
75
76 /**
77 * Returns the absolute path name of the instrument file.
78 * @return The absolute path name of the instrument file.
79 */
80 public String
81 getFilePath() { return path; }
82
83 /**
84 * Sets the absolute path name of the instrument file.
85 * @param path Specifies the absolute path name of the instrument file.
86 */
87 public void
88 setFilePath(String path) { this.path = path; }
89
90 /**
91 * Returns the index of the instrument in the instrument file.
92 * @return The index of the instrument in the instrument file.
93 */
94 public int
95 getInstrumentIndex() { return instrumentIndex; }
96
97 /**
98 * Sets the index of the instrument in the instrument file.
99 * @param idx The index of the instrument in the instrument file.
100 */
101 public void
102 setInstrumentIndex(int idx) { instrumentIndex = idx; }
103
104 /**
105 * Returns the format family of the instrument.
106 **/
107 public String
108 getFormatFamily() { return formatFamily; }
109
110 /**
111 * Returns the format version of the instrument.
112 **/
113 public String
114 getFormatVersion() { return formatVersion; }
115
116 /**
117 * Parses a line of text.
118 * @param s The string to be parsed.
119 * @return <code>true</code> if the line has been processed, <code>false</code> otherwise.
120 * @throws LscpException If some error occurs.
121 */
122 public boolean
123 parse(String s) throws LscpException {
124 if(s.startsWith("NAME: ")) {
125 setName(s.substring("NAME: ".length()));
126 } else if(s.startsWith("DESCRIPTION: ")) {
127 description = s.substring("DESCRIPTION: ".length());
128 description = toNonEscapedString(description);
129 } else if(s.startsWith("INSTRUMENT_FILE: ")) {
130 setFilePath(s.substring("INSTRUMENT_FILE: ".length()));
131 } else if(s.startsWith("INSTRUMENT_NR: ")) {
132 s = s.substring("INSTRUMENT_NR: ".length());
133 setInstrumentIndex(Parser.parseInt(s));
134 } else if(s.startsWith("FORMAT_FAMILY: ")) {
135 formatFamily = s.substring("FORMAT_FAMILY: ".length());
136 } else if(s.startsWith("FORMAT_VERSION: ")) {
137 formatVersion = s.substring("FORMAT_VERSION: ".length());
138 } else return false;
139
140 return true;
141 }
142 }

  ViewVC Help
Powered by ViewVC