KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > reportcalculator > CollectionMatrix


1 package com.calipso.reportgenerator.reportcalculator;
2
3 import java.util.*;
4 import java.io.Serializable JavaDoc;
5
6 import com.calipso.reportgenerator.common.InfoException;
7
8 /**
9  *
10  */

11 public class CollectionMatrix implements Matrix, Serializable JavaDoc {
12
13   private List rows;
14   Vector columnNames;
15
16   public CollectionMatrix() {
17     rows = new LinkedList();
18   }
19
20   /**
21    * Devuelve la lista de rows
22    * @return la lista de rows
23    */

24   private List getRows() {
25     return rows;
26   }
27
28   public void add(Object JavaDoc[] row) throws InfoException {
29     getRows().add(row);
30   }
31
32   public Iterator iterator() throws InfoException {
33     return getRows().iterator();
34   }
35
36   public boolean isEmpty() {
37     return rows.isEmpty();
38   }
39
40   public int size() {
41     return getRows().size();
42   }
43
44   public void setColumNames(Vector columnNames) {
45     this.columnNames = columnNames;
46   }
47
48   public void addAll(Matrix sourceMatrix) throws InfoException{
49     Iterator iterator = sourceMatrix.iterator();
50     while(iterator.hasNext()){
51       Object JavaDoc[] objects = (Object JavaDoc[]) iterator.next();
52       add(objects);
53     }
54   }
55
56   public int getRowCount() {
57     return rows.size();
58   }
59
60   public int getColumCount() {
61     return columnNames.size();
62   }
63
64   public String JavaDoc getColumName(int i) throws IndexOutOfBoundsException JavaDoc {
65     return (String JavaDoc)columnNames.get(i);
66   }
67
68   public void setColumName(int i, String JavaDoc string) throws IndexOutOfBoundsException JavaDoc, InfoException {
69     columnNames.set(i, string);
70   }
71
72   public Object JavaDoc getValueAt(int i, int i1) throws IndexOutOfBoundsException JavaDoc {
73     //Este metodo no deberia utilizarse
74
return ((Object JavaDoc[])rows.get(i))[i1];
75   }
76
77   public Collection getColumValues(int i) throws IndexOutOfBoundsException JavaDoc {
78     //Este metodo no es implementado porque no se utiliza.
79
throw new NoSuchMethodError JavaDoc();
80   }
81
82   public Collection getRowValues(int i) throws IndexOutOfBoundsException JavaDoc {
83     //Este metodo no deberia utilizarse
84
return Arrays.asList((Object JavaDoc[])rows.get(i));
85   }
86
87   public void updateValueAt(int i, int i1, Object JavaDoc object) throws IndexOutOfBoundsException JavaDoc {
88     //Este metodo no deberia utilizarse
89
((Object JavaDoc[])rows.get(i))[i1] = object;
90  }
91
92   public void addRow(Collection collection) throws InfoException {
93     add(collection.toArray());
94   }
95 }
96
Popular Tags