< prev index next >

src/java.desktop/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -23,10 +23,12 @@
  * questions.
  */
 
 package javax.sound.sampled.spi;
 
+import java.util.Objects;
+
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioInputStream;
 
 import static javax.sound.sampled.AudioFormat.Encoding;
 

@@ -75,13 +77,14 @@
      *
      * @param  sourceEncoding the source format encoding for which support is
      *         queried
      * @return {@code true} if the encoding is supported, otherwise
      *         {@code false}
+     * @throws NullPointerException if {@code sourceEncoding} is {@code null}
      */
     public boolean isSourceEncodingSupported(Encoding sourceEncoding) {
-
+        Objects.requireNonNull(sourceEncoding);
         Encoding sourceEncodings[] = getSourceEncodings();
 
         for(int i=0; i<sourceEncodings.length; i++) {
             if( sourceEncoding.equals( sourceEncodings[i]) ) {
                 return true;

@@ -96,13 +99,14 @@
      *
      * @param  targetEncoding the target format encoding for which support is
      *         queried
      * @return {@code true} if the encoding is supported, otherwise
      *         {@code false}
+     * @throws NullPointerException if {@code targetEncoding} is {@code null}
      */
     public boolean isTargetEncodingSupported(Encoding targetEncoding) {
-
+        Objects.requireNonNull(targetEncoding);
         Encoding targetEncodings[] = getTargetEncodings();
 
         for(int i=0; i<targetEncodings.length; i++) {
             if( targetEncoding.equals( targetEncodings[i]) ) {
                 return true;

@@ -116,10 +120,11 @@
      * converter given a particular source format. If no target format encodings
      * are supported for this source format, an array of length 0 is returned.
      *
      * @param  sourceFormat format of the incoming data
      * @return array of supported target format encodings
+     * @throws NullPointerException if {@code sourceFormat} is {@code null}
      */
     public abstract Encoding[] getTargetEncodings(AudioFormat sourceFormat);
 
     /**
      * Indicates whether the format converter supports conversion to a

@@ -127,14 +132,16 @@
      *
      * @param  targetEncoding desired encoding of the outgoing data
      * @param  sourceFormat format of the incoming data
      * @return {@code true} if the conversion is supported, otherwise
      *         {@code false}
+     * @throws NullPointerException if {@code targetEncoding} or
+     *         {@code sourceFormat} are {@code null}
      */
     public boolean isConversionSupported(Encoding targetEncoding,
                                          AudioFormat sourceFormat) {
-
+        Objects.requireNonNull(targetEncoding);
         Encoding targetEncodings[] = getTargetEncodings(sourceFormat);
 
         for(int i=0; i<targetEncodings.length; i++) {
             if( targetEncoding.equals( targetEncodings[i]) ) {
                 return true;

@@ -143,16 +150,18 @@
         return false;
     }
 
     /**
      * Obtains the set of target formats with the encoding specified supported
-     * by the format converter If no target formats with the specified encoding
+     * by the format converter. If no target formats with the specified encoding
      * are supported for this source format, an array of length 0 is returned.
      *
      * @param  targetEncoding desired encoding of the stream after processing
      * @param  sourceFormat format of the incoming data
      * @return array of supported target formats
+     * @throws NullPointerException if {@code targetEncoding} or
+     *         {@code sourceFormat} are {@code null}
      */
     public abstract AudioFormat[] getTargetFormats(Encoding targetEncoding,
                                                    AudioFormat sourceFormat);
 
     /**

@@ -161,10 +170,12 @@
      *
      * @param  targetFormat desired format of outgoing data
      * @param  sourceFormat format of the incoming data
      * @return {@code true} if the conversion is supported, otherwise
      *         {@code false}
+     * @throws NullPointerException if {@code targetFormat} or
+     *         {@code sourceFormat} are {@code null}
      */
     public boolean isConversionSupported(AudioFormat targetFormat,
                                          AudioFormat sourceFormat) {
 
         AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

@@ -186,10 +197,12 @@
      *         read
      * @return stream from which processed data with the specified target
      *         encoding may be read
      * @throws IllegalArgumentException if the format combination supplied is
      *         not supported
+     * @throws NullPointerException if {@code targetEncoding} or
+     *         {@code sourceStream} are {@code null}
      */
     public abstract AudioInputStream getAudioInputStream(
             Encoding targetEncoding, AudioInputStream sourceStream);
 
     /**

@@ -201,9 +214,11 @@
      *         read
      * @return stream from which processed data with the specified format may be
      *         read
      * @throws IllegalArgumentException if the format combination supplied is
      *         not supported
+     * @throws NullPointerException if {@code targetFormat} or
+     *         {@code sourceStream} are {@code null}
      */
     public abstract AudioInputStream getAudioInputStream(
             AudioFormat targetFormat, AudioInputStream sourceStream);
 }
< prev index next >