Coverage details for base.jdbs.ui.BackupDescriptorTableModel

LineHitsSource
1 /*******************************************************************************
2  *InternetCafe is a software solution that helps the management of Cybercafes
3  * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005.
4  * Copyright (C) 2006 Guido Angelo Ingenito
5  
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *******************************************************************************/
20  
21 package base.jdbs.ui;
22  
23 import java.util.Date;
24 import java.util.Observable;
25 import java.util.Observer;
26  
27 import javax.swing.table.AbstractTableModel;
28  
29 import org.apache.log4j.Logger;
30  
31 import base.jdbs.BackupDescriptor;
32 import base.jdbs.ConfigurationManager;
33 import base.util.FileUtil;
34  
35 @SuppressWarnings("serial")
360public class BackupDescriptorTableModel extends AbstractTableModel implements Observer {
37     
380    private static final transient Logger logger = Logger.getLogger(BackupDescriptorTableModel.class.getName());
39  
400    private String[] columnNames = {"Id","Name","Space (Kb)","Creation","Expiration","CRC32","MD5","Security"};
41  
42     public static final int BACKUP_ID_COLUMN = 0;
43  
44     public static final int BACKUP_NAME_COLUMN = 1;
45  
46     public static final int BACKUP_OCCUPIED_SPACE_COLUMN = 2;
47  
48     public static final int BACKUP_CREATION_DATE_COLUMN = 3;
49  
50     public static final int BACKUP_EXPIRATION_DATE_COLUMN = 4;
51  
52     public static final int BACKUP_CRC32_COLUMN = 5;
53  
54     public static final int BACKUP_MD5_COLUMN = 6;
55  
56     public static final int BACKUP_SECURITY_LEVEL_COLUMN = 7;
57  
58     public BackupDescriptorTableModel() {
590        super();
600        ConfigurationManager.getInstance().getRepository().addObserver(this);
610    }
62  
63     public int getColumnCount() {
640        return columnNames.length;
65     }
66  
67     public int getRowCount() {
680        return ConfigurationManager.getInstance().getRepository().getBackupDescriptor().length;
69     }
70  
71     public String getColumnName(int column) {
720        return columnNames[column];
73     }
74  
75     public Object getValueAt(int row, int column) {
760        if (row < 0 || column < 0)
770            return null;
780        Object result = null;
790        BackupDescriptor backupDescriptor = ConfigurationManager.getInstance().getRepository().getBackupDescriptor()[row];
800        switch (column) {
81         case BACKUP_ID_COLUMN:
820            result = backupDescriptor.getBackup().getGuId();
830            break;
84         case BACKUP_NAME_COLUMN:
850            result = backupDescriptor.getBackup().getName();
860            break;
87         case BACKUP_OCCUPIED_SPACE_COLUMN:
880            result = FileUtil.fileSizeInKB(backupDescriptor.getBackupFile());
890            break;
90         case BACKUP_CREATION_DATE_COLUMN:
910            result = backupDescriptor.getBackup().getCreationDate();
920            break;
93         case BACKUP_EXPIRATION_DATE_COLUMN:
940            result = backupDescriptor.getBackup().getExpirationDate();
950            break;
96         case BACKUP_CRC32_COLUMN:
970            result = backupDescriptor.getCrc32ChecksumValue();
980            break;
99         case BACKUP_MD5_COLUMN:
1000            result = backupDescriptor.getMd5DigestValue();
1010            break;
102         case BACKUP_SECURITY_LEVEL_COLUMN:
1030            result = backupDescriptor.getBackup().getSecurityLevel();
104             break;
105         }
1060        return result;
107     }
108  
109     @SuppressWarnings("unchecked")
110     public Class getColumnClass(int column) {
1110        Class result = null;
1120        switch (column) {
113         case BACKUP_ID_COLUMN:
1140            result = String.class;
1150            break;
116         case BACKUP_NAME_COLUMN:
1170            result = String.class;
1180            break;
119         case BACKUP_OCCUPIED_SPACE_COLUMN:
1200            result = Long.class;
1210            break;
122         case BACKUP_CREATION_DATE_COLUMN:
1230            result = Date.class;
1240            break;
125         case BACKUP_EXPIRATION_DATE_COLUMN:
1260            result = Date.class;
1270            break;
128         case BACKUP_CRC32_COLUMN:
1290            result = String.class;
1300            break;
131         case BACKUP_MD5_COLUMN:
1320            result = String.class;
1330            break;
134         case BACKUP_SECURITY_LEVEL_COLUMN:
1350            result = String.class;
136             break;
137         }
1380        return result;
139     }
140  
141     public void update(Observable arg0, Object arg1) {
1420        this.fireTableDataChanged();
1430    }
144 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.