1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.contrib.table.model.common; |
16 |
| |
17 |
| import java.util.Iterator; |
18 |
| import java.util.NoSuchElementException; |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| public class ArrayIterator implements Iterator |
24 |
| { |
25 |
| private Object[] m_arrValues; |
26 |
| private int m_nFrom; |
27 |
| private int m_nTo; |
28 |
| private int m_nCurrent; |
29 |
| |
30 |
0
| public ArrayIterator(Object[] arrValues)
|
31 |
| { |
32 |
0
| this(arrValues, 0, arrValues.length);
|
33 |
| } |
34 |
| |
35 |
0
| public ArrayIterator(Object[] arrValues, int nFrom, int nTo)
|
36 |
| { |
37 |
0
| m_arrValues = arrValues;
|
38 |
0
| m_nFrom = nFrom;
|
39 |
0
| m_nTo = nTo;
|
40 |
| |
41 |
0
| if (m_nFrom < 0)
|
42 |
0
| m_nFrom = 0;
|
43 |
0
| if (m_nTo < m_nFrom)
|
44 |
0
| m_nTo = m_nFrom;
|
45 |
0
| if (m_nTo > m_arrValues.length)
|
46 |
0
| m_nTo = m_arrValues.length;
|
47 |
| |
48 |
0
| m_nCurrent = m_nFrom;
|
49 |
| } |
50 |
| |
51 |
| |
52 |
| |
53 |
| |
54 |
0
| public boolean hasNext()
|
55 |
| { |
56 |
0
| return m_nCurrent < m_nTo;
|
57 |
| } |
58 |
| |
59 |
| |
60 |
| |
61 |
| |
62 |
0
| public Object next()
|
63 |
| { |
64 |
| |
65 |
0
| if (!hasNext())
|
66 |
0
| throw new NoSuchElementException();
|
67 |
0
| return m_arrValues[m_nCurrent++];
|
68 |
| } |
69 |
| |
70 |
| |
71 |
| |
72 |
| |
73 |
0
| public void remove()
|
74 |
| { |
75 |
0
| throw new UnsupportedOperationException();
|
76 |
| } |
77 |
| |
78 |
| } |