import java.util.Collection; public class TranscriptRequest implements Runnable { private Thread t; private TranscriptParser parser; private String userId, password; private Exception exception; private boolean isDone, isStarted; public TranscriptRequest() { isDone = false; isStarted = false; t = new Thread(this); } public boolean isDone() { return isDone; } public boolean isStarted() { return isStarted; } public Exception getException() { if(!isDone) return null; return exception; } public Collection getCourses() { if(!isDone) return null; return parser.getCourses(); } public String getTransferCreditCount() { if(!isDone) return null; return Integer.toString(parser.getTransferCreditCount()); } public String getTotalCreditCount() { if(!isDone) return null; return Integer.toString(parser.getTotalCreditCount()); } public void start(String userId, String password) { this.userId = userId; this.password = password; t.start(); isStarted = true; } public void run() { isDone = false; try { parser = new TranscriptParser(); parser.parse(userId, password); } catch(Exception e) { exception = e; } isDone = true; } }