If you have code like this:
configuration.addProperty("prop", "string1");
configuration.addProperty("prop", "string2");String value = configuration.getString("prop");How should the latter call be treated? I think ATM an exception will be thrown because the value of "prop" is a list rather than a string. An alternative approach would be that this call returned the first string in the list because the property has multiple values of type string (which may be appropriate for some use cases).
On the other hand if the code ran:
List l = ...;
configuration.setProperty("prop", l);
String value = configuration.getString("prop");Then then property's value is really a list, which cannot be converted to string.
So if we want to implement the getter methods in a way that they return the first value if there are multiple, then such a Container class would be needed to make a distinction. I would prefer such an approach and would like to know what others think.
Oliver
Emmanuel Bourg schrieb:
Oliver Heger wrote:
A related question is the behavior of getProperty() if the requested property has multiple values. At the moment the Container class is used to make a difference whether the property has a single value of type Collection or multiple values.
I'm not sure to understand the difference between a multiple value property and a Collection value, isn't this the same ?
If Container is removed, getProperty would be reduced from this:
public Object getProperty(String key) { Object o = getPropertyDirect(key);
if (o instanceof Container) { o = ((Container) o).asList(); } return o; }
to this:
public Object getProperty(String key) { return getPropertyDirect(key); }
Emmanuel Bourg
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Dipl.-Inform. Oliver Heger Zentrale Informationsverarbeitung (ZIV) / Bereich Anwenderverfahren Klinikum der Philipps-Universit�t Marburg Bunsenstra�e 3, D-35037 Marburg Tel: +49 6421 28-66592 mailto:[EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
