summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormianrui2013-01-31 02:34:20 (EST)
committer mwu2013-01-31 02:34:20 (EST)
commitc837c404b56f016b4921265125f285e36fa3e45a (patch)
tree9ce99b78c7d23f96aaddf3e708a5415cf1512722
parentf1438d7aaa90ee403875bbde2d702364f58c1d9d (diff)
downloadorg.eclipse.datatools.enablement.oda-c837c404b56f016b4921265125f285e36fa3e45a.zip
org.eclipse.datatools.enablement.oda-c837c404b56f016b4921265125f285e36fa3e45a.tar.gz
org.eclipse.datatools.enablement.oda-c837c404b56f016b4921265125f285e36fa3e45a.tar.bz2
Dataset preview result isn't correct when FlatFile datasource's columnv201301311534
name is number.(T56447)
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.flatfile.ui/src/org/eclipse/datatools/connectivity/oda/flatfile/ui/i18n/messages.properties1
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.flatfile.ui/src/org/eclipse/datatools/connectivity/oda/flatfile/ui/wizards/FileSelectionWizardPage.java86
2 files changed, 87 insertions, 0 deletions
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.flatfile.ui/src/org/eclipse/datatools/connectivity/oda/flatfile/ui/i18n/messages.properties b/plugins/org.eclipse.datatools.connectivity.oda.flatfile.ui/src/org/eclipse/datatools/connectivity/oda/flatfile/ui/i18n/messages.properties
index 08c021d..666ca8a 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.flatfile.ui/src/org/eclipse/datatools/connectivity/oda/flatfile/ui/i18n/messages.properties
+++ b/plugins/org.eclipse.datatools.connectivity.oda.flatfile.ui/src/org/eclipse/datatools/connectivity/oda/flatfile/ui/i18n/messages.properties
@@ -111,5 +111,6 @@ FileSelectionWizardPage.MenuItem.removeAll=Remove All
FileSelectionWizardPage.error.selectColumn.EmptyName=The column name cannot be empty!
FileSelectionWizardPage.error.selectColumn.duplicatedFileName=The specified column name is duplicated!
FileSelectionWizardPage.error.selectColumn.NoColumnSelected=At least one column should be selected.
+FileSelectionWizardPage.error.selectColumn.numberName=Column Name can not be a number.
RelativeFileSelectionDialog.Title.SelectFile=Select File
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.flatfile.ui/src/org/eclipse/datatools/connectivity/oda/flatfile/ui/wizards/FileSelectionWizardPage.java b/plugins/org.eclipse.datatools.connectivity.oda.flatfile.ui/src/org/eclipse/datatools/connectivity/oda/flatfile/ui/wizards/FileSelectionWizardPage.java
index 8011a47..48cde8d 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.flatfile.ui/src/org/eclipse/datatools/connectivity/oda/flatfile/ui/wizards/FileSelectionWizardPage.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda.flatfile.ui/src/org/eclipse/datatools/connectivity/oda/flatfile/ui/wizards/FileSelectionWizardPage.java
@@ -663,6 +663,7 @@ public class FileSelectionWizardPage extends DataSetWizardPage
} );
selectedColumnsViewer.refresh( );
+ validateSelectedColumns( );
}
@@ -999,6 +1000,12 @@ public class FileSelectionWizardPage extends DataSetWizardPage
pageComplete = false;
break;
}
+ if ( isNumeric(columnName) )
+ {
+ setMessage( Messages.getString( "FileSelectionWizardPage.error.selectColumn.numberName" ), //$NON-NLS-1$
+ ERROR );
+ pageComplete = false;
+ }
}
if ( savedSelectedColumnsInfoList.size( ) <= 0 )
{
@@ -1015,6 +1022,80 @@ public class FileSelectionWizardPage extends DataSetWizardPage
}
/**
+ * If text is a decimal presentation of int32 value, then text is index. In
+ * this case return true and make send out error message. Otherwise return
+ * false means the column name is right.
+ */
+ private boolean isNumeric( String text )
+ {
+ long indexTest = indexFromString( text );
+ if ( indexTest >= 0 )
+ {
+ return true;
+ }
+ return false;
+ }
+
+ private long indexFromString( String str )
+ {
+ // The length of the decimal string representation of
+ // Integer.MAX_VALUE, 2147483647
+ final int MAX_VALUE_LENGTH = 10;
+
+ int len = str.length( );
+ if ( len > 0 )
+ {
+ int i = 0;
+ boolean negate = false;
+ int c = str.charAt( 0 );
+ if ( c == '-' )
+ {
+ if ( len > 1 )
+ {
+ c = str.charAt( 1 );
+ i = 1;
+ negate = true;
+ }
+ }
+ c -= '0';
+ if ( 0 <= c
+ && c <= 9
+ && len <= ( negate ? MAX_VALUE_LENGTH + 1
+ : MAX_VALUE_LENGTH ) )
+ {
+ // Use negative numbers to accumulate index to handle
+ // Integer.MIN_VALUE that is greater by 1 in absolute value
+ // then Integer.MAX_VALUE
+ int index = -c;
+ int oldIndex = 0;
+ i++;
+ if ( index != 0 )
+ {
+ // Note that 00, 01, 000 etc. are not indexes
+ while ( i != len
+ && 0 <= ( c = str.charAt( i ) - '0' ) && c <= 9 )
+ {
+ oldIndex = index;
+ index = 10 * index - c;
+ i++;
+ }
+ }
+ // Make sure all characters were consumed and that it
+ // couldn't
+ // have overflowed.
+ if ( i == len
+ && ( oldIndex > ( Integer.MIN_VALUE / 10 ) || ( oldIndex == ( Integer.MIN_VALUE / 10 ) && c <= ( negate
+ ? -( Integer.MIN_VALUE % 10 )
+ : ( Integer.MAX_VALUE % 10 ) ) ) ) )
+ {
+ return 0xFFFFFFFFL & ( negate ? index : -index );
+ }
+ }
+ }
+ return -1L;
+ }
+
+ /**
* Load the custom properties
*/
private void loadProperties( )
@@ -2263,6 +2344,11 @@ public class FileSelectionWizardPage extends DataSetWizardPage
status = getMiscStatus( IStatus.ERROR,
Messages.getString( "FileSelectionWizardPage.error.selectColumn.duplicatedFileName" ) ); //$NON-NLS-1$
}
+ else if ( isNumeric( this.columnName.trim( ) ) )
+ {
+ status = getMiscStatus( IStatus.ERROR,
+ Messages.getString( "FileSelectionWizardPage.error.selectColumn.numberName" ) ); //$NON-NLS-1$
+ }
else
{
status = getOKStatus( );