1 |
/* |
2 |
* jlscp - a java LinuxSampler control protocol API |
3 |
* |
4 |
* Copyright (C) 2005 Grigor Kirilov Iliev |
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 |
|
34 |
/** |
35 |
* Creates a new instance of <code>ServerInfo</code> and parses the information |
36 |
* described by <code>resultSet</code>. |
37 |
* @param resultSet An array with information categories about a sampler. |
38 |
*/ |
39 |
public |
40 |
ServerInfo(String[] resultSet) { |
41 |
for(String s : resultSet) |
42 |
if(!parse(s)) Client.getLogger().info(LscpI18n.getLogMsg("unknownLine", s)); |
43 |
} |
44 |
|
45 |
/** |
46 |
* Gets description about the sampler. |
47 |
* @return Description about the sampler. |
48 |
*/ |
49 |
public String |
50 |
getDescription() { return desc; } |
51 |
|
52 |
/** |
53 |
* Gets the version of the sampler. |
54 |
* @return The version of the sampler. |
55 |
*/ |
56 |
public String |
57 |
getVersion() { return ver; } |
58 |
|
59 |
/** |
60 |
* Gets the version of the LSCP protocol. |
61 |
* @return The version of the LSCP protocol. |
62 |
*/ |
63 |
public String |
64 |
getProtocolVersion() { return protoVer; } |
65 |
|
66 |
/** |
67 |
* Parses a line of text. |
68 |
* @param s The string to be parsed. |
69 |
* @return <code>true</code> if the line has been processed, <code>false</code> otherwise. |
70 |
*/ |
71 |
public boolean |
72 |
parse(String s) { |
73 |
if(s.startsWith("DESCRIPTION: ")) { |
74 |
desc = s.substring("DESCRIPTION: ".length()); |
75 |
} else if(s.startsWith("VERSION: ")) { |
76 |
ver = s.substring("VERSION: ".length()); |
77 |
} else if(s.startsWith("PROTOCOL_VERSION: ")) { |
78 |
protoVer = s.substring("PROTOCOL_VERSION: ".length()); |
79 |
} else return false; |
80 |
|
81 |
return true; |
82 |
} |
83 |
} |