You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Adam Heath <do...@brainfood.com> on 2009/09/08 02:44:06 UTC

Re: svn commit: r812313 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java

lektran@apache.org wrote:
> Author: lektran
> Date: Tue Sep  8 00:40:57 2009
> New Revision: 812313
> 
> Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java?rev=812313&r1=812312&r2=812313&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java (original)
> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java Tue Sep  8 00:40:57 2009
> @@ -1298,19 +1298,32 @@
>      }
>  
>      public static char calcUpcChecksum(String upc) {
> -        if (upc != null && upc.length() == 12) {
> -            upc = upc.substring(0, 11);
> +        return calcChecksum(upc, 12);
> +    }
> +
> +    public static boolean isValidEan(String ean) {
> +        if (ean == null || ean.length() != 13) {
> +            throw new IllegalArgumentException("Invalid UPC length; must be 12 characters");

s/UPC/EAN/

.

Re: svn commit: r812313 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Thanks!

Regards
Scott

On 8/09/2009, at 12:44 PM, Adam Heath wrote:

> lektran@apache.org wrote:
>> Author: lektran
>> Date: Tue Sep  8 00:40:57 2009
>> New Revision: 812313
>>
>> Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ 
>> UtilValidate.java
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java?rev=812313&r1=812312&r2=812313&view=diff
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ 
>> UtilValidate.java (original)
>> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ 
>> UtilValidate.java Tue Sep  8 00:40:57 2009
>> @@ -1298,19 +1298,32 @@
>>     }
>>
>>     public static char calcUpcChecksum(String upc) {
>> -        if (upc != null && upc.length() == 12) {
>> -            upc = upc.substring(0, 11);
>> +        return calcChecksum(upc, 12);
>> +    }
>> +
>> +    public static boolean isValidEan(String ean) {
>> +        if (ean == null || ean.length() != 13) {
>> +            throw new IllegalArgumentException("Invalid UPC  
>> length; must be 12 characters");
>
> s/UPC/EAN/
>
> .