]> source.dussan.org Git - vaadin-framework.git/commitdiff
Removed getStringValue based on API review meeting
authorArtur Signell <artur@vaadin.com>
Thu, 22 Dec 2011 06:27:52 +0000 (08:27 +0200)
committerJens Jansson <peppe@vaadin.com>
Thu, 22 Dec 2011 07:53:12 +0000 (09:53 +0200)
12 files changed:
src/com/vaadin/data/util/AbstractProperty.java
src/com/vaadin/data/util/IndexedContainer.java
src/com/vaadin/data/util/PropertyFormatter.java
src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java
src/com/vaadin/ui/AbstractField.java
src/com/vaadin/ui/AbstractTextField.java
src/com/vaadin/ui/ProgressIndicator.java
src/com/vaadin/ui/RichTextArea.java
tests/testbench/com/vaadin/tests/TestForContainerFilterable.java
tests/testbench/com/vaadin/tests/components/datefield/DefaultHandleUnparsableDateField.java
tests/testbench/com/vaadin/tests/tickets/Ticket2053.java
tests/testbench/com/vaadin/tests/tickets/Ticket2090.java

index 5e90d11831b9478b8cdcf3463cfce0a9ed30a194..3b6db3807e9c641311e14699eed8fc66b0968d32 100644 (file)
@@ -59,8 +59,7 @@ public abstract class AbstractProperty<T> implements Property<T>,
      * format.
      * 
      * @return String representation of the value stored in the Property
-     * @deprecated use the property value directly, or {@link #getStringValue()}
-     *             during migration period
+     * @deprecated use {@link #getValue()} instead and possibly toString on that
      */
     @Deprecated
     @Override
@@ -70,21 +69,6 @@ public abstract class AbstractProperty<T> implements Property<T>,
                         + ".toString()");
     }
 
-    /**
-     * Returns the value of the <code>Property</code> in human readable textual
-     * format.
-     * 
-     * @return String representation of the value stored in the Property
-     * @since 7.0
-     */
-    public String getStringValue() {
-        final Object value = getValue();
-        if (value == null) {
-            return null;
-        }
-        return value.toString();
-    }
-
     /* Events */
 
     /**
index 424fccb1e9c9c33da0a1a9a2a39e7380a8cac910..1e0a2fae1a07d550c777584099e9d36f391b87a9 100644 (file)
@@ -894,8 +894,8 @@ public class IndexedContainer extends
          * 
          * @return <code>String</code> representation of the value stored in the
          *         Property
-         * @deprecated use the property value directly, or
-         *             {@link #getStringValue()} during migration period
+         * @deprecated use {@link #getValue()} instead and possibly toString on
+         *             that
          */
         @Deprecated
         @Override
@@ -904,21 +904,6 @@ public class IndexedContainer extends
                     "Use Property.getValue() instead of IndexedContainerProperty.toString()");
         }
 
