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 |
/** |
26 |
* Provides general information about LinuxSampler instance. |
27 |
* @author Grigor Iliev |
28 |
*/ |
29 |
public final class ServerInfo implements Parseable { |
30 |
private String desc = null; |
31 |
private String ver = null; |
32 |
private String protoVer = null; |
33 |
private boolean instrumentsDbSupport = false; |
34 |
|
35 |
/** |
36 |
* Creates a new instance of <code>ServerInfo</code> and parses the information |
37 |
* described by <code>resultSet</code>. |
38 |
* @param resultSet An array with information categories about a sampler. |
39 |
*/ |
40 |
public |
41 |
ServerInfo(String[] resultSet) { |
42 |
for(String s : resultSet) |
43 |
if(!parse(s)) Client.getLogger().info(LscpI18n.getLogMsg("unknownLine", s)); |
44 |
} |
45 |
|
46 |
/** |
47 |
* Gets description about the sampler. |
48 |
* @return Description about the sampler. |
49 |
*/ |
50 |
public String |
51 |
getDescription() { return desc; } |
52 |
|
53 |
/** |
54 |
* Gets the version of the sampler. |
55 |
* @return The version of the sampler. |
56 |
*/ |
57 |
public String |
58 |
getVersion() { return ver; } |
59 |
|
60 |
/** |
61 |
* Gets the version of the LSCP protocol. |
62 |
* @return The version of the LSCP protocol. |
63 |
*/ |
64 |
public String |
65 |
getProtocolVersion() { return protoVer; } |
66 |
|
67 |
/** |
68 |
* Determines whether the backend is |
69 |
* build with instruments database support. |
70 |
*/ |
71 |
public boolean |
72 |
hasInstrumentsDbSupport() { return instrumentsDbSupport; } |
73 |
|
74 |
/** |
75 |
* Parses a line of text. |
76 |
* @param s The string to be parsed. |
77 |
* @return <code>true</code> if the line has been processed, <code>false</code> otherwise. |
78 |
*/ |
79 |
public boolean |
80 |
parse(String s) { |
81 |
if(s.startsWith("DESCRIPTION: ")) { |
82 |
desc = s.substring("DESCRIPTION: ".length()); |
83 |
} else if(s.startsWith("VERSION: ")) { |
84 |
ver = s.substring("VERSION: ".length()); |
85 |
} else if(s.startsWith("PROTOCOL_VERSION: ")) { |
86 |
protoVer = s.substring("PROTOCOL_VERSION: ".length()); |
87 |
} else if(s.startsWith("INSTRUMENTS_DB_SUPPORT: ")) { |
88 |
s = s.substring("INSTRUMENTS_DB_SUPPORT: ".length()); |
89 |
if(s.equalsIgnoreCase("yes")) instrumentsDbSupport = true; |
90 |
} else return false; |
91 |
|
92 |
return true; |
93 |
} |
94 |
} |