2719N/A/*
6321N/A * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
2719N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2719N/A *
2719N/A * This code is free software; you can redistribute it and/or modify it
2719N/A * under the terms of the GNU General Public License version 2 only, as
2719N/A * published by the Free Software Foundation. Oracle designates this
2719N/A * particular file as subject to the "Classpath" exception as provided
2719N/A * by Oracle in the LICENSE file that accompanied this code.
2719N/A *
2719N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2719N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2719N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2719N/A * version 2 for more details (a copy is included in the LICENSE file that
2719N/A * accompanied this code).
2719N/A *
2719N/A * You should have received a copy of the GNU General Public License version
2719N/A * 2 along with this work; if not, write to the Free Software Foundation,
2719N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2719N/A *
2719N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2719N/A * or visit www.oracle.com if you need additional information or have any
2719N/A * questions.
2719N/A */
2719N/Apackage com.sun.media.sound;
2719N/A
2719N/Aimport javax.sound.midi.*;
2719N/A
2719N/A
2719N/A/**
2719N/A * Helper class which allows to convert {@code Transmitter}
2719N/A * to {@code MidiDeviceTransmitter}.
2719N/A *
2719N/A * @author Alex Menkov
2719N/A */
6321N/Apublic final class MidiDeviceTransmitterEnvelope implements MidiDeviceTransmitter {
2719N/A
2719N/A private final MidiDevice device;
2719N/A private final Transmitter transmitter;
2719N/A
2719N/A /**
2719N/A * Creates a new {@code MidiDeviceTransmitterEnvelope} object which
2719N/A * envelops the specified {@code Transmitter}
2719N/A * and is owned by the specified {@code MidiDevice}.
2719N/A *
2719N/A * @param device the owner {@code MidiDevice}
2719N/A * @param transmitter the {@code Transmitter} to be enveloped
2719N/A */
2719N/A public MidiDeviceTransmitterEnvelope(MidiDevice device, Transmitter transmitter) {
2719N/A if (device == null || transmitter == null) {
2719N/A throw new NullPointerException();
2719N/A }
2719N/A this.device = device;
2719N/A this.transmitter = transmitter;
2719N/A }
2719N/A
2719N/A // Transmitter implementation
2719N/A public void setReceiver(Receiver receiver) {
2719N/A transmitter.setReceiver(receiver);
2719N/A }
2719N/A
2719N/A public Receiver getReceiver() {
2719N/A return transmitter.getReceiver();
2719N/A }
2719N/A
2719N/A public void close() {
2719N/A transmitter.close();
2719N/A }
2719N/A
2719N/A
2719N/A // MidiDeviceReceiver implementation
2719N/A public MidiDevice getMidiDevice() {
2719N/A return device;
2719N/A }
2719N/A
2719N/A /**
2719N/A * Obtains the transmitter enveloped
2719N/A * by this {@code MidiDeviceTransmitterEnvelope} object.
2719N/A *
2719N/A * @return the enveloped transmitter
2719N/A */
2719N/A public Transmitter getTransmitter() {
2719N/A return transmitter;
2719N/A }
2719N/A}