1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.millscript.office.spreadsheet.worksheets;
22
23 import org.millscript.commons.util.ListIterator;
24 import org.millscript.commons.util.Listlet;
25 import org.millscript.commons.util.maplet.IListlet;
26 import org.millscript.office.spreadsheet.Row;
27 import org.millscript.office.spreadsheet.RowRef;
28 import org.millscript.office.spreadsheet.WorksheetRef;
29 import org.millscript.office.spreadsheet.rows.RowRefImpl;
30
31 /**
32 *
33 */
34 public class WorksheetRefListIterator implements ListIterator< RowRef > {
35
36 private final WorksheetRef worksheetRef;
37
38 private final ListIterator< Row > rowIterator;
39
40 private int rowOffset;
41
42 /**
43 *
44 */
45 public WorksheetRefListIterator( final WorksheetRef bookRef, final int offset, final ListIterator< Row > iterator ) {
46 this.worksheetRef = bookRef;
47 this.rowIterator = iterator;
48 this.rowOffset = offset;
49 }
50
51 public Integer currentKey() {
52 return this.rowIterator.currentKey();
53 }
54
55 public Listlet< RowRef > currentMaplet() {
56 return new IListlet< RowRef >(
57 this.rowIterator.currentKey(),
58 this.currentValue()
59 );
60 }
61
62 public RowRef currentValue() {
63 return new RowRefImpl(
64 this.worksheetRef,
65 this.rowOffset + this.rowIterator.currentKey().intValue(),
66 this.rowIterator.currentValue(),
67 0
68 );
69 }
70
71 public boolean hasNext() {
72 return this.rowIterator.hasNext();
73 }
74
75 public Integer nextKey() {
76 return this.rowIterator.nextKey();
77 }
78
79 public Listlet< RowRef > nextMaplet() {
80 return new IListlet< RowRef >(
81 this.rowIterator.nextKey(),
82 this.currentValue()
83 );
84 }
85
86 public RowRef nextValue() {
87 return new RowRefImpl(
88 this.worksheetRef,
89 this.rowIterator.nextKey().intValue(),
90 this.rowIterator.currentValue(),
91 0
92 );
93 }
94
95 }