sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlebi...@apache.org
Subject svn commit: r1649463 - in /sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis: internal/shapefile/jdbc/connection/DBFConnection.java internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java storage/shapefile/InputFeatureStream.java
Date Mon, 05 Jan 2015 05:40:23 GMT
Author: mlebihan
Date: Mon Jan  5 05:40:23 2015
New Revision: 1649463

URL: http://svn.apache.org/r1649463
Log:
SIS-185 : Feature values taken from Database are temporary recast to String instead of their
true type.

Modified:
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java?rev=1649463&r1=1649462&r2=1649463&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
[UTF-8] Mon Jan  5 05:40:23 2015
@@ -269,7 +269,7 @@ public class DBFConnection extends Abstr
         }
         
         // TODO Implements ResultSet:absolute(int) instead.
-        for(int index=1; index < column; index ++) {
+        for(int index=1; index <= column; index ++) {
             try {
                 rs.next();
             }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java?rev=1649463&r1=1649462&r2=1649463&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
[UTF-8] Mon Jan  5 05:40:23 2015
@@ -303,8 +303,7 @@ public class DBFRecordBasedResultSet ext
         try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(column,
m_sql)) {
             String fieldType;
             
-            try
-            {
+            try {
                 fieldType = field.getString("TYPE_NAME");
             }
             catch(SQLNoSuchFieldException e) {
@@ -323,8 +322,19 @@ public class DBFRecordBasedResultSet ext
                 case "DATE":
                     return getDate(column);
                     
+                case "DECIMAL": {
+                    // Choose Integer or Long type, if no decimal and that the field is not
to big.
+                    if (field.getInt("DECIMAL_DIGITS") == 0 && field.getInt("COLUMN_SIZE")
<= 18) {
+                        if (field.getInt("COLUMN_SIZE") <= 9)
+                            return getInt(column);
+                        else
+                            return getLong(column);
+                    }
+                    
+                    return getDouble(column);
+                }
+                    
                 case "DOUBLE":
-                case "DECIMAL":
                 case "CURRENCY":
                     return getDouble(column);
                     

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java?rev=1649463&r1=1649462&r2=1649463&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
(original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
Mon Jan  5 05:40:23 2015
@@ -19,7 +19,7 @@ package org.apache.sis.storage.shapefile
 import java.io.File;
 import java.io.InputStream;
 import java.sql.SQLFeatureNotSupportedException;
-import java.text.MessageFormat;
+import java.text.*;
 
 import org.apache.sis.feature.DefaultFeatureType;
 import org.apache.sis.internal.shapefile.InvalidShapefileFormatException;
@@ -141,8 +141,7 @@ public class InputFeatureStream extends
      */
     public Feature readFeature() throws SQLConnectionClosedException, SQLInvalidStatementException,
SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException,
SQLNotNumericException, SQLNotDateException, SQLFeatureNotSupportedException, SQLIllegalColumnIndexException,
InvalidShapefileFormatException {
         try {
-            if (m_endOfFile == false) {
-                m_endOfFile = true;
+            if (m_endOfFile) {
                 return null;
             }
             
@@ -159,7 +158,30 @@ public class InputFeatureStream extends
                 while(rsDatabase.next()) {
                     String fieldName = rsDatabase.getString("COLUMN_NAME");
                     Object fieldValue = m_rs.getObject(fieldName);
-                    feature.setPropertyValue(fieldName, fieldValue);
+                    
+                    // FIXME To allow features to be filled again, the values are converted
to String again : feature should allow any kind of data.
+                    String stringValue;
+                    
+                    if (fieldValue == null) {
+                        stringValue = null;
+                    }
+                    else {
+                        if (fieldValue instanceof Integer || fieldValue instanceof Long)
{
+                            stringValue = MessageFormat.format("{0,number,#0}", fieldValue);
// Avoid thousand separator.
+                        }
+                        else {
+                            if (fieldValue instanceof Double || fieldValue instanceof Float)
{
+                                // Avoid thousand separator.
+                                DecimalFormat df = new DecimalFormat();
+                                df.setGroupingUsed(false);
+                                stringValue = df.format(fieldValue);                    
           
+                            }
+                            else
+                                stringValue = fieldValue.toString();
+                        }
+                    }
+                    
+                    feature.setPropertyValue(fieldName, stringValue);
                 }
                 
                 return feature;



Mime
View raw message