-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
1.0
-
sparc
-
generic
I know the interfaces are supposed to be frozen, but ...
It would be good if arbitrary objects could be associated with the
entries in a List class.
In the old days, this would be done by having client data entries
associated with each list entry, and all the reasons that clientData
has been provided in the past are appropriate justification for the
suggestion enhancement here.
In these more enlightened OO days, an interesting and easy to implement
alternative to client data would be to store java.lang.Objects on the
List, and judicially use toString() at the necessary times when a
String is actually required. This would require a simple and upward
compatible change for the addEntry replaceEntry methods. For backward
compatability, getItem could still return a String, but there could be
a new method to get the item as a raw Object.
Such an approach fits in easily with the current implementation, which
already uses a Vector (of java.lang.Objects) to store the String
objects.
-- Jon
It would be good if arbitrary objects could be associated with the
entries in a List class.
In the old days, this would be done by having client data entries
associated with each list entry, and all the reasons that clientData
has been provided in the past are appropriate justification for the
suggestion enhancement here.
In these more enlightened OO days, an interesting and easy to implement
alternative to client data would be to store java.lang.Objects on the
List, and judicially use toString() at the necessary times when a
String is actually required. This would require a simple and upward
compatible change for the addEntry replaceEntry methods. For backward
compatability, getItem could still return a String, but there could be
a new method to get the item as a raw Object.
Such an approach fits in easily with the current implementation, which
already uses a Vector (of java.lang.Objects) to store the String
objects.
-- Jon
- duplicates
-
JDK-4038823 java.awt.List & java.awt.Choice should contain Objects not just Strings
- Closed