protected void handleMissingColumns ( Attributes attributes ) throws DataSetException { List < Column > columnsToMerge = new ArrayList < Column > ( ) ; ITableMetaData activeMetaData = getActiveMetaData ( ) ; // Search all columns that do not yet exist and collect them int attributeLength = attributes . getLength ( ) ; for ( int i = 0 ; i < attributeLength ; i ++ ) { try { activeMetaData . getColumnIndex ( getAttributeNameFromCache ( attributes . getQName ( i ) ) ) ; } catch ( NoSuchColumnException e ) { columnsToMerge . add ( new Column ( getAttributeNameFromCache ( attributes . getQName ( i ) ) , DataType . UNKNOWN ) ) ; } } if ( ! columnsToMerge . isEmpty ( ) ) { if ( _columnSensing ) { logger . debug ( "Column sensing enabled. Will create a new metaData with potentially new columns if needed" ) ; activeMetaData = mergeTableMetaData ( columnsToMerge , activeMetaData ) ; _orderedTableNameMap . update ( activeMetaData . getTableName ( ) , activeMetaData ) ; // We also need to recreate the table, copying the data already // collected from the old one to the new one _consumer . startTable ( activeMetaData ) ; } else { StringBuilder extraColumnNames = new StringBuilder ( ) ; for ( Column col : columnsToMerge ) { extraColumnNames . append ( extraColumnNames . length ( ) > 0 ? "," : "" ) . append ( col . getColumnName ( ) ) ; } if ( logger . isWarnEnabled ( ) ) { StringBuilder msg = new StringBuilder ( ) ; msg . append ( "Extra columns ({}) on line {} for table {} (global line number is {}). Those columns will be ignored." ) ; msg . append ( "\n\tPlease add the extra columns to line 1," + " or use a DTD to make sure the value of those columns are populated" ) ; msg . append ( " or specify 'columnSensing=true' for your FlatXmlProducer." ) ; msg . append ( "\n\tSee FAQ for more details." ) ; logger . warn ( msg . toString ( ) , new Object [ ] { extraColumnNames . toString ( ) , _lineNumber + 1 , activeMetaData . getTableName ( ) , _lineNumberGlobal } ) ; } } } }
parses the attributes in the current row and checks whether a new column is found .