diff options
author | Henri Sara <hesara@vaadin.com> | 2011-11-08 11:24:12 +0200 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2011-11-08 11:24:12 +0200 |
commit | a61302616430cbbfc97cbdbb85fe294842b3409c (patch) | |
tree | dcca942cdad8fc09680effc7269819faea75a6e1 /src | |
parent | b2f5e652227dd4468622b092a8197afa8ee9b65f (diff) | |
download | vaadin-framework-a61302616430cbbfc97cbdbb85fe294842b3409c.tar.gz vaadin-framework-a61302616430cbbfc97cbdbb85fe294842b3409c.zip |
Eliminate more cases that used Property.toString().
Remaining possibly problematic cases include Label.compareTo(),
TestForPreconfiguredComponents and TestForTrees.
Diffstat (limited to 'src')
-rw-r--r-- | src/com/vaadin/data/util/IndexedContainer.java | 7 | ||||
-rw-r--r-- | src/com/vaadin/ui/AbstractField.java | 8 | ||||
-rw-r--r-- | src/com/vaadin/ui/AbstractSelect.java | 5 | ||||
-rw-r--r-- | src/com/vaadin/ui/Label.java | 14 |
4 files changed, 21 insertions, 13 deletions
diff --git a/src/com/vaadin/data/util/IndexedContainer.java b/src/com/vaadin/data/util/IndexedContainer.java index c9499d4aa8..a6e03970cc 100644 --- a/src/com/vaadin/data/util/IndexedContainer.java +++ b/src/com/vaadin/data/util/IndexedContainer.java @@ -691,8 +691,8 @@ public class IndexedContainer extends /** * Gets the <code>String</code> representation of the contents of the * Item. The format of the string is a space separated catenation of the - * <code>String</code> representations of the Properties contained by - * the Item. + * <code>String</code> representations of the values of the Properties + * contained by the Item. * * @return <code>String</code> representation of the Item contents */ @@ -702,8 +702,7 @@ public class IndexedContainer extends for (final Iterator<?> i = propertyIds.iterator(); i.hasNext();) { final Object propertyId = i.next(); - // TODO do not use Property.toString() - retValue += getItemProperty(propertyId).toString(); + retValue += getItemProperty(propertyId).getValue(); if (i.hasNext()) { retValue += " "; } diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java index 007f851a72..7b686fd397 100644 --- a/src/com/vaadin/ui/AbstractField.java +++ b/src/com/vaadin/ui/AbstractField.java @@ -299,7 +299,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, // Discards buffer by overwriting from datasource newValue = dataSource.getValue(); - if (String.class == getType()) { + if (String.class == getType() && newValue != null) { newValue = newValue.toString(); } @@ -390,7 +390,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, readThroughMode = readThrough; if (!isModified() && readThroughMode && dataSource != null) { Object newValue = dataSource.getValue(); - if (String.class == getType()) { + if (String.class == getType() && newValue != null) { newValue = newValue.toString(); } setInternalValue(newValue); @@ -468,7 +468,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, } Object result = dataSource.getValue(); - if (String.class == getType()) { + if (String.class == getType() && result != null) { result = result.toString(); } return result; @@ -640,7 +640,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, try { if (dataSource != null) { Object newValue = dataSource.getValue(); - if (String.class == getType()) { + if (String.class == getType() && newValue != null) { newValue = newValue.toString(); } setInternalValue(newValue); diff --git a/src/com/vaadin/ui/AbstractSelect.java b/src/com/vaadin/ui/AbstractSelect.java index 646d898a54..eaac3bb4c5 100644 --- a/src/com/vaadin/ui/AbstractSelect.java +++ b/src/com/vaadin/ui/AbstractSelect.java @@ -1080,7 +1080,10 @@ public abstract class AbstractSelect extends AbstractField implements final Property p = getContainerProperty(itemId, getItemCaptionPropertyId()); if (p != null) { - caption = p.toString(); + Object value = p.getValue(); + if (value != null) { + caption = value.toString(); + } } break; } diff --git a/src/com/vaadin/ui/Label.java b/src/com/vaadin/ui/Label.java index c7504230e3..1249f20a62 100644 --- a/src/com/vaadin/ui/Label.java +++ b/src/com/vaadin/ui/Label.java @@ -257,16 +257,22 @@ public class Label extends AbstractComponent implements Property, } /** - * TODO temporary method to help eliminate the use of toString() + * Returns the value of the <code>Property</code> in human readable textual + * format. * - * @return + * This method exists to help migration from previous Vaadin versions by + * providing a simple replacement for {@link #toString()}. However, it is + * normally better to use the value of the label directly. + * + * @return String representation of the value stored in the Property + * @since 7.0 */ public String getStringValue() { if (dataSource == null) { throw new IllegalStateException(DATASOURCE_MUST_BE_SET); } - // TODO do not use Property.toString() - return dataSource.toString(); + Object value = dataSource.getValue(); + return (null != value) ? value.toString() : null; } /** |