-        /**
-         * Returns the value of the <code>Property</code> in human readable
-         * textual format.
-         * 
-         * @return String representation of the value stored in the Property
-         * @since 7.0
-         */
-        public String getStringValue() {
-            final Object value = getValue();
-            if (value == null) {
-                return null;
-            }
-            return value.toString();
-        }
-
         /**
          * Calculates a integer hash-code for the Property that's unique inside
          * the Item containing the Property. Two different Properties inside the
index e126d97d3cf23f00c7eb9adb5b35563b3af90c16..a63973535bf060898e218fb5172ea72f17ec1b0b 100644 (file)
@@ -106,7 +106,7 @@ public abstract class PropertyFormatter<T> extends AbstractProperty<String>
                         .removeListener(this);
             }
             readOnly = isReadOnly();
-            prevValue = getStringValue();
+            prevValue = getValue();
         }
 
         dataSource = newDataSource;
@@ -124,7 +124,7 @@ public abstract class PropertyFormatter<T> extends AbstractProperty<String>
         if (isReadOnly() != readOnly) {
             fireReadOnlyStatusChange();
         }
-        String newVal = getStringValue();
+        String newVal = getValue();
         if ((prevValue == null && newVal != null)
                 || (prevValue != null && !prevValue.equals(newVal))) {
             fireValueChange();
@@ -143,18 +143,6 @@ public abstract class PropertyFormatter<T> extends AbstractProperty<String>
      *         String given by format().
      */
     public String getValue() {
-        return getStringValue();
-    }
-
-    /**
-     * Get the formatted value. For PropertyFormatter, this is identical with
-     * {@link #getValue()}.
-     * 
-     * @return If the datasource returns null, this is null. Otherwise this is
-     *         String given by format().
-     */
-    @Override
-    public String getStringValue() {
         T value = dataSource == null ? null : dataSource.getValue();
         if (value == null) {
             return null;
@@ -219,7 +207,7 @@ public abstract class PropertyFormatter<T> extends AbstractProperty<String>
         } else {
             try {
                 dataSource.setValue(parse(newValue.toString()));
-                if (!newValue.equals(getStringValue())) {
+                if (!newValue.equals(getValue())) {
                     fireValueChange();
                 }
             } catch (Exception e) {
index 5e152da79e7e9c76fe2237133c72a69c8e64ed2b..a74db6ce8a9098c92790df155a72377ac93abdb8 100644 (file)
@@ -160,8 +160,7 @@ final public class ColumnProperty implements Property {
      * Returns the value of the Property in human readable textual format.
      * 
      * @see java.lang.Object#toString()
-     * @deprecated get the string representation from the value, or use
-     *             getStringValue() during migration
+     * @deprecated get the string representation from the value
      */
     @Deprecated
     @Override
@@ -170,26 +169,6 @@ final public class ColumnProperty implements Property {
                 "Use ColumnProperty.getValue() instead of ColumnProperty.toString()");
     }
 
-    /**
-     * Returns the (UI type) value of the field converted to a String using
-     * toString().
-     * 
-     * This method exists to help migration from the use of Property.toString()
-     * to get the field value - for new applications, access getValue()
-     * directly. This method may disappear in future Vaadin versions.
-     * 
-     * @return string representation of the field value or null if the value is
-     *         null
-     * @since 7.0
-     */
-    public String getStringValue() {
-        final Object value = getValue();
-        if (value == null) {
-            return null;
-        }
-        return value.toString();
-    }
-
     public void setOwner(RowItem owner) {
         if (owner == null) {
             throw new IllegalArgumentException("Owner can not be set to null.");
index cbdee0eae1d7c0f9d253a45b4befba2d30c0738d..3e75da5ae28a58a5ec2f944e8820f3e462b4c7cc 100644 (file)
@@ -13,6 +13,7 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.logging.Logger;
 
 import com.vaadin.Application;
 import com.vaadin.data.Buffered;
@@ -63,6 +64,9 @@ public abstract class AbstractField<T> extends AbstractComponent implements
 
     /* Private members */
 
+    private static final Logger logger = Logger.getLogger(AbstractField.class
+            .getName());
+
     /**
      * Value of the abstract field.
      */
@@ -340,16 +344,20 @@ public abstract class AbstractField<T> extends AbstractComponent implements
         }
     }
 
+    /**
+     * Gets the value from the data source. This is only here because of clarity
+     * in the code that handles both the data model value and the field value.
+     * 
+     * @return The value of the property data source
+     */
     private Object getDataSourceValue() {
         return dataSource.getValue();
     }
 
     /**
-     * Returns the value that is or should be displayed in the field. This is
-     * always of type T.
-     * 
-     * This method should return the converter data source value if there are no
-     * buffered changes in the field.
+     * Returns the field value. This is always identical to {@link #getValue()}
+     * and only here because of clarity in the code that handles both the data
+     * model value and the field value.
      * 
      * @return The value of the field
      */
@@ -488,32 +496,21 @@ public abstract class AbstractField<T> extends AbstractComponent implements
     /* Property interface implementation */
 
     /**
-     * Returns the value of the Property in human readable textual format.
+     * Returns the (field) value converted to a String using toString().
      * 
      * @see java.lang.Object#toString()
-     * @deprecated get the string representation from the data source, or use
-     *             getStringValue() during migration
+     * @deprecated Instead use {@link #getValue()} to get the value of the
+     *             field, {@link #getConvertedValue()} to get the field value
+     *             converted to the data model type or
+     *             {@link #getPropertyDataSource()} .getValue() to get the value
+     *             of the data source.
      */
     @Deprecated
     @Override
     public String toString() {
-        throw new UnsupportedOperationException(
-                "Use Property.getValue() instead of " + getClass()
-                        + ".toString()");
-    }
-
-    /**
-     * Returns the (UI type) value of the field converted to a String.
-     * 
-     * This method exists to help migration from the use of Property.toString()
-     * to get the field value. For new applications, it is often better to
-     * access getValue() directly.
-     * 
-     * @return string representation of the field value or null if the value is
-     *         null
-     * @since 7.0
-     */
-    public String getStringValue() {
+        logger.warning("You are using AbstractField.toString() to get the value for a "
+                + getClass().getSimpleName()
+                + ". This is not recommended and will not be supported in future versions.");
         final Object value = getFieldValue();
         if (value == null) {
             return null;
index 7d2509b978083c652d1ec1daefef334b0c04c2ce..96d8a1141012c767d61ca366010aab739eca82ba 100644 (file)
@@ -375,7 +375,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
 
     @Override
     protected boolean isEmpty() {
-        return super.isEmpty() || getStringValue().length() == 0;
+        return super.isEmpty() || getValue().length() == 0;
     }
 
     /**
index 30555f942725a9409ddcff091eb72f2da30f1e0e..cc17333cc42d181dd4a5d7d727fcf6964bf66a60 100644 (file)
@@ -149,17 +149,6 @@ public class ProgressIndicator extends AbstractField<Number> implements
         dataSource.setValue(newValue);
     }
 
-    /**
-     * @see com.vaadin.ui.AbstractField#toString()
-     * @deprecated use the data source value instead of toString()
-     */
-    @Deprecated
-    @Override
-    public String toString() {
-        throw new UnsupportedOperationException(
-                "Use Property.getValue() instead of ProgressIndicator.toString()");
-    }
-
     /**
      * @see com.vaadin.ui.AbstractField#getType()
      */
index 1ef843b789832289433d13025d5e73ba8d2f615a..ea22a6b54b602b27e55f4df52b1df3d5f5896b74 100644 (file)
@@ -343,7 +343,7 @@ public class RichTextArea extends AbstractField<String> {
 
     @Override
     protected boolean isEmpty() {
-        return super.isEmpty() || getStringValue().length() == 0;
+        return super.isEmpty() || getValue().length() == 0;
     }
 
 }
index 6a61674e9b11c851ed0fca73b0da34f40e575c63..92b7ae4f6213b16aafcd58aaf7b892e13d88c0be 100644 (file)
@@ -62,12 +62,12 @@ public class TestForContainerFilterable extends CustomComponent {
         filterButton.addListener(new Button.ClickListener() {
             public void buttonClick(ClickEvent event) {
                 ic.removeAllContainerFilters();
-                if (fooFilter.getStringValue().length() > 0) {
-                    ic.addContainerFilter("foo", fooFilter.getStringValue(), false,
+                if (fooFilter.getValue().length() > 0) {
+                    ic.addContainerFilter("foo", fooFilter.getValue(), false,
                             false);
                 }
-                if (barFilter.getStringValue().length() > 0) {
-                    ic.addContainerFilter("bar", barFilter.getStringValue(), true,
+                if (barFilter.getValue().length() > 0) {
+                    ic.addContainerFilter("bar", barFilter.getValue(), true,
                             true);
                 }
                 count.setValue("Rows in table: " + ic.size());
index 14c0198270d970e3a95b1abb7c01b6e59334f667..060c7fcc0a9c766246426449da0a93ad4df3c262 100644 (file)
@@ -17,7 +17,8 @@ public class DefaultHandleUnparsableDateField extends TestBase {
         date.addListener(new Property.ValueChangeListener() {
             public void valueChange(ValueChangeEvent event) {
                 if (date.isValid()) {
-                    getMainWindow().showNotification(date.getStringValue());
+                    getMainWindow()
+                            .showNotification(date.getValue().toString());
                 }
 
             }
index a2ff1816e0df49f81f7bbed2e6f2b314cb79c7ef..751dbbae01440f6928db2e0aec389978cb7c84be 100644 (file)
@@ -37,7 +37,7 @@ public class Ticket2053 extends Application.LegacyApplication {
                 tf.addListener(new Property.ValueChangeListener() {
                     public void valueChange(ValueChangeEvent event) {
                         main.addComponent(new Label(name + " send text:"
-                                + tf.getStringValue()));
+                                + tf.getValue()));
                     }
                 });
                 for (int i = 0; i < 3; i++) {
index ea94635931b06187dfd6f0e5e9585c27b7a004f4..b4171b9baca455f5a113adc934a4646f8c1f3dd0 100644 (file)
@@ -29,7 +29,7 @@ public class Ticket2090 extends Application.LegacyApplication {
         height.addListener(new Property.ValueChangeListener() {
             public void valueChange(ValueChangeEvent event) {
                 try {
-                    target.setHeight(height.getStringValue());
+                    target.setHeight(height.getValue());
                     height.setComponentError(null);
                     updateLabel();
                 } catch (Exception e) {
@@ -40,7 +40,7 @@ public class Ticket2090 extends Application.LegacyApplication {
         width.addListener(new Property.ValueChangeListener() {
             public void valueChange(ValueChangeEvent event) {
                 try {
-                    target.setWidth(width.getStringValue());
+                    target.setWidth(width.getValue());
                     width.setComponentError(null);
                     updateLabel();
                 } catch (Exception e) {