1 6 package org.logicalcobwebs.dbscript; 7 8 import org.apache.commons.logging.Log; 9 import org.apache.commons.logging.LogFactory; 10 11 21 class Command implements CommandIF { 22 23 private static final Log LOG = LogFactory.getLog(Command.class); 24 25 private String name; 26 27 private String sql; 28 29 private int load = 1; 30 31 private int loops = 1; 32 33 private String exception; 34 35 39 protected static final String EXCEPTION_STOP = "stop"; 40 41 45 protected static final String EXCEPTION_LOG = "log"; 46 47 51 protected static final String EXCEPTION_IGNORE = "ignore"; 52 53 56 public String getSql() { 57 return sql; 58 } 59 60 63 protected void setSql(String sql) { 64 this.sql = sql; 65 } 66 67 70 public int getLoad() { 71 return load; 72 } 73 74 77 protected void setLoad(int load) { 78 this.load = load; 79 } 80 81 84 public int getLoops() { 85 return loops; 86 } 87 88 91 protected void setLoops(int loops) { 92 this.loops = loops; 93 } 94 95 98 public boolean isIgnoreException() { 99 return exception != null && exception.equals(EXCEPTION_IGNORE); 100 } 101 102 105 public boolean isLogException() { 106 return exception != null && exception.equals(EXCEPTION_LOG); 107 } 108 109 112 public void setException(String exception) { 113 if (exception == null) { 114 this.exception = EXCEPTION_STOP; 115 LOG.debug("Setting exception to default " + EXCEPTION_STOP); 116 } else if (exception.equals(EXCEPTION_IGNORE) 117 || exception.equals(EXCEPTION_LOG) 118 || exception.equals(EXCEPTION_STOP)) { 119 this.exception = exception; 120 LOG.debug("Setting exception to " + exception); 121 } else { 122 throw new RuntimeException ("Unknown exception value: " + exception); 123 } 124 } 125 126 129 public String getName() { 130 return name; 131 } 132 133 136 public void setName(String name) { 137 this.name = name; 138 } 139 140 } 141 142 174 | Popular Tags |