1 19 20 package org.netbeans.lib.ddl.impl; 21 22 import java.util.HashMap ; 23 import java.util.Map ; 24 25 import org.openide.util.NbBundle; 26 27 import org.netbeans.lib.ddl.DDLException; 28 import org.netbeans.lib.ddl.util.CommandFormatter; 29 30 35 public class TriggerEvent { 36 public static final int INSERT = 1; 37 public static final int UPDATE = 2; 38 public static final int DELETE = 3; 39 40 41 public static String getName(int code) 42 { 43 switch (code) { 44 case INSERT: return "INSERT"; case UPDATE: return "UPDATE"; case DELETE: return "DELETE"; } 48 49 return null; 50 } 51 52 53 private String name; 54 55 56 private String col; 57 58 59 private String format; 60 61 62 public String getName() 63 { 64 return name; 65 } 66 67 68 public void setName(String aname) 69 { 70 name = aname; 71 } 72 73 74 public String getFormat() 75 { 76 return format; 77 } 78 79 80 public void setFormat(String fmt) 81 { 82 format = fmt; 83 } 84 85 86 public String getColumn() 87 { 88 return col; 89 } 90 91 92 public void setColumn(String column) 93 { 94 col = column; 95 } 96 97 103 public Map getColumnProperties(AbstractCommand cmd) throws DDLException { 104 HashMap args = new HashMap (); 105 args.put("event.name", cmd.quote(name)); args.put("event.column", col); 108 return args; 109 } 110 111 114 public String getCommand(AbstractCommand cmd) 115 throws DDLException 116 { 117 Map cprops; 118 if (format == null) throw new DDLException(NbBundle.getBundle("org.netbeans.lib.ddl.resources.Bundle").getString("EXC_NoFormatSpec")); try { 120 cprops = getColumnProperties(cmd); 121 return CommandFormatter.format(format, cprops); 122 } catch (Exception e) { 123 throw new DDLException(e.getMessage()); 124 } 125 } 126 } 127 | Popular Tags |