Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Name: nt126004 Date: 03/26/2003 A DESCRIPTION OF THE REQUEST : RFE With the introduction of the CharSequence interface, the String class is no longer the lowest-common-denominator for character data, and yet String arguments are still a pervasive requirement throughout the API. All API methods currently specifying String arguments should be relaxed to CharSequence arguments unless they require immutability, equals(), hashCode(), or other String-specific behavior. This change would not affect any existing code. Here are a few candidate methods found by simply searching the API for the string, err, I mean the CharSequence ;-) ---> "(String" StringBuffer(String str) StringBuffer.append(String str) //related Bug Id 4812591 StringBuffer.append(StringBuffer sb) //related Bug Id 4812591 StringBuffer.indexOf(String str) StringBuffer.lastIndexOf(String str, int fromIndex) java.io.StringReader(String s) // CharSequenceReader? JTextComponent.replaceSelection(String content) JTextComponent.setText(String t) JEditorPane.setText(String text) JTextArea(String text) JTextArea(String text, int rows, int columns) JTextArea.append(String str) JTextArea.insert(String str, int pos) JTextArea.replaceRange(String str, int start, int end) JEditorPane(String url) JEditorPane(String type, String text) JList.getNextMatch(String prefix, int startIndex, Position.Bias bias) AbstractWriter.setLineSeparator(String value) AbstractWriter.write(String content) Integer(String s) Integer.parseInt(String s) Integer.valueOf(String s) Double(String s) Double.parseDouble(String s) StringTokenizer.nextToken(String delim) JUSTIFICATION : This enhancement would eliminate creation and garbage-collection of superfluous String objects when text is stored in a some other implementation of CharSequence. EXPECTED VERSUS ACTUAL BEHAVIOR : Component makeTextArea(CharSequence chars){ return new javax.swing.JTextArea(chars); } Component makeTextArea(CharSequence chars){ return new javax.swing.JTextArea(chars.toString()); } CUSTOMER SUBMITTED WORKAROUND : Use charSequence.toString() wherever a String object is required. (Review ID: 183002) ======================================================================
|