1 16 package org.apache.commons.chain.generic; 17 18 19 import org.apache.commons.chain.Command; 20 import org.apache.commons.chain.Context; 21 22 23 30 31 public class CopyCommand implements Command { 32 33 34 36 37 private String fromKey = null; 38 39 40 43 public String getFromKey() { 44 45 return (this.fromKey); 46 47 } 48 49 50 55 public void setFromKey(String fromKey) { 56 57 this.fromKey = fromKey; 58 59 } 60 61 62 private String toKey = null; 63 64 65 68 public String getToKey() { 69 70 return (this.toKey); 71 72 } 73 74 75 80 public void setToKey(String toKey) { 81 82 this.toKey = toKey; 83 84 } 85 86 87 private String value = null; 88 89 90 93 public String getValue() { 94 95 return (this.value); 96 97 } 98 99 100 105 public void setValue(String value) { 106 107 this.value = value; 108 109 } 110 111 112 114 115 123 public boolean execute(Context context) throws Exception { 124 125 Object value = this.value; 126 if (value == null) { 127 context.get(getFromKey()); 128 } 129 if (value != null) { 130 context.put(getToKey(), value); 131 } else { 132 context.remove(getToKey()); 133 } 134 return (false); 135 136 } 137 138 139 } 140 | Popular Tags |