1 18 19 20 package sync4j.framework.core; 21 22 import java.util.*; 23 24 31 public final class Atomic 32 extends AbstractCommand 33 implements java.io.Serializable { 34 35 public static String COMMAND_NAME = "Atomic"; 37 38 private ArrayList commands = new ArrayList(); 40 41 43 44 protected Atomic(){} 45 46 55 public Atomic(final CmdID cmdID, 56 final boolean noResp, 57 final Meta meta, 58 final AbstractCommand[] commands) { 59 super(cmdID); 60 61 this.noResp = (noResp) ? new Boolean (noResp) : null; 62 setMeta(meta); 63 setCommands(commands); 64 65 } 66 67 69 74 public ArrayList getCommands() { 75 return this.commands; 76 } 77 78 84 public void setCommands(AbstractCommand[] commands) { 85 if (commands == null || commands.length == 0) { 86 throw new IllegalArgumentException ("commands cannot be null"); 87 } 88 89 for (int i=0; i<commands.length; i++) { 90 if ((!(commands[i] instanceof Add)) 91 && (!(commands[i] instanceof Delete)) 92 && (!(commands[i] instanceof Copy)) 93 && (!(commands[i] instanceof Map)) 94 && (!(commands[i] instanceof Replace)) 95 && (!(commands[i] instanceof Sequence)) 96 && (!(commands[i] instanceof Sync))) { 97 98 throw new IllegalArgumentException ( 99 "illegal nested command: " + commands[i]); 100 } 101 } 102 this.commands.clear(); 103 this.commands.addAll(Arrays.asList(commands)); 104 } 105 106 111 public String getName() { 112 return Atomic.COMMAND_NAME; 113 } 114 } | Popular Tags |