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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1139 - (show annotations) (download)
Mon Apr 2 20:43:58 2007 UTC (17 years ago) by iliev
File size: 3304 byte(s)
* upgraded to version 0.4a

1 /*
2 * jlscp - a java LinuxSampler control protocol API
3 *
4 * Copyright (C) 2005-2006 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 java.util.Vector;
26
27
28 /**
29 * This class provides default implementation of the <code>Driver</code> interface.
30 * @author Grigor Iliev
31 */
32 public abstract class AbstractDriver implements Driver, Parseable {
33 private String name = null;
34 private String desc = null;
35 private String ver = null;
36 private String[] prmNames = null;
37 private final Vector<Parameter> prmList = new Vector<Parameter>();
38
39
40 /** Creates a new instance of <code>AbstractDriver</code> */
41 public AbstractDriver() {
42 }
43
44 /**
45 * Gets the name of this driver.
46 * @return The name of this driver.
47 */
48 public String
49 getName() { return name; }
50
51 /**
52 * Sets the name of this driver.
53 * @param name A <code>String</code> object containing the new name for this driver.
54 */
55 public void
56 setName(String name) { this.name = name; }
57
58 /**
59 * Gets a description about this driver.
60 * @return A description about this driver.
61 */
62 public String
63 getDescription() { return desc; }
64
65 /**
66 * Gets the version of this driver.
67 * @return The version of this driver.
68 */
69 public String
70 getVersion() { return ver; }
71
72 /**
73 * Adds driver parameter.
74 * @param prm The additional parameter to be added.
75 */
76 public void
77 addParameter(Parameter prm) { prmList.add(prm); }
78
79 /**
80 * Gets all parameters available for this driver.
81 * @return <code>Parameter</code> array with all parameters available for this driver.
82 */
83 public Parameter[]
84 getParameters() { return prmList.toArray(new Parameter[prmList.size()]); }
85
86 /**
87 * Gets the names of all parameters available for this driver.
88 * @return <code>String</code> array with the names of all parameters
89 * available for this driver.
90 */
91 public String[]
92 getParameterNames() { return prmNames; }
93
94 /**
95 * Parses a line of text.
96 * @param s A string to be parsed.
97 * @return <code>true</code> if the line has been processed, <code>false</code> otherwise.
98 */
99 public boolean
100 parse(String s) {
101 if(s.startsWith("DESCRIPTION: ")) {
102 desc = s.substring("DESCRIPTION: ".length(), s.length());
103 } else if(s.startsWith("VERSION: ")) {
104 ver = s.substring("VERSION: ".length(), s.length());
105 } else if(s.startsWith("PARAMETERS: ")) {
106 s = s.substring("PARAMETERS: ".length(), s.length());
107 prmNames = Parser.parseList(s);
108 } else return false;
109
110 return true;
111 }
112
113 /**
114 * Returns the name of this driver.
115 * @return The name of this driver.
116 */
117 public String
118 toString() { return getName(); }
119 }

  ViewVC Help
Powered by ViewVC