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.rows;
22
23 import org.millscript.commons.alert.alerts.Unimplemented;
24 import org.millscript.commons.util.IList;
25 import org.millscript.commons.util.ListIterator;
26 import org.millscript.commons.util.list.AbstractIList;
27 import org.millscript.office.spreadsheet.Cell;
28 import org.millscript.office.spreadsheet.CellRef;
29 import org.millscript.office.spreadsheet.Row;
30 import org.millscript.office.spreadsheet.RowRef;
31 import org.millscript.office.spreadsheet.WorksheetRef;
32
33 /**
34 *
35 */
36 public class RowRefImpl extends AbstractIList< CellRef > implements RowRef {
37
38 private IList< Cell > cellList;
39
40 private int cellOffset;
41
42 private int rowIndex;
43
44 private WorksheetRef worksheetRef;
45
46 public RowRefImpl( final WorksheetRef sheetRef, final int index, final IList< Cell > cells, final int offset ) {
47 this.cellList = cells;
48 this.cellOffset = offset;
49 this.rowIndex = index;
50 this.worksheetRef = sheetRef;
51 }
52
53 /**
54 * @see org.millscript.commons.util.list.AbstractIList#doGet(int)
55 */
56 @Override
57 protected CellRef doGet( final int pos ) {
58 return new RowCellRefImpl(
59 this,
60 this.cellOffset + pos,
61 this.cellList.get( pos )
62 );
63 }
64
65 /**
66 * @see org.millscript.commons.util.list.AbstractIList#doSlice(int, int, boolean)
67 */
68 @Override
69 protected IList< CellRef > doSlice( final int first, final int last, final boolean share ) {
70 return new RowRefImpl(
71 this.worksheetRef,
72 this.rowIndex,
73 this.cellList.slice( first, last, share ),
74 this.cellOffset + first - 1
75 );
76 }
77
78 /**
79 * @see org.millscript.office.spreadsheet.RowRef#getRow()
80 */
81 public Row getRow() {
82 return this.worksheetRef.getWorksheet().get( rowIndex );
83 }
84
85 /**
86 * @see org.millscript.office.spreadsheet.RowRef#getRowIndex()
87 */
88 public int getRowIndex() {
89 return this.rowIndex;
90 }
91
92 /**
93 * @see org.millscript.office.spreadsheet.RowRef#getWorksheetRef()
94 */
95 public WorksheetRef getWorksheetRef() {
96 return this.worksheetRef;
97 }
98
99 /**
100 * @see org.millscript.commons.util.IList#indexOf(V)
101 */
102 public int indexOf( final CellRef value ) {
103
104 throw new Unimplemented(
105 "A indexOf operation was required"
106 ).culprit( "class", this.getClass() );
107 }
108
109 /**
110 * @see org.millscript.commons.util.IList#iterator(boolean)
111 */
112 public ListIterator< CellRef > iterator( final boolean share ) {
113 return new RowRefListIterator(
114 this,
115 this.cellList.iterator( share )
116 );
117 }
118
119 /**
120 * @see org.millscript.commons.util.IMap#size()
121 */
122 public int size() {
123 return this.cellList.size();
124 }
125
126 }