XS bindings for bounded integral types fail with to encode values larger than 
Integer.MAX_VALUE
-----------------------------------------------------------------------------------------------

                 Key: GEOT-2767
                 URL: http://jira.codehaus.org/browse/GEOT-2767
             Project: GeoTools
          Issue Type: Bug
          Components: ext xml-xsd
    Affects Versions: 2.6-M3
            Reporter: Gabriel Roldán
            Assignee: Gabriel Roldán
             Fix For: 2.6-RC1


The xs bindings for integral types with restricted value space do fail 
to parse/encode due to some checks value range using its Java integer 
value rather than the long one, when the actual value exceeds the Java 
integer value range. The xsd value ranges for these types as -Ininity..0 
or 0..Infinity, so it makes more sense to make the checks over their 
Java long values.

Here's a patch:
{code}
Index: src/main/java/org/geotools/xs/bindings/XSNegativeIntegerBinding.java
===================================================================
--- 
src/main/java/org/geotools/xs/bindings/XSNegativeIntegerBinding.java 
(revision 34084)
+++ 
src/main/java/org/geotools/xs/bindings/XSNegativeIntegerBinding.java 
(working copy)
@@ -85,7 +85,7 @@
          throws Exception {
          Number number = (Number) value;

-        if (number.intValue() == 0) {
+        if (number.longValue() == 0) {
              throw new IllegalArgumentException("negativeInteger value 
'" + number
                  + "' required to be negative");
          }
Index: 
src/main/java/org/geotools/xs/bindings/XSNonNegativeIntegerBinding.java
===================================================================
--- 
src/main/java/org/geotools/xs/bindings/XSNonNegativeIntegerBinding.java 
(revision 34084)
+++ 
src/main/java/org/geotools/xs/bindings/XSNonNegativeIntegerBinding.java 
(working copy)
@@ -119,7 +119,7 @@
      public String encode(Object object, String value) throws Exception {
          Number number = (Number) object;

-        if (number.intValue() < 0) {
+        if (number.longValue() < 0) {
              throw new IllegalArgumentException("Value '" + number
                  + "' must be non-negative (0 or above).");
          }
Index: 
src/main/java/org/geotools/xs/bindings/XSNonPositiveIntegerBinding.java
===================================================================
--- 
src/main/java/org/geotools/xs/bindings/XSNonPositiveIntegerBinding.java 
(revision 34084)
+++ 
src/main/java/org/geotools/xs/bindings/XSNonPositiveIntegerBinding.java 
(working copy)
@@ -114,7 +114,7 @@
      public String encode(Object object, String value) throws Exception {
          Number number = (Number) object;

-        if (number.intValue() > 0) {
+        if (number.longValue() > 0) {
              throw new IllegalArgumentException("Value '" + number
                  + "' must be non-positive (0 or below).");
          }
Index: src/main/java/org/geotools/xs/bindings/XSPositiveIntegerBinding.java
===================================================================
--- 
src/main/java/org/geotools/xs/bindings/XSPositiveIntegerBinding.java 
(revision 34084)
+++ 
src/main/java/org/geotools/xs/bindings/XSPositiveIntegerBinding.java 
(working copy)
@@ -89,7 +89,7 @@
          throws Exception {
          Number number = (Number) value;

-        if (number.intValue() < 1) {
+        if (number.longValue() < 1) {
              throw new IllegalArgumentException("positiveInteger value 
'" + number
                  + "' must be positive.");
          }
@@ -106,7 +106,7 @@
      public String encode(Object object, String value) throws Exception {
          Number number = (Number) object;

-        if (number.intValue() == 0) {
+        if (number.longValue() == 0) {
              throw new IllegalArgumentException("positiveInteger value 
'" + number
                  + "' must be positive.");
          }
{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to