< prev index next >

src/java.desktop/share/classes/javax/sound/sampled/CompoundControl.java

Print this page
rev 57600 : 8236980: toString() cleanup in JavaSound
Reviewed-by: XXX

*** 1,7 **** /* ! * Copyright (c) 1999, 2018, 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, 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. Oracle designates this
*** 23,32 **** --- 23,34 ---- * questions. */ 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 * {@code Control}. *
*** 59,87 **** public Control[] getMemberControls() { return controls.clone(); } /** ! * Provides a string representation of the control. * ! * @return a string description */ @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()); ! } ! ! return new String(getType() + " Control containing " + sb + " Controls."); } /** * An instance of the {@code CompoundControl.Type} inner class identifies * one kind of compound control. --- 61,82 ---- public Control[] getMemberControls() { return controls.clone(); } /** ! * Returns a string representation of the compound control. * ! * @return a string representation of the compound control */ @Override public String toString() { ! StringJoiner controls = new StringJoiner(", ", "[", "]"); ! for (Control control : getMemberControls()) { ! controls.add(control.getType().toString()); } ! return String.format("%s containing %s controls", super.toString(), ! controls); } /** * An instance of the {@code CompoundControl.Type} inner class identifies * one kind of compound control.
< prev index next >