ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/DBReporter2/ReportList.java
Revision: 1.2
Committed: Fri Mar 23 23:47:28 2001 UTC (24 years, 9 months ago) by pjm2
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Error occurred while calculating annotation data.
Log Message:
I thought I'd deleted these weeks ago(!)

File Contents

# Content
1 import java.util.*;
2 import java.io.*;
3
4 public class ReportList {
5
6 // Constructor
7 public ReportList(String filename) throws IOException {
8 this.readFile(filename);
9 }
10
11 public Iterator iterator() {
12 return _reports.iterator();
13 }
14
15 public int size() {
16 return _reports.size();
17 }
18
19 // private static method to read the report list file.
20 private void readFile(String filename) throws IOException {
21
22 String s = "";
23 try {
24 BufferedReader br = new BufferedReader(new FileReader(filename));
25 s = br.readLine();
26
27 int lineNumber = 0;
28 while (s != null) {
29
30 lineNumber++;
31 s = s.trim();
32
33 // Ignore blank lines.
34 if (s.equals("")){
35 s = br.readLine();
36 continue;
37 }
38
39 // Ignore comments.
40 if (s.substring(0,1).equals("#")){
41 s = br.readLine();
42 continue;
43 }
44
45 // Add instances of the report to the reports list.
46 Report r = null;
47 StringTokenizer tokenizer = new StringTokenizer(s, ":");
48
49 if (tokenizer.countTokens() == 2) {
50 r = new Report(tokenizer.nextToken(), tokenizer.nextToken());
51 }
52 else if (tokenizer.countTokens() == 3) {
53 try {
54 r = new Report(tokenizer.nextToken(), tokenizer.nextToken(), tokenizer.nextToken());
55 }
56 catch (NumberFormatException e) {
57 System.out.println("Line " + lineNumber + "of the report skipped: " + e);
58 }
59 }
60 else {
61 System.out.println("Line " + lineNumber + " of the report was skipped: " + s);
62 s = br.readLine();
63 continue;
64 }
65 _reports.add(r);
66
67 s = br.readLine();
68 }
69
70 }
71 catch (IOException e){
72 throw new IOException("Could not read the list of reports to run from " + filename + ": "+e);
73 }
74 }
75
76 private LinkedList _reports = new LinkedList();
77
78 }