8236980: Cleanup of toString methods in JavaSound
Reviewed-by: prr
This commit is contained in:
parent
c18080fef7
commit
a0a9595d8b
src/java.desktop/share/classes/javax/sound
midi
sampled
test/jdk/javax/sound
midi
sampled
AudioFileFormat
AudioFormat
Controls
LineEvent
ReverbType
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -350,9 +350,9 @@ public interface MidiDevice extends AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a string representation of the device information.
|
||||
* Returns a string representation of the info object.
|
||||
*
|
||||
* @return a description of the info object
|
||||
* @return a string representation of the info object
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -720,14 +720,13 @@ public interface Sequencer extends MidiDevice {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides this synchronization mode's name as the string
|
||||
* representation of the mode.
|
||||
* Returns mode's name as the string representation of the
|
||||
* synchronization mode.
|
||||
*
|
||||
* @return the name of this synchronization mode
|
||||
* @return a string representation of the synchronization mode
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -262,33 +262,25 @@ public class AudioFileFormat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a string representation of the file format.
|
||||
* Returns a string representation of the audio file format.
|
||||
*
|
||||
* @return the file format as a string
|
||||
* @return a string representation of the audio file format
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
String str = "Unknown file format";
|
||||
//$$fb2002-11-01: fix for 4672864: AudioFileFormat.toString() throws unexpected NullPointerException
|
||||
if (type != null) {
|
||||
buf.append(type.toString() + " (." + type.getExtension() + ") file");
|
||||
} else {
|
||||
buf.append("unknown file format");
|
||||
if (getType() != null) {
|
||||
str = getType() + " (." + getType().getExtension() + ") file";
|
||||
}
|
||||
|
||||
if (byteLength != AudioSystem.NOT_SPECIFIED) {
|
||||
buf.append(", byte length: " + byteLength);
|
||||
if (getByteLength() != AudioSystem.NOT_SPECIFIED) {
|
||||
str += ", byte length: " + getByteLength();
|
||||
}
|
||||
|
||||
buf.append(", data format: " + format);
|
||||
|
||||
if (frameLength != AudioSystem.NOT_SPECIFIED) {
|
||||
buf.append(", frame length: " + frameLength);
|
||||
str += ", data format: " + getFormat();
|
||||
if (getFrameLength() != AudioSystem.NOT_SPECIFIED) {
|
||||
str += ", frame length: " + getFrameLength();
|
||||
}
|
||||
|
||||
return new String(buf);
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -376,10 +368,9 @@ public class AudioFileFormat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the file type's name as the {@code String} representation of
|
||||
* the file type.
|
||||
* Returns type's name as the string representation of the file type.
|
||||
*
|
||||
* @return the file type's name
|
||||
* @return a string representation of the file type
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -448,83 +448,47 @@ public class AudioFormat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string that describes the format, such as: "PCM SIGNED 22050 Hz
|
||||
* 16 bit mono big-endian". The contents of the string may vary between
|
||||
* implementations of Java Sound.
|
||||
* Returns a string that describes the audio format, such as: "PCM SIGNED
|
||||
* 22050 Hz 16 bit mono big-endian". The contents of the string may vary
|
||||
* between implementations of Java Sound.
|
||||
*
|
||||
* @return a string that describes the format parameters
|
||||
* @return a string representation of the audio format
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String sEncoding = "";
|
||||
if (getEncoding() != null) {
|
||||
sEncoding = getEncoding().toString() + " ";
|
||||
}
|
||||
String sampleRate = getSampleRate() == AudioSystem.NOT_SPECIFIED ?
|
||||
"unknown sample rate" : getSampleRate() + " Hz";
|
||||
|
||||
String sSampleRate;
|
||||
if (getSampleRate() == (float) AudioSystem.NOT_SPECIFIED) {
|
||||
sSampleRate = "unknown sample rate, ";
|
||||
} else {
|
||||
sSampleRate = "" + getSampleRate() + " Hz, ";
|
||||
}
|
||||
String sampleSize = getSampleSizeInBits() == AudioSystem.NOT_SPECIFIED ?
|
||||
"unknown bits per sample" : getSampleSizeInBits() + " bit";
|
||||
|
||||
String sSampleSizeInBits;
|
||||
if (getSampleSizeInBits() == (float) AudioSystem.NOT_SPECIFIED) {
|
||||
sSampleSizeInBits = "unknown bits per sample, ";
|
||||
} else {
|
||||
sSampleSizeInBits = "" + getSampleSizeInBits() + " bit, ";
|
||||
}
|
||||
String channels = switch (getChannels()) {
|
||||
case 1 -> "mono";
|
||||
case 2 -> "stereo";
|
||||
case AudioSystem.NOT_SPECIFIED -> "unknown number of channels";
|
||||
default -> getChannels() + " channels";
|
||||
};
|
||||
|
||||
String sChannels;
|
||||
if (getChannels() == 1) {
|
||||
sChannels = "mono, ";
|
||||
} else
|
||||
if (getChannels() == 2) {
|
||||
sChannels = "stereo, ";
|
||||
} else {
|
||||
if (getChannels() == AudioSystem.NOT_SPECIFIED) {
|
||||
sChannels = " unknown number of channels, ";
|
||||
} else {
|
||||
sChannels = ""+getChannels()+" channels, ";
|
||||
}
|
||||
}
|
||||
String frameSize = getFrameSize() == AudioSystem.NOT_SPECIFIED ?
|
||||
"unknown frame size" : getFrameSize() + " bytes/frame";
|
||||
|
||||
String sFrameSize;
|
||||
if (getFrameSize() == (float) AudioSystem.NOT_SPECIFIED) {
|
||||
sFrameSize = "unknown frame size, ";
|
||||
} else {
|
||||
sFrameSize = "" + getFrameSize()+ " bytes/frame, ";
|
||||
}
|
||||
|
||||
String sFrameRate = "";
|
||||
String frameRate = "";
|
||||
if (Math.abs(getSampleRate() - getFrameRate()) > 0.00001) {
|
||||
if (getFrameRate() == (float) AudioSystem.NOT_SPECIFIED) {
|
||||
sFrameRate = "unknown frame rate, ";
|
||||
} else {
|
||||
sFrameRate = getFrameRate() + " frames/second, ";
|
||||
}
|
||||
frameRate = getFrameRate() == AudioSystem.NOT_SPECIFIED ?
|
||||
", unknown frame rate":", " + getFrameRate() + " frames/second";
|
||||
}
|
||||
|
||||
String sEndian = "";
|
||||
String bigEndian = "";
|
||||
if ((getEncoding().equals(Encoding.PCM_SIGNED)
|
||||
|| getEncoding().equals(Encoding.PCM_UNSIGNED))
|
||||
&& ((getSampleSizeInBits() > 8)
|
||||
|| (getSampleSizeInBits() == AudioSystem.NOT_SPECIFIED))) {
|
||||
if (isBigEndian()) {
|
||||
sEndian = "big-endian";
|
||||
} else {
|
||||
sEndian = "little-endian";
|
||||
}
|
||||
bigEndian = isBigEndian() ? ", big-endian" : ", little-endian";
|
||||
}
|
||||
|
||||
return sEncoding
|
||||
+ sSampleRate
|
||||
+ sSampleSizeInBits
|
||||
+ sChannels
|
||||
+ sFrameSize
|
||||
+ sFrameRate
|
||||
+ sEndian;
|
||||
|
||||
return String.format("%s %s, %s, %s, %s%s%s", getEncoding(),
|
||||
sampleRate, sampleSize, channels, frameSize,
|
||||
frameRate, bigEndian);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -630,13 +594,12 @@ public class AudioFormat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the {@code String} representation of the encoding. This
|
||||
* {@code String} is the same name that was passed to the constructor.
|
||||
* Returns encoding's name as the string representation of the encoding.
|
||||
* For the predefined encodings, the name is similar to the encoding's
|
||||
* variable (field) name. For example, {@code PCM_SIGNED.toString()}
|
||||
* returns the name "PCM_SIGNED".
|
||||
*
|
||||
* @return the encoding name
|
||||
* @return a string representation of the encoding
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -119,13 +119,14 @@ public abstract class BooleanControl extends Control {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a string representation of the control.
|
||||
* Returns a string representation of the boolean control.
|
||||
*
|
||||
* @return a string representation of the control
|
||||
* @return a string representation of the boolean control
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return new String(super.toString() + " with current value: " + getStateLabel(getValue()));
|
||||
return String.format("%s with current value: %s", super.toString(),
|
||||
getStateLabel(getValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -25,6 +25,8 @@
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* A {@code CompoundControl}, such as a graphic equalizer, provides control over
|
||||
* two or more related properties, each of which is itself represented as a
|
||||
@ -61,25 +63,18 @@ public abstract class CompoundControl extends Control {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a string representation of the control.
|
||||
* Returns a string representation of the compound control.
|
||||
*
|
||||
* @return a string description
|
||||
* @return a string representation of the compound control
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < controls.length; i++) {
|
||||
if (i != 0) {
|
||||
sb.append(", ");
|
||||
if ((i + 1) == controls.length) {
|
||||
sb.append("and ");
|
||||
}
|
||||
}
|
||||
sb.append(controls[i].getType());
|
||||
StringJoiner controls = new StringJoiner(", ", "[", "]");
|
||||
for (Control control : getMemberControls()) {
|
||||
controls.add(control.getType().toString());
|
||||
}
|
||||
|
||||
return new String(getType() + " Control containing " + sb + " Controls.");
|
||||
return String.format("%s containing %s controls", super.toString(),
|
||||
controls);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -66,13 +66,13 @@ public abstract class Control {
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a string describing the control type and its current state.
|
||||
* Returns a string representation of the control.
|
||||
*
|
||||
* @return a string representation of the control
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return new String(getType() + " Control");
|
||||
return String.format("%s control", getType());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,10 +120,9 @@ public abstract class Control {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the {@code String} representation of the control type. This
|
||||
* {@code String} is the same name that was passed to the constructor.
|
||||
* Returns type's name as the string representation of the control type.
|
||||
*
|
||||
* @return the control type name
|
||||
* @return a string representation of the control type
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -475,30 +475,33 @@ public interface DataLine extends Line {
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a textual description of the data line info.
|
||||
* Returns a string representation of the info object.
|
||||
*
|
||||
* @return a string description
|
||||
* @return a string representation of the info object
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if ( (formats.length == 1) && (formats[0] != null) ) {
|
||||
sb.append(" supporting format " + formats[0]);
|
||||
} else if (getFormats().length > 1) {
|
||||
sb.append(" supporting " + getFormats().length + " audio formats");
|
||||
String format = "";
|
||||
AudioFormat[] formats = getFormats();
|
||||
if (formats.length == 1 && formats[0] != null) {
|
||||
format = " supporting format " + formats[0];
|
||||
} else if (formats.length > 1) {
|
||||
format = " supporting " + formats.length + " audio formats";
|
||||
}
|
||||
|
||||
if ( (minBufferSize != AudioSystem.NOT_SPECIFIED) && (maxBufferSize != AudioSystem.NOT_SPECIFIED) ) {
|
||||
sb.append(", and buffers of " + minBufferSize + " to " + maxBufferSize + " bytes");
|
||||
} else if ( (minBufferSize != AudioSystem.NOT_SPECIFIED) && (minBufferSize > 0) ) {
|
||||
sb.append(", and buffers of at least " + minBufferSize + " bytes");
|
||||
} else if (maxBufferSize != AudioSystem.NOT_SPECIFIED) {
|
||||
sb.append(", and buffers of up to " + minBufferSize + " bytes");
|
||||
String buffers = "";
|
||||
int min = getMinBufferSize();
|
||||
int max = getMaxBufferSize();
|
||||
if (min != AudioSystem.NOT_SPECIFIED
|
||||
&& max != AudioSystem.NOT_SPECIFIED) {
|
||||
buffers = ", and buffers of " + min + " to " + max + " bytes";
|
||||
} else if (min > 0) {
|
||||
buffers = ", and buffers of at least " + min + " bytes";
|
||||
} else if (max != AudioSystem.NOT_SPECIFIED) {
|
||||
buffers = ", and buffers of up to " + max + " bytes";
|
||||
}
|
||||
|
||||
return new String(super.toString() + sb);
|
||||
return String.format("%s%s%s", super.toString(), format, buffers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -130,13 +130,14 @@ public abstract class EnumControl extends Control {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a string representation of the control.
|
||||
* Returns a string representation of the enumerated control.
|
||||
*
|
||||
* @return a string description
|
||||
* @return a string representation of the enumerated control
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return new String(getType() + " with current value: " + getValue());
|
||||
return String.format("%s with current value: %s", super.toString(),
|
||||
getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -330,14 +330,15 @@ public abstract class FloatControl extends Control {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a string representation of the control.
|
||||
* Returns a string representation of the float control.
|
||||
*
|
||||
* @return a string description
|
||||
* @return a string representation of the float control
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return new String(getType() + " with current value: " + getValue() + " " + units +
|
||||
" (range: " + minimum + " - " + maximum + ")");
|
||||
return String.format("%s with current value: %s %s (range: %s - %s)",
|
||||
super.toString(), getValue(), getUnits(),
|
||||
getMinimum(), getMaximum());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -318,9 +318,9 @@ public interface Line extends AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a textual description of the line info.
|
||||
* Returns a string representation of the info object.
|
||||
*
|
||||
* @return a string description
|
||||
* @return a string representation of the info object
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -140,22 +140,13 @@ public class LineEvent extends EventObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a string representation of the event. The contents of the string
|
||||
* may vary between implementations of Java Sound.
|
||||
* Returns a string representation of the event.
|
||||
*
|
||||
* @return a string describing the event
|
||||
* @return a string representation of the event
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String sType = "";
|
||||
if (type != null) sType = type.toString()+" ";
|
||||
String sLine;
|
||||
if (getLine() == null) {
|
||||
sLine = "null";
|
||||
} else {
|
||||
sLine = getLine().toString();
|
||||
}
|
||||
return new String(sType + "event from line " + sLine);
|
||||
return String.format("%s event from line %s", type, getLine());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,9 +198,9 @@ public class LineEvent extends EventObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type name as the string representation.
|
||||
* Returns type's name as the string representation of the event type.
|
||||
*
|
||||
* @return the type name as the string representation
|
||||
* @return a string representation of the event type
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -349,13 +349,13 @@ public interface Mixer extends Line {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a string representation of the mixer info.
|
||||
* Returns a string representation of the info object.
|
||||
*
|
||||
* @return a string describing the info object
|
||||
* @return a string representation of the info object
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
return (name + ", version " + version);
|
||||
return String.format("%s, version %s", name, version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -199,13 +199,14 @@ public interface Port extends Line {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a {@code String} representation of the port.
|
||||
* Returns a string representation of the info object.
|
||||
*
|
||||
* @return a string that describes the port
|
||||
* @return a string representation of the info object
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
return (name + ((isSource == true) ? " source" : " target") + " port");
|
||||
return String.format("%s %s port", getName(),
|
||||
isSource() ? "source" : "target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, 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
|
||||
@ -269,21 +269,21 @@ public class ReverbType {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a {@code String} representation of the reverb type, including
|
||||
* its name and its parameter settings. The exact contents of the string may
|
||||
* vary between implementations of Java Sound.
|
||||
* Returns a string representation of the reverb type, including its name
|
||||
* and its parameter settings. The exact contents of the string may vary
|
||||
* between implementations of Java Sound.
|
||||
*
|
||||
* @return reverberation type name and description
|
||||
* @return a string representation of the reverb type
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
|
||||
//$$fb2001-07-20: fix for bug 4385060: The "name" attribute of class "ReverbType" is not accessible.
|
||||
//return (super.toString() + ", early reflection delay " + earlyReflectionDelay +
|
||||
return (name + ", early reflection delay " + earlyReflectionDelay +
|
||||
" ns, early reflection intensity " + earlyReflectionIntensity +
|
||||
" dB, late deflection delay " + lateReflectionDelay +
|
||||
" ns, late reflection intensity " + lateReflectionIntensity +
|
||||
" dB, decay time " + decayTime);
|
||||
return String.format("%s, early reflection delay %d ns, " +
|
||||
"early reflection intensity %s dB, " +
|
||||
"late deflection delay %d ns, " +
|
||||
"late reflection intensity %s dB, decay time %d",
|
||||
getName(), earlyReflectionDelay,
|
||||
earlyReflectionIntensity,
|
||||
lateReflectionDelay, lateReflectionIntensity,
|
||||
decayTime);
|
||||
}
|
||||
}
|
||||
|
38
test/jdk/javax/sound/midi/Devices/ToString.java
Normal file
38
test/jdk/javax/sound/midi/Devices/ToString.java
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.sound.midi.MidiDevice;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8236980
|
||||
*/
|
||||
public final class ToString {
|
||||
|
||||
public static void main(String[] args) {
|
||||
MidiDevice.Info info = new MidiDevice.Info("nameToTest", "", "", ""){};
|
||||
if (!info.toString().contains("nameToTest")) {
|
||||
throw new RuntimeException("wrong string: " + info);
|
||||
}
|
||||
}
|
||||
}
|
38
test/jdk/javax/sound/midi/Sequencer/ToString.java
Normal file
38
test/jdk/javax/sound/midi/Sequencer/ToString.java
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.sound.midi.Sequencer;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8236980
|
||||
*/
|
||||
public final class ToString {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Sequencer.SyncMode syncMode = new Sequencer.SyncMode("nameToTest"){};
|
||||
if (!syncMode.toString().equals("nameToTest")) {
|
||||
throw new RuntimeException("wrong string: " + syncMode);
|
||||
}
|
||||
}
|
||||
}
|
39
test/jdk/javax/sound/sampled/AudioFileFormat/ToString.java
Normal file
39
test/jdk/javax/sound/sampled/AudioFileFormat/ToString.java
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.sound.sampled.AudioFileFormat;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8236980
|
||||
*/
|
||||
public final class ToString {
|
||||
|
||||
public static void main(String[] args) {
|
||||
AudioFileFormat.Type type = new AudioFileFormat.Type("nameToTest",
|
||||
"ext") {};
|
||||
if (!type.toString().equals("nameToTest")) {
|
||||
throw new RuntimeException("wrong string: " + type);
|
||||
}
|
||||
}
|
||||
}
|
38
test/jdk/javax/sound/sampled/AudioFormat/ToString.java
Normal file
38
test/jdk/javax/sound/sampled/AudioFormat/ToString.java
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8236980
|
||||
*/
|
||||
public final class ToString {
|
||||
|
||||
public static void main(String[] args) {
|
||||
AudioFormat.Encoding enc = new AudioFormat.Encoding("nameToTest") {};
|
||||
if (!enc.toString().equals("nameToTest")) {
|
||||
throw new RuntimeException("wrong string: " + enc);
|
||||
}
|
||||
}
|
||||
}
|
38
test/jdk/javax/sound/sampled/Controls/ToString.java
Normal file
38
test/jdk/javax/sound/sampled/Controls/ToString.java
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.sound.sampled.Control;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8236980
|
||||
*/
|
||||
public final class ToString {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Control.Type type = new Control.Type("nameToTest") {};
|
||||
if (!type.toString().equals("nameToTest")) {
|
||||
throw new RuntimeException("wrong string: " + type);
|
||||
}
|
||||
}
|
||||
}
|
38
test/jdk/javax/sound/sampled/LineEvent/ToString.java
Normal file
38
test/jdk/javax/sound/sampled/LineEvent/ToString.java
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.sound.sampled.LineEvent;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8236980
|
||||
*/
|
||||
public final class ToString {
|
||||
|
||||
public static void main(String[] args) {
|
||||
LineEvent.Type type = new LineEvent.Type("nameToTest") {};
|
||||
if (!type.toString().equals("nameToTest")) {
|
||||
throw new RuntimeException("wrong string: " + type);
|
||||
}
|
||||
}
|
||||
}
|
38
test/jdk/javax/sound/sampled/ReverbType/ToString.java
Normal file
38
test/jdk/javax/sound/sampled/ReverbType/ToString.java
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.sound.sampled.ReverbType;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 4385060 8236980
|
||||
*/
|
||||
public final class ToString {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ReverbType type = new ReverbType("nameToTest", 0, 0, 0, 0, 0) {};
|
||||
if (!type.toString().startsWith("nameToTest")) {
|
||||
throw new RuntimeException("wrong string: " + type);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user