KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > coachEmfServices > EmfBasicLog > IteratorImpl


1 package ist.coach.coachEmfServices.EmfBasicLog;
2
3 import org.omg.CORBA.*;
4
5
6 public class IteratorImpl extends IteratorPOA
7 {
8
9     private LogRecord[] logRecords_ = null;
10     private int logRecordsSize_ = 0;
11
12
13     public void logRecords(LogRecord[] records) {
14         logRecords_ = records;
15     }
16
17     public LogRecord[] logRecords() {
18         return logRecords_;
19     }
20
21     public void logRecordsSize(int recordsSize) {
22         logRecordsSize_ = recordsSize;
23     }
24
25     public int logRecordsSize() {
26         return logRecordsSize_;
27     }
28
29     /************************************************************************/
30     /* METHOD 'get' */
31     /************************************************************************/
32         public LogRecord[] get(int position, int how_many) throws InvalidParam
33         {
34         if ( position > logRecordsSize_ ) {
35             String JavaDoc detailsStr = "Position (" + position +
36                     ") requested is greater than the number of records (" +
37                     logRecordsSize_ + ")";
38             InvalidParam ex_InvalidParam = new InvalidParam(detailsStr);
39             throw ex_InvalidParam;
40         }
41
42         if ( ( position + how_many ) > logRecordsSize_ ){
43             how_many = logRecordsSize_ - position;
44         }
45
46         LogRecord[] recSnapshot = new LogRecord[how_many];
47
48         for (int i = 0; i <= (how_many - 1); i++) {
49             recSnapshot[i] = logRecords_[ position + i];
50         }
51
52         return recSnapshot;
53
54         } // End of Method 'get'
55

56     /************************************************************************/
57     /* METHOD 'destroy' */
58     /************************************************************************/
59         public void destroy()
60     {
61
62         System.out.println( "*** BasicLogImpl: < DESTROY() > Not implemented Yet" );
63     }
64
65 } // End of Class 'IteratorImpl'
66
Popular Tags