< prev index next >
src/java.desktop/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java
Print this page
*** 1,7 ****
/*
! * 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
--- 1,7 ----
/*
! * Copyright (c) 1999, 2016, 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,33 ****
* 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;
--- 23,33 ----
* questions.
*/
package javax.sound.sampled.spi;
! import java.util.stream.Stream;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import static javax.sound.sampled.AudioFormat.Encoding;
*** 79,98 ****
* 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;
! }
! }
! return false;
}
/**
* Indicates whether the format converter supports conversion to the
* specified target format encoding.
--- 79,90 ----
* queried
* @return {@code true} if the encoding is supported, otherwise
* {@code false}
* @throws NullPointerException if {@code sourceEncoding} is {@code null}
*/
! public boolean isSourceEncodingSupported(final Encoding sourceEncoding) {
! return Stream.of(getSourceEncodings()).anyMatch(sourceEncoding::equals);
}
/**
* Indicates whether the format converter supports conversion to the
* specified target format encoding.
*** 101,120 ****
* 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;
! }
! }
! return false;
}
/**
* Obtains the set of target format encodings supported by the format
* converter given a particular source format. If no target format encodings
--- 93,104 ----
* queried
* @return {@code true} if the encoding is supported, otherwise
* {@code false}
* @throws NullPointerException if {@code targetEncoding} is {@code null}
*/
! public boolean isTargetEncodingSupported(final Encoding targetEncoding) {
! return Stream.of(getTargetEncodings()).anyMatch(targetEncoding::equals);
}
/**
* Obtains the set of target format encodings supported by the format
* converter given a particular source format. If no target format encodings
*** 135,155 ****
* @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;
! }
! }
! 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
--- 119,132 ----
* @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(final Encoding targetEncoding,
! final AudioFormat sourceFormat) {
! return Stream.of(getTargetEncodings(sourceFormat))
! .anyMatch(targetEncoding::equals);
}
/**
* Obtains the set of target formats with the encoding specified supported
* by the format converter. If no target formats with the specified encoding
*** 173,193 ****
* @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 );
!
! for(int i=0; i<targetFormats.length; i++) {
! if( targetFormat.matches( targetFormats[i] ) ) {
! return true;
! }
! }
! return false;
}
/**
* Obtains an audio input stream with the specified encoding from the given
* audio input stream.
--- 150,164 ----
* @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(final AudioFormat targetFormat,
! final AudioFormat sourceFormat) {
! final Encoding targetEncoding = targetFormat.getEncoding();
! return Stream.of(getTargetFormats(targetEncoding, sourceFormat))
! .anyMatch(targetFormat::matches);
}
/**
* Obtains an audio input stream with the specified encoding from the given
* audio input stream.
< prev index next >