< prev index next >

src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileWriter.java

Print this page


   1 /*
   2  * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  41  */
  42 public abstract class MidiFileWriter {
  43 
  44     /**
  45      * Obtains the set of MIDI file types for which file writing support is
  46      * provided by this file writer.
  47      *
  48      * @return array of file types. If no file types are supported, an array of
  49      *         length 0 is returned.
  50      */
  51     public abstract int[] getMidiFileTypes();
  52 
  53     /**
  54      * Obtains the file types that this file writer can write from the sequence
  55      * specified.
  56      *
  57      * @param  sequence the sequence for which MIDI file type support is
  58      *         queried
  59      * @return array of file types. If no file types are supported, returns an
  60      *         array of length 0.

  61      */
  62     public abstract int[] getMidiFileTypes(Sequence sequence);
  63 
  64     /**
  65      * Indicates whether file writing support for the specified MIDI file type
  66      * is provided by this file writer.
  67      *
  68      * @param  fileType the file type for which write capabilities are queried
  69      * @return {@code true} if the file type is supported, otherwise
  70      *         {@code false}
  71      */
  72     public boolean isFileTypeSupported(int fileType) {
  73 
  74         int types[] = getMidiFileTypes();
  75         for(int i=0; i<types.length; i++) {
  76             if( fileType == types[i] ) {
  77                 return true;
  78             }
  79         }
  80         return false;
  81     }
  82 
  83     /**
  84      * Indicates whether a MIDI file of the file type specified can be written
  85      * from the sequence indicated.
  86      *
  87      * @param  fileType the file type for which write capabilities are queried
  88      * @param  sequence the sequence for which file writing support is queried
  89      * @return {@code true} if the file type is supported for this sequence,
  90      *         otherwise {@code false}

  91      */
  92     public boolean isFileTypeSupported(int fileType, Sequence sequence) {
  93 
  94         int types[] = getMidiFileTypes( sequence );
  95         for(int i=0; i<types.length; i++) {
  96             if( fileType == types[i] ) {
  97                 return true;
  98             }
  99         }
 100         return false;
 101     }
 102 
 103     /**
 104      * Writes a stream of bytes representing a MIDI file of the file type
 105      * indicated to the output stream provided.
 106      *
 107      * @param  in sequence containing MIDI data to be written to the file
 108      * @param  fileType type of the file to be written to the output stream
 109      * @param  out stream to which the file data should be written
 110      * @return the number of bytes written to the output stream
 111      * @throws IOException if an I/O exception occurs
 112      * @throws IllegalArgumentException if the file type is not supported by
 113      *         this file writer


 114      * @see #isFileTypeSupported(int, Sequence)
 115      * @see #getMidiFileTypes(Sequence)
 116      */
 117     public abstract int write(Sequence in, int fileType, OutputStream out)
 118             throws IOException;
 119 
 120     /**
 121      * Writes a stream of bytes representing a MIDI file of the file type
 122      * indicated to the external file provided.
 123      *
 124      * @param  in sequence containing MIDI data to be written to the external
 125      *         file
 126      * @param  fileType type of the file to be written to the external file
 127      * @param  out external file to which the file data should be written
 128      * @return the number of bytes written to the file
 129      * @throws IOException if an I/O exception occurs
 130      * @throws IllegalArgumentException if the file type is not supported by
 131      *         this file writer


 132      * @see #isFileTypeSupported(int, Sequence)
 133      * @see #getMidiFileTypes(Sequence)
 134      */
 135     public abstract int write(Sequence in, int fileType, File out)
 136             throws IOException;
 137 }
   1 /*
   2  * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  41  */
  42 public abstract class MidiFileWriter {
  43 
  44     /**
  45      * Obtains the set of MIDI file types for which file writing support is
  46      * provided by this file writer.
  47      *
  48      * @return array of file types. If no file types are supported, an array of
  49      *         length 0 is returned.
  50      */
  51     public abstract int[] getMidiFileTypes();
  52 
  53     /**
  54      * Obtains the file types that this file writer can write from the sequence
  55      * specified.
  56      *
  57      * @param  sequence the sequence for which MIDI file type support is
  58      *         queried
  59      * @return array of file types. If no file types are supported, returns an
  60      *         array of length 0.
  61      * @throws NullPointerException if {@code sequence} is {@code null}
  62      */
  63     public abstract int[] getMidiFileTypes(Sequence sequence);
  64 
  65     /**
  66      * Indicates whether file writing support for the specified MIDI file type
  67      * is provided by this file writer.
  68      *
  69      * @param  fileType the file type for which write capabilities are queried
  70      * @return {@code true} if the file type is supported, otherwise
  71      *         {@code false}
  72      */
  73     public boolean isFileTypeSupported(int fileType) {
  74 
  75         int types[] = getMidiFileTypes();
  76         for(int i=0; i<types.length; i++) {
  77             if( fileType == types[i] ) {
  78                 return true;
  79             }
  80         }
  81         return false;
  82     }
  83 
  84     /**
  85      * Indicates whether a MIDI file of the file type specified can be written
  86      * from the sequence indicated.
  87      *
  88      * @param  fileType the file type for which write capabilities are queried
  89      * @param  sequence the sequence for which file writing support is queried
  90      * @return {@code true} if the file type is supported for this sequence,
  91      *         otherwise {@code false}
  92      * @throws NullPointerException if {@code sequence} is {@code null}
  93      */
  94     public boolean isFileTypeSupported(int fileType, Sequence sequence) {
  95 
  96         int types[] = getMidiFileTypes( sequence );
  97         for(int i=0; i<types.length; i++) {
  98             if( fileType == types[i] ) {
  99                 return true;
 100             }
 101         }
 102         return false;
 103     }
 104 
 105     /**
 106      * Writes a stream of bytes representing a MIDI file of the file type
 107      * indicated to the output stream provided.
 108      *
 109      * @param  in sequence containing MIDI data to be written to the file
 110      * @param  fileType type of the file to be written to the output stream
 111      * @param  out stream to which the file data should be written
 112      * @return the number of bytes written to the output stream
 113      * @throws IOException if an I/O exception occurs
 114      * @throws IllegalArgumentException if the file type is not supported by
 115      *         this file writer
 116      * @throws NullPointerException if {@code in} or {@code out} are
 117      *         {@code null}
 118      * @see #isFileTypeSupported(int, Sequence)
 119      * @see #getMidiFileTypes(Sequence)
 120      */
 121     public abstract int write(Sequence in, int fileType, OutputStream out)
 122             throws IOException;
 123 
 124     /**
 125      * Writes a stream of bytes representing a MIDI file of the file type
 126      * indicated to the external file provided.
 127      *
 128      * @param  in sequence containing MIDI data to be written to the external
 129      *         file
 130      * @param  fileType type of the file to be written to the external file
 131      * @param  out external file to which the file data should be written
 132      * @return the number of bytes written to the file
 133      * @throws IOException if an I/O exception occurs
 134      * @throws IllegalArgumentException if the file type is not supported by
 135      *         this file writer
 136      * @throws NullPointerException if {@code in} or {@code out} are
 137      *         {@code null}
 138      * @see #isFileTypeSupported(int, Sequence)
 139      * @see #getMidiFileTypes(Sequence)
 140      */
 141     public abstract int write(Sequence in, int fileType, File out)
 142             throws IOException;
 143 }
< prev index next >