1 package org.oddjob.monitor.model; 2 3 import java.io.PrintWriter ; 4 import java.io.StringWriter ; 5 import java.util.Observable ; 6 7 import org.oddjob.state.JobStateEvent; 8 9 14 15 16 public class StateModel extends Observable { 17 18 private String state; 19 private String time; 20 private String exception; 21 22 23 public void change(JobStateEvent event) { 24 state = event.getJobState().toString(); 25 time = event.getTime().toString(); 26 StringWriter stackBuffer = new StringWriter (); 27 28 Throwable t = event.getException(); 29 if (t != null) { 30 PrintWriter writer = new PrintWriter (stackBuffer); 31 t.printStackTrace(writer); 32 exception = stackBuffer.toString(); 33 } 34 else { 35 exception = ""; 36 } 37 setChanged(); 38 notifyObservers(); 39 } 40 41 44 public String getException() { 45 return exception; 46 } 47 50 public String getState() { 51 return state; 52 } 53 56 public String getTime() { 57 return time; 58 } 59 60 public void clear() { 61 state = ""; 62 time = ""; 63 exception = ""; 64 setChanged(); 65 notifyObservers(); 66 } 67 68 } 69 | Popular Tags |