KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > backup > HistoryEntry


1 /*
2  * BackupStatus.java
3  *
4  * Created on December 13, 2000, 6:52 AM
5  */

6
7 package com.sun.enterprise.config.backup;
8
9 import java.io.Serializable JavaDoc;
10 import java.util.ArrayList JavaDoc;
11 import java.util.Date JavaDoc;
12 import com.sun.enterprise.config.backup.status.StatusConstants;
13 import com.sun.enterprise.config.backup.status.Status;
14 import com.sun.enterprise.config.backup.utils.LoggerHelper;
15
16 /**
17  *
18  * @author sridatta
19  */

20 public class HistoryEntry implements Serializable JavaDoc,
21                                 StatusConstants,
22                                 EnvironmentConstants,
23                                 DefaultConstants {
24        
25     private String JavaDoc _operation = OPERATION_TYPE_UNKNOWN;
26     private long _timestamp=-1;
27     private Status _status;
28     private String JavaDoc _tmpStringValue;
29     
30    //private ArrayList _historyEntries;
31
/** Creates a new instance of BackupStatus */
32     public HistoryEntry() {
33     }
34     
35     public HistoryEntry(String JavaDoc line) throws BackupException {
36         this();
37         if(line == null || line == "") {
38                 return;
39         }
40             
41        /* try {
42             String[] parts = line.split(HISTORY_FILE_INITIAL_SEPARATOR);
43             String[] vars = parts[1].split(HISTORY_FILE_DATA_SEPARATOR);
44             initVariables(vars);
45         } catch(Exception e) {
46             //incase of exception
47             //log it and ignore
48             
49             LoggerHelper.warning("error_creating_history_entry");
50             LoggerHelper.warning("The file could be bad. Move it out");
51             LoggerHelper.fine("Actual Exception is", e);
52         }
53         */

54         _tmpStringValue = line;
55     }
56     
57     public HistoryEntry(Status status) {
58         if(status!= null) {
59             _operation = status.getOperation();
60             _timestamp = status.getCreationTimeStamp();
61             _status = status;
62             _tmpStringValue = status.toString();
63         }
64     }
65     /**
66      * careful about order of variables
67      */

68     private void initVariables(String JavaDoc[] vars) {
69         _operation = vars[0];
70         _timestamp = new Long JavaDoc(vars[1]).longValue();
71         
72         //TBD FIXME
73
//initialize status
74
}
75     
76     public String JavaDoc toString() {
77         if(_tmpStringValue == null) {
78             return getDate() + HISTORY_FILE_INITIAL_SEPARATOR +
79                     _operation + HISTORY_FILE_DATA_SEPARATOR +
80                     _timestamp + HISTORY_FILE_DATA_SEPARATOR +
81                     HISTORY_FILE_EXTRA_DATA_SEPARATOR_START +
82                     getStatusAsString() +
83                     HISTORY_FILE_EXTRA_DATA_SEPARATOR_END;
84         } else {
85             return _tmpStringValue;
86         }
87     }
88     private String JavaDoc getDate() {
89         return new Date JavaDoc(_timestamp).toString();
90     }
91     private String JavaDoc getStatusAsString() {
92        if(_status == null) {
93             return "No Extra Details";
94         }
95         return _status.toString();
96     }
97 }
98
Popular Tags