< prev index next >
src/java.desktop/share/classes/javax/sound/sampled/LineEvent.java
Print this page
rev 57600 : 8236980: toString() cleanup in JavaSound
Reviewed-by: XXX
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -138,26 +138,17 @@
public final long getFramePosition() {
return position;
}
/**
- * 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());
}
/**
* The LineEvent.Type inner class identifies what kind of event occurred on
* a line. Static instances are provided for the common types (OPEN, CLOSE,
@@ -205,13 +196,13 @@
public final int hashCode() {
return super.hashCode();
}
/**
- * 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() {
return name;
}
< prev index next >