Source code: com/flexstor/common/data/ejb/sequence/SequenceData.java
1 /*
2 * SequenceData.java
3 *
4 * Copyright $Date: 2003/08/11 02:22:50 $ FLEXSTOR.net Inc.
5 *
6 * This work is licensed for use and distribution under license terms found at
7 * http://www.flexstor.org/license.html
8 *
9 */
10
11 package com.flexstor.common.data.ejb.sequence;
12
13 import com.flexstor.common.data.ejb.Data;
14
15 /**
16 * Provides a wrapper class around a set of sequence numbers.
17 * Please note that the set of sequences may not be contiguious.
18 *
19 * @author Dan Schroeder
20 * @version 3.0
21 */
22 public class SequenceData
23 extends Data
24 {
25 static final long serialVersionUID = 7709418658839925342L;
26 private long nSeqCount = 0; //Number of positions in sequence array
27 private long[] naSequences;
28
29 // Used as indicator to current sequence ( See hasMoreItems() && nextSequence() )
30 private int nCurSeqCount = 0;
31
32 /**
33 * Creates a new sequence based on naSequence.
34 * @param naSequence the array of sequence numbers.
35 */
36
37 public SequenceData ( long[] nSequences, int nCount )
38 {
39 naSequences = nSequences;
40 nSeqCount = nCount;
41 }
42
43 /**
44 * Returns true if there are more sequence numbers available.
45 * @return true if there are more items.
46 */
47 public boolean hasMoreItems ( )
48 {
49 return (nCurSeqCount < nSeqCount );
50 }
51
52 /**
53 * Returns the next item in this sequence.
54 * @return the next item.
55 */
56 public long nextSequence ( )
57 {
58 return naSequences[nCurSeqCount++];
59
60 }
61 }