mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-20 06:00:44 +00:00
CE-1955 - Add rowNo to BulkLoadFileRow, set by FileToRowsInterface objects
This commit is contained in:
@ -36,6 +36,7 @@ public abstract class AbstractIteratorBasedFileToRows<E> implements FileToRowsIn
|
||||
private boolean useLast = false;
|
||||
private BulkLoadFileRow last;
|
||||
|
||||
int rowNo = 0;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@ -65,6 +66,7 @@ public abstract class AbstractIteratorBasedFileToRows<E> implements FileToRowsIn
|
||||
@Override
|
||||
public BulkLoadFileRow next()
|
||||
{
|
||||
rowNo++;
|
||||
if(iterator == null)
|
||||
{
|
||||
throw new IllegalStateException("Object was not init'ed");
|
||||
@ -99,6 +101,7 @@ public abstract class AbstractIteratorBasedFileToRows<E> implements FileToRowsIn
|
||||
@Override
|
||||
public void unNext()
|
||||
{
|
||||
rowNo--;
|
||||
useLast = true;
|
||||
}
|
||||
|
||||
@ -122,4 +125,15 @@ public abstract class AbstractIteratorBasedFileToRows<E> implements FileToRowsIn
|
||||
this.iterator = iterator;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for rowNo
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Override
|
||||
public int getRowNo()
|
||||
{
|
||||
return rowNo;
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class CsvFileToRows extends AbstractIteratorBasedFileToRows<CSVRecord> im
|
||||
values[i++] = s;
|
||||
}
|
||||
|
||||
return (new BulkLoadFileRow(values));
|
||||
return (new BulkLoadFileRow(values, getRowNo()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,6 +66,12 @@ public interface FileToRowsInterface extends AutoCloseable, Iterator<BulkLoadFil
|
||||
void init(InputStream inputStream) throws QException;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
**
|
||||
***************************************************************************/
|
||||
int getRowNo();
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
**
|
||||
***************************************************************************/
|
||||
|
@ -116,7 +116,7 @@ public class XlsxFileToRows extends AbstractIteratorBasedFileToRows<org.dhatim.f
|
||||
}
|
||||
}
|
||||
|
||||
return new BulkLoadFileRow(values);
|
||||
return new BulkLoadFileRow(values, getRowNo());
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,6 +33,7 @@ import java.util.stream.Collectors;
|
||||
*******************************************************************************/
|
||||
public class BulkLoadFileRow implements Serializable
|
||||
{
|
||||
private int rowNo;
|
||||
private Serializable[] values;
|
||||
|
||||
|
||||
@ -41,9 +42,10 @@ public class BulkLoadFileRow implements Serializable
|
||||
** Constructor
|
||||
**
|
||||
*******************************************************************************/
|
||||
public BulkLoadFileRow(Serializable[] values)
|
||||
public BulkLoadFileRow(Serializable[] values, int rowNo)
|
||||
{
|
||||
this.values = values;
|
||||
this.rowNo = rowNo;
|
||||
}
|
||||
|
||||
|
||||
@ -150,8 +152,8 @@ public class BulkLoadFileRow implements Serializable
|
||||
return false;
|
||||
}
|
||||
|
||||
BulkLoadFileRow row = (BulkLoadFileRow) o;
|
||||
return Objects.deepEquals(values, row.values);
|
||||
BulkLoadFileRow that = (BulkLoadFileRow) o;
|
||||
return rowNo == that.rowNo && Objects.deepEquals(values, that.values);
|
||||
}
|
||||
|
||||
|
||||
@ -162,6 +164,38 @@ public class BulkLoadFileRow implements Serializable
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Arrays.hashCode(values);
|
||||
return Objects.hash(rowNo, Arrays.hashCode(values));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for rowNo
|
||||
*******************************************************************************/
|
||||
public int getRowNo()
|
||||
{
|
||||
return (this.rowNo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for rowNo
|
||||
*******************************************************************************/
|
||||
public void setRowNo(int rowNo)
|
||||
{
|
||||
this.rowNo = rowNo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for rowNo
|
||||
*******************************************************************************/
|
||||
public BulkLoadFileRow withRowNo(int rowNo)
|
||||
{
|
||||
this.rowNo = rowNo;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user