/* * 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; import java.util.Vector; /** * This class provides default implementation of the Device interface. * @author Grigor Iliev */ public abstract class AbstractDevice implements Device { private int id = -1; private String driver = null; private BoolParameter active = new BoolParameter("ACTIVE", true); private final Vector prmList = new Vector(); /** Creates new instance of AbstractDevice */ public AbstractDevice() { } /** * Gets the numerical ID of this device. * @return The numerical ID of this device or -1 if the device number is not set. */ public int getDeviceId() { return id; } /** * Sets the numerical ID of this device. * @param id The new numerical ID of this device. */ public void setDeviceId(int id) { this.id = id; } /** * Gets the driver name used by this device. * @return The driver name used by this device. */ public String getDriverName() { return driver; } /** * Sets the driver name of this device. * @param driver The new name for this device. */ public void setDriverName(String driver) { this.driver = driver; } /** * Determines whether this device is active. * @return false if the device is inactive and true otherwise. */ public boolean isActive() { return active.getValue(); } /** * Sets whether this audio output device is active or not. * @param active false if the device is inactive and doesn't output any sound, * true otherwise. */ public void setActive(boolean active) { this.active.setValue(active); } /** * Gets the ACTIVE parameter. * @return A Parameter instance * representing the active state of the device. */ public Parameter getActiveParameter() { return active; } /** * Adds additional parameter to this device. * @param prm The additional parameter to be added. */ public void addParameter(Parameter prm) { prmList.add(prm); } /** * Gets Parameter array with the additional parameters of this device. * @return Parameter array with the additional parameters of this device. */ public Parameter[] getAdditionalParameters() { return prmList.toArray(new Parameter[prmList.size()]); } /** * Determines whether this device has additional parameters. * @return true if this device has additional parameters, * false otherwise. */ public boolean hasAdditionalParameters() { return !prmList.isEmpty(); } /** * Returns the numerical ID of the device. * @return The numerical ID of the device. */ public String toString() { return String.valueOf(getDeviceId()); } }