/* * jlscp - a java LinuxSampler control protocol API * * Copyright (C) 2005-2006 Grigor Iliev * * This file is part of jlscp. * * jlscp is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * jlscp is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with jlscp; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ package org.linuxsampler.lscp; /** * Provides general information about LinuxSampler instance. * @author Grigor Iliev */ public final class ServerInfo implements Parseable { private String desc = null; private String ver = null; private String protoVer = null; private boolean instrumentsDbSupport = false; /** * Creates a new instance of ServerInfo and parses the information * described by resultSet. * @param resultSet An array with information categories about a sampler. */ public ServerInfo(String[] resultSet) { for(String s : resultSet) if(!parse(s)) Client.getLogger().info(LscpI18n.getLogMsg("unknownLine", s)); } /** * Gets description about the sampler. * @return Description about the sampler. */ public String getDescription() { return desc; } /** * Gets the version of the sampler. * @return The version of the sampler. */ public String getVersion() { return ver; } /** * Gets the version of the LSCP protocol. * @return The version of the LSCP protocol. */ public String getProtocolVersion() { return protoVer; } /** * Determines whether the backend is * build with instruments database support. */ public boolean hasInstrumentsDbSupport() { return instrumentsDbSupport; } /** * Parses a line of text. * @param s The string to be parsed. * @return true if the line has been processed, false otherwise. */ public boolean parse(String s) { if(s.startsWith("DESCRIPTION: ")) { desc = s.substring("DESCRIPTION: ".length()); } else if(s.startsWith("VERSION: ")) { ver = s.substring("VERSION: ".length()); } else if(s.startsWith("PROTOCOL_VERSION: ")) { protoVer = s.substring("PROTOCOL_VERSION: ".length()); } else if(s.startsWith("INSTRUMENTS_DB_SUPPORT: ")) { s = s.substring("INSTRUMENTS_DB_SUPPORT: ".length()); if(s.equalsIgnoreCase("yes")) instrumentsDbSupport = true; } else return false; return true; } }