commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r588103 - in /commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines: EmailValidator.java UrlValidator.java
Date Thu, 25 Oct 2007 01:21:01 GMT
Author: niallp
Date: Wed Oct 24 18:21:00 2007
New Revision: 588103

URL: http://svn.apache.org/viewvc?rev=588103&view=rev
Log:
VALIDATOR-203 / VALIDATOR-242 - re-add new routines versions of URL and Email validators (preserving
the commit history)

Added:
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
      - copied, changed from r587279, commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/EmailValidator.java
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
      - copied, changed from r587279, commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/UrlValidator.java

Copied: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
(from r587279, commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/EmailValidator.java)
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/EmailValidator.java?p2=commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/EmailValidator.java&p1=commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/EmailValidator.java&r1=587279&r2=588103&rev=588103&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/EmailValidator.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
Wed Oct 24 18:21:00 2007
@@ -14,9 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.validator;
+package org.apache.commons.validator.routines;
 
-import org.apache.commons.validator.routines.InetAddressValidator;
 import org.apache.oro.text.perl.Perl5Util;
 
 import java.util.regex.Matcher;
@@ -38,7 +37,7 @@
  * </p>.
  *
  * @version $Revision$ $Date$
- * @since Validator 1.1
+ * @since Validator 1.4
  */
 public class EmailValidator {
 
@@ -53,7 +52,7 @@
     private static final String EMAIL_PATTERN = "/^(.+)@(.+)$/";
     private static final String IP_DOMAIN_PATTERN = "^\\[(.*)\\]$";
     private static final String TLD_PATTERN = "/^([a-zA-Z]+)$/";
-            
+
     private static final String USER_PATTERN = "/^\\s*" + WORD + "(\\." + WORD + ")*$/";
     private static final String DOMAIN_PATTERN = "/^" + ATOM + "(\\." + ATOM + ")*\\s*$/";
     private static final String ATOM_PATTERN = "/(" + ATOM + ")/";
@@ -164,34 +163,6 @@
     }
 
     /**
-     * Validates an IP address. Returns true if valid.
-     * @param ipAddressMatcher Pattren matcher
-     * @return true if the ip address is valid.
-     */
-    protected boolean isValidIpAddress(Perl5Util ipAddressMatcher) {
-        for (int i = 1; i <= 4; i++) {
-            String ipSegment = ipAddressMatcher.group(i);
-            if (ipSegment == null || ipSegment.length() <= 0) {
-                return false;
-            }
-
-            int iIpSegment = 0;
-
-            try {
-                iIpSegment = Integer.parseInt(ipSegment);
-            } catch(NumberFormatException e) {
-                return false;
-            }
-
-            if (iIpSegment > 255) {
-                return false;
-            }
-
-        }
-        return true;
-    }
-
-    /**
      * Validates a symbolic domain name.  Returns true if it's valid.
      * @param domain symbolic domain name
      * @return true if the symbolic domain name is valid.
@@ -212,17 +183,17 @@
                         : domain.substring(l);
 
                 i++;
-            } 
+            }
         }
 
         int len = i;
-        
+
         // Make sure there's a host name preceding the domain.
         if (len < 2) {
             return false;
         }
-        
-        // TODO: the tld should be checked against some sort of configurable 
+
+        // TODO: the tld should be checked against some sort of configurable
         // list
         String tld = domainSegment[len - 1];
         if (tld.length() > 1) {

Copied: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
(from r587279, commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/UrlValidator.java)
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java?p2=commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java&p1=commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/UrlValidator.java&r1=587279&r2=588103&rev=588103&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/UrlValidator.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
Wed Oct 24 18:21:00 2007
@@ -14,17 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.validator;
+package org.apache.commons.validator.routines;
+
+import org.apache.commons.validator.GenericValidator;
+import org.apache.commons.validator.util.Flags;
+import org.apache.oro.text.perl.Perl5Util;
 
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.commons.validator.routines.InetAddressValidator;
-import org.apache.commons.validator.util.Flags;
-import org.apache.oro.text.perl.Perl5Util;
-
 /**
  * <p>Validates URLs.</p>
  * Behavour of validation is modified by passing in options:
@@ -69,12 +69,12 @@
  * </a>
  *
  * @version $Revision$ $Date$
- * @since Validator 1.1
+ * @since Validator 1.4
  */
 public class UrlValidator implements Serializable {
 
     /**
-     * Allows all validly formatted schemes to pass validation instead of 
+     * Allows all validly formatted schemes to pass validation instead of
      * supplying a set of valid schemes.
      */
     public static final int ALLOW_ALL_SCHEMES = 1 << 0;



Mime
View raw message