if ( iData != null && iMetaData != null )
if ( iData != null && columnNames.length > 0 )
	public void extractData( IReportDocument document, String resultSetName,			Collection columns, Locale locale, ServletOutputStream outputStream )			throws RemoteException	{		assert document != null;		assert resultSetName != null && resultSetName.length( ) > 0;		assert columns != null && !columns.isEmpty( );		String[] columnNames = new String[columns.size( )];		Iterator iSelectedColumns = columns.iterator( );		for ( int i = 0; iSelectedColumns.hasNext( ); i++ )		{			columnNames[i] = (String) iSelectedColumns.next( );		}		IDataExtractionTask dataTask = null;		IExtractionResults result = null;		IDataIterator iData = null;		try		{			synchronized ( this.getClass( ) )			{				dataTask = engine.createDataExtractionTask( document );			}			dataTask.selectResultSet( resultSetName );			dataTask.selectColumns( columnNames );			dataTask.setLocale( locale );			result = dataTask.extract( );			if ( result != null )			{				IResultMetaData iMetaData = result.getResultMetaData( );				iData = result.nextResultIterator( );				if ( iData != null && iMetaData != null )				{					StringBuffer buf = new StringBuffer( );					// Captions					String caption = iMetaData.getColumnLabel( 0 );					if ( caption != null )					{						buf.append( caption );					}					else					{						buf.append( iMetaData.getColumnName( 0 ) );					}					for ( int i = 1; i < columnNames.length; i++ )					{						buf.append( ',' ); //$NON-NLS-1$						caption = iMetaData.getColumnLabel( i );						if ( caption != null )						{							buf.append( caption );						}						else						{							buf.append( iMetaData.getColumnName( i ) );						}					}					outputStream.println( buf.toString( ) );					buf.delete( 0, buf.length( ) );					// Data					while ( iData.next( ) )					{						String value = null;						try						{							value = cvsConvertor( (String) DataTypeUtil									.convert( iData.getValue( columnNames[0] ),											DataType.STRING_TYPE ) );						}						catch ( Exception e )						{							value = null;						}						if ( value != null )						{							buf.append( value );						}						for ( int i = 1; i < columnNames.length; i++ )						{							buf.append( ',' ); //$NON-NLS-1$							try							{								value = cvsConvertor( (String) DataTypeUtil										.convert( iData												.getValue( columnNames[i] ),												DataType.STRING_TYPE ) );							}							catch ( Exception e )							{								value = null;							}							if ( value != null )							{								buf.append( value );							}						}						outputStream.println( buf.toString( ) );						buf.delete( 0, buf.length( ) );					}				}			}		}		catch ( Exception e )		{			AxisFault fault = new AxisFault( );			fault					.setFaultCode( new QName(							"ReportEngineService.extractData( )" ) ); //$NON-NLS-1$			fault.setFaultString( e.getLocalizedMessage( ) );			throw fault;		}		finally		{			if ( iData != null )			{				iData.close( );			}			if ( result != null )			{				result.close( );			}			if ( dataTask != null )			{				dataTask.close( );			}		}	}