if ( ( resultSet != null ) && ( resultSet.getRowCount() > 0 ) ) {
displayNames = new HashMap();
items = new ArrayList();
if ( nameColumnNo == -1 ) {
// we did not find the specified name column
throw new ComponentException( Messages.getInstance().getErrorString(
"FilterDefinition.ERROR_0001_NAME_COLUMN_MISSING", descriptionItem ) ); //$NON-NLS-1$
} else if ( valueColumnNo == -1 ) {
// we did not find the specified name column
throw new ComponentException( Messages.getInstance().getErrorString(
"FilterDefinition.ERROR_0002_VALUE_COLUMN_MISSING", valueItem ) ); //$NON-NLS-1$
}
Object[] row = null;
try {
row = resultSet.next();
} catch ( Exception e ) {
// We will check for null below
}
if ( row == null ) {
logger.warn( Messages.getInstance().getErrorString( "FilterDefinition.ERROR_0004_FILTER_DEFINITION_EMPTY" ) ); //$NON-NLS-1$
} else {
while ( row != null ) {
value = row[valueColumnNo].toString();
items.add( value );
name = row[nameColumnNo].toString();
if ( name != null ) {
displayNames.put( value, name );
}
row = resultSet.next();
}
}
// close the result set so we can loop through it again later if we need
// to
resultSet.close();
// now create the XForm for the item
if ( displayNames.size() == 0 ) {
displayNames = null;
}
} else {
// ResultSet is null and it is ok only for a filter type of TEXT_BOX
if ( type != XForm.TYPE_TEXT ) {
throw new ComponentException( Messages.getInstance().getErrorString(
"FilterDefinition.ERROR_0003_FILTER_DEFINITION_NULL" ) ); //$NON-NLS-1$
}
}
assert formName != null : Messages.getInstance().getErrorString( "FilterDefinition.ERROR_0005_NAME_ELEMENT_EMPTY" ); //$NON-NLS-1$