X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Fjava%2Fdolda%2Fdolcon%2FCommand.java;fp=lib%2Fjava%2Fdolda%2Fdolcon%2FCommand.java;h=fa72357ab4d99520e9d518cd0296fe87610dedf7;hb=e78d9ca3a7ae1bcf61849b02c816d6659a477657;hp=0000000000000000000000000000000000000000;hpb=46eac39e1edf535f1d6701f05170192a6880d20d;p=doldaconnect.git diff --git a/lib/java/dolda/dolcon/Command.java b/lib/java/dolda/dolcon/Command.java new file mode 100644 index 0000000..fa72357 --- /dev/null +++ b/lib/java/dolda/dolcon/Command.java @@ -0,0 +1,37 @@ +package dolda.dolcon; + +import java.util.*; + +public class Command { + List tokens; + Set listeners = new HashSet(); + Response resp; + + public interface Listener { + public void done(Response resp) throws Exception; + public void error(Exception cause); + } + + public Command(List tokens) { + this.tokens = tokens; + } + + public Command(String... tokens) { + this(Arrays.asList(tokens)); + } + + public void addListener(Listener l) { + listeners.add(l); + } + + public void done(Response resp) throws Exception { + this.resp = resp; + for(Listener l : listeners) + l.done(resp); + } + + public void error(Exception cause) { + for(Listener l : listeners) + l.error(cause); + } +}