bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r996740 - /incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/PathNavigation.java
Date Tue, 14 Sep 2010 02:42:15 GMT
Author: mbenson
Date: Tue Sep 14 02:42:15 2010
New Revision: 996740

URL: http://svn.apache.org/viewvc?rev=996740&view=rev
Log:
assume an empty/null path is root; simplify and thus make more broadly applicable the error
message thrown

Modified:
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/PathNavigation.java

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/PathNavigation.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/PathNavigation.java?rev=996740&r1=996739&r2=996740&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/PathNavigation.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/PathNavigation.java
Tue Sep 14 02:42:15 2010
@@ -20,12 +20,14 @@ import java.util.StringTokenizer;
 
 import javax.validation.ValidationException;
 
+import org.apache.commons.lang3.StringUtils;
+
 /**
  * Defines a path navigation algorithm and a means of interacting with same.
  * 
  * @version $Rev$ $Date$
  */
-//TODO share code with PathImpl
+// TODO share code with PathImpl
 public class PathNavigation {
 
     /**
@@ -88,12 +90,13 @@ public class PathNavigation {
      * 
      * @param <T>
      * @param propertyPath
+     *            , null is assumed empty/root
      * @param callback
      * @return T result
      */
     public static <T> T navigateAndReturn(String propertyPath, Callback<? extends
T> callback) {
         try {
-            StringTokenizer tokens = new StringTokenizer(propertyPath, ".[]", true);
+            StringTokenizer tokens = new StringTokenizer(StringUtils.defaultString(propertyPath),
".[]", true);
             while (tokens.hasMoreTokens()) {
                 String token = tokens.nextToken();
                 if (".".equals(token)) {
@@ -117,7 +120,7 @@ public class PathNavigation {
         } catch (ValidationException ex) {
             throw ex;
         } catch (Exception ex) {
-            throw new ValidationException("invalid property format: " + propertyPath, ex);
+            throw new ValidationException("invalid property: " + propertyPath, ex);
         }
     }
 



Mime
View raw message