public boolean writeRow ( Object row [ ] , CSVWriter writer , boolean skipinternal , BinaryEncoding binaryEncoding , SimpleDateFormat dateFormatter ) { int firstfield = getFirstField ( skipinternal ) ; try { String [ ] fields = new String [ m_tableSchema . size ( ) - firstfield ] ; for ( int i = firstfield ; i < m_tableSchema . size ( ) ; i ++ ) { if ( row [ i ] == null ) { fields [ i - firstfield ] = "NULL" ; } else if ( m_tableSchema . get ( i ) == VoltType . VARBINARY && binaryEncoding != null ) { if ( binaryEncoding == BinaryEncoding . HEX ) { fields [ i - firstfield ] = Encoder . hexEncode ( ( byte [ ] ) row [ i ] ) ; } else { fields [ i - firstfield ] = Encoder . base64Encode ( ( byte [ ] ) row [ i ] ) ; } } else if ( m_tableSchema . get ( i ) == VoltType . STRING ) { fields [ i - firstfield ] = ( String ) row [ i ] ; } else if ( m_tableSchema . get ( i ) == VoltType . TIMESTAMP && dateFormatter != null ) { TimestampType timestamp = ( TimestampType ) row [ i ] ; fields [ i - firstfield ] = dateFormatter . format ( timestamp . asApproximateJavaDate ( ) ) ; } else { fields [ i - firstfield ] = row [ i ] . toString ( ) ; } } writer . writeNext ( fields ) ; } catch ( Exception x ) { x . printStackTrace ( ) ; return false ; } return true ; }
This is for legacy connector .