Path: blob/master/src/java.desktop/share/classes/com/sun/media/sound/MidiDeviceTransmitterEnvelope.java
41161 views
/*1* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.media.sound;2627import javax.sound.midi.MidiDevice;28import javax.sound.midi.MidiDeviceTransmitter;29import javax.sound.midi.Receiver;30import javax.sound.midi.Transmitter;3132/**33* Helper class which allows to convert {@code Transmitter}34* to {@code MidiDeviceTransmitter}.35*36* @author Alex Menkov37*/38public final class MidiDeviceTransmitterEnvelope implements MidiDeviceTransmitter {3940private final MidiDevice device;41private final Transmitter transmitter;4243/**44* Creates a new {@code MidiDeviceTransmitterEnvelope} object which45* envelops the specified {@code Transmitter}46* and is owned by the specified {@code MidiDevice}.47*48* @param device the owner {@code MidiDevice}49* @param transmitter the {@code Transmitter} to be enveloped50*/51public MidiDeviceTransmitterEnvelope(MidiDevice device, Transmitter transmitter) {52if (device == null || transmitter == null) {53throw new NullPointerException();54}55this.device = device;56this.transmitter = transmitter;57}5859// Transmitter implementation60@Override61public void setReceiver(Receiver receiver) {62transmitter.setReceiver(receiver);63}6465@Override66public Receiver getReceiver() {67return transmitter.getReceiver();68}6970@Override71public void close() {72transmitter.close();73}7475// MidiDeviceReceiver implementation76@Override77public MidiDevice getMidiDevice() {78return device;79}8081/**82* Obtains the transmitter enveloped83* by this {@code MidiDeviceTransmitterEnvelope} object.84*85* @return the enveloped transmitter86*/87public Transmitter getTransmitter() {88return transmitter;89}90}919293