Reviewers: cromwellian,

Description:
getValue returns null on unparsable value, and getValueOrThrow allows
access to the ParseException

Review by: [email protected]

Please review this at http://gwt-code-reviews.appspot.com/510801/show

Affected files:
  M /bikeshed/src/com/google/gwt/user/client/ui/ValueBoxBase.java


Index: /bikeshed/src/com/google/gwt/user/client/ui/ValueBoxBase.java
===================================================================
--- /bikeshed/src/com/google/gwt/user/client/ui/ValueBoxBase.java (revision 8094) +++ /bikeshed/src/com/google/gwt/user/client/ui/ValueBoxBase.java (working copy)
@@ -15,6 +15,7 @@
  */
 package com.google.gwt.user.client.ui;

+import com.google.gwt.app.util.ParseException;
 import com.google.gwt.app.util.Parser;
 import com.google.gwt.app.util.Renderer;
 import com.google.gwt.core.client.GWT;
@@ -137,7 +138,22 @@
     return DOM.getElementProperty(getElement(), "value");
   }

+  /**
+   * Return the parsed value, or null if parsing fails.
+   */
   public T getValue() {
+    try {
+      return getValueOrThrow();
+    } catch (ParseException e) {
+      return null;
+    }
+  }
+
+  /**
+   * Return the parsed value.
+   * @throws ParseException if the value cannot be parsed
+   */
+  public T getValueOrThrow() throws ParseException {
     return parser.parse(getText());
   }



--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to