String outputName = (String) outputNameIterator.next();
Object value = context.getOutputParameter( outputName ).getValue();
if ( value == null ) {
value = ""; //$NON-NLS-1$
} else if ( value instanceof IPentahoResultSet ) {
IPentahoResultSet resultSet = (IPentahoResultSet) value;
Object[][] columnHeaders = resultSet.getMetaData().getColumnHeaders();
Object[][] rowHeaders = resultSet.getMetaData().getRowHeaders();
boolean hasColumnHeaders = columnHeaders != null;
boolean hasRowHeaders = rowHeaders != null;
if ( hasColumnHeaders ) {
for ( Object[] element : columnHeaders ) {
for ( int column = 0; column < element.length; column++ ) {
if ( hasRowHeaders ) {
for ( int indent = 0; indent < rowHeaders[0].length; indent++ ) {
messageBuffer.append( "\t" ); //$NON-NLS-1$
}
}
messageBuffer.append( element[column] ).append( "\t" ); //$NON-NLS-1$
}
messageBuffer.append( "\n" ); //$NON-NLS-1$
}
}
int headerRow = 0;
Object[] dataRow = resultSet.next();
int currentRow = 0;
while ( ( dataRow != null ) && ( currentRow < MessageFormatter.MAX_RESULT_THRESHOLD ) ) {
if ( hasRowHeaders ) {
for ( int rowHeaderCol = 0; rowHeaderCol < rowHeaders[headerRow].length; rowHeaderCol++ ) {
messageBuffer.append( rowHeaders[headerRow][rowHeaderCol].toString() ).append( "\t" ); //$NON-NLS-1$
}
}
for ( Object element : dataRow ) {
messageBuffer.append( element.toString() ).append( "\t" ); //$NON-NLS-1$
}
dataRow = resultSet.next();
currentRow++;
}
} else {
// Temporary fix for BISERVER-3348
ReturnParameter rpm = (ReturnParameter) context.getParameterManager().getReturnParameters().get( outputName );