public class dosing {
public List<String> dosingColumnList(String roa){
List<String> dosingList = new ArrayList<String>();
dosingList.add("Dose");
dosingList.add("Time of Dose");
dosingList.add("Tau");
if(roa.equalsIgnoreCase("abc") ||
roa.equalsIgnoreCase("bcd")){
}
else if(roa.equalsIgnoreCase("cba")){
dosingList.add("Length of Infusion");
}
else if(roa.equalsIgnoreCase("cbd")){
dosingList.add("Length of Infusion");
}
return dosingList;
}
public boolean readFile(File filePath,int sheetNo,String roa) throws InvalidFormatException, IOException{
FileInputStream inputStream = new FileInputStream(filePath);
Workbook wb = WorkbookFactory.create(inputStream);
Sheet mySheet = wb.getSheetAt(sheetNo);
List<String> dosingColumnData =dosingColumnList(roa);
Iterator<Row> rowIter = mySheet.rowIterator();
List<String> headerData = new ArrayList<String>();
//rowIter.next();
while (rowIter.hasNext()){
Row row = rowIter.next();
Iterator<Cell> cellIterator = row.cellIterator();
while(row.getRowNum() == 0){
while (cellIterator.hasNext()){
Cell cell = cellIterator.next();
if(cell.getCellType() == Cell.CELL_TYPE_STRING){
String varData = cell.getStringCellValue();
headerData.add(varData);
}
}
break;
}
}
if (headerData == null || dosingColumnData == null){
}
if((headerData == null && dosingColumnData != null)
||( headerData != null && dosingColumnData == null)
|| (headerData.size() != dosingColumnData.size())){
}
headerData = new ArrayList<String>(headerData);
dosingColumnData = new ArrayList<String>(dosingColumnData);
Set<String> set1 = new HashSet<String>();
set1.addAll(headerData);
Set<String> set2 = new HashSet<String>();
set2.addAll(dosingColumnData);
System.out.println(set1 + " " + set2);
return set1.equals(set2);
}
}
This is the code I am working with ...with all imports...so headerdata list contains a row data from excel sheet and dosingColumnData contains list from user selection ....output of SOP is [Length, Time, Tau, Dose] [Length, Time, Tau, Dose]... although the two sets above have same type,same size,same order of elements ...the return statement always outputs false