protected String optionToCode ( final Object option , final int index ) { if ( index < 0 ) { List < ? > options = getOptions ( ) ; if ( options == null || options . isEmpty ( ) ) { Integrity . issue ( this , "No options available, so cannot convert the option \"" + option + "\" to a code." ) ; } else { StringBuffer message = new StringBuffer ( ) ; message . append ( "The option \"" ) . append ( option ) . append ( "\" is not one of the available options." ) ; Object firstOption = SelectListUtil . getFirstOption ( options ) ; if ( firstOption != null && option != null && firstOption . getClass ( ) != option . getClass ( ) ) { message . append ( " The options in this list component are of type \"" ) ; message . append ( firstOption . getClass ( ) . getName ( ) ) . append ( "\", the selection you supplied is of type \"" ) ; message . append ( option . getClass ( ) . getName ( ) ) . append ( "\"." ) ; } Integrity . issue ( this , message . toString ( ) ) ; } return null ; } else if ( option instanceof Option ) { Option opt = ( Option ) option ; return opt . getCode ( ) == null ? "" : opt . getCode ( ) ; } else { String code = APPLICATION_LOOKUP_TABLE . getCode ( getLookupTable ( ) , option ) ; if ( code == null ) { return String . valueOf ( index + 1 ) ; } else { return code ; } } }
Retrieves the code for the given option . Will return null if there is no matching option .