1 18 19 20 package sync4j.framework.core; 21 22 import java.util.*; 23 24 35 public final class Sequence 36 extends AbstractCommand 37 implements java.io.Serializable { 38 39 41 public static String COMMAND_NAME = "Sequence"; 42 43 45 private ArrayList commands = new ArrayList(); 46 47 49 52 protected Sequence() {} 53 54 66 public Sequence( 67 final CmdID cmdID , 68 final boolean noResp , 69 final Meta meta , 70 final AbstractCommand[] commands ) { 71 super(cmdID, noResp); 72 73 setMeta(meta); 74 setCommands(commands); 75 } 76 77 79 84 public ArrayList getCommands() { 85 return this.commands; 86 } 87 88 96 public void setCommands(AbstractCommand[] commands) { 97 if (commands == null) { 98 throw new IllegalArgumentException ("commands cannot be null"); 99 } 100 101 for (int i = 0; i < commands.length; i++) { 102 if (commands[i] == null) { 103 throw new IllegalArgumentException ("commands[" + i +"] cannot be null"); 104 } else if ((!(commands[i] instanceof Add)) 105 && (!(commands[i] instanceof Replace)) 106 && (!(commands[i] instanceof Delete)) 107 && (!(commands[i] instanceof Copy)) 108 && (!(commands[i] instanceof Atomic)) 109 && (!(commands[i] instanceof Map)) 110 && (!(commands[i] instanceof Sync))) { 111 throw new IllegalArgumentException ( 112 "commands[" + i + "] cannot be a " + commands[i].getName() 113 ); 114 } 115 } 116 this.commands.clear(); 117 this.commands.addAll(Arrays.asList(commands)); 118 } 119 120 125 public String getName() { 126 return Sequence.COMMAND_NAME; 127 } 128 } 129 | Popular Tags |