private List < ConfigCommand > buildCommandListFromSheetComment ( final XSSFSheet sheet , final int sheetRightCol , final CellAttributesMap cellAttributesMap ) { List < ConfigCommand > commandList = new ArrayList <> ( ) ; // if skip then return empty list. if ( parent . isSkipConfiguration ( ) ) { return commandList ; } Map < CellAddress , ? extends Comment > comments = null ; try { // due to a poi bug. null exception throwed if no comments in the // sheet. comments = sheet . getCellComments ( ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "Null exception throwed when no comment exists: " + ex . getLocalizedMessage ( ) , ex ) ; } if ( comments == null ) { return commandList ; } // not sure the map is sorted. So use tree map to sort it. SortedSet < CellAddress > keys = new TreeSet <> ( comments . keySet ( ) ) ; // go through each comments // if found tie command then transfer it to list also remove from // comments. for ( CellAddress key : keys ) { Cell cell = sheet . getRow ( key . getRow ( ) ) . getCell ( key . getColumn ( ) , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; buildCommandList ( sheet , sheetRightCol , cell , commandList , cellAttributesMap ) ; } return commandList ; }
build command list from comments . after transfer the comment to command remove it from comments .