1 19 20 package org.netbeans.lib.ddl.impl; 21 22 import java.io.Serializable ; 23 import java.util.HashMap ; 24 import java.util.Map ; 25 26 import org.openide.util.NbBundle; 27 28 import org.netbeans.lib.ddl.DDLException; 29 import org.netbeans.lib.ddl.util.CommandFormatter; 30 31 36 public class AbstractTableColumn implements Serializable { 37 38 private String name, cname, format; 39 40 41 private String otype; 42 43 44 private Map addprops; 45 46 47 String reftab; 48 49 50 String refcol; 51 52 static final long serialVersionUID =-5128289937199572117L; 53 54 public String getObjectName() 55 { 56 return name; 57 } 58 59 60 public void setObjectName(String oname) 61 { 62 name = oname; 63 } 64 65 66 public String getObjectType() 67 { 68 return otype; 69 } 70 71 72 public void setObjectType(String type) 73 { 74 otype = type; 75 } 76 77 78 public String getColumnName() 79 { 80 return cname; 81 } 82 83 84 public void setColumnName(String columnName) 85 { 86 cname = columnName; 87 } 88 89 90 public String getFormat() 91 { 92 return format; 93 } 94 95 96 public void setFormat(String fmt) 97 { 98 format = fmt; 99 } 100 101 102 public String getReferencedTableName() 103 { 104 return reftab; 105 } 106 107 108 public void setReferencedTableName(String table) 109 { 110 reftab = table; 111 } 112 113 114 public String getReferencedColumnName() 115 { 116 return refcol; 117 } 118 119 120 public void setReferencedColumnName(String col) 121 { 122 refcol = col; 123 } 124 125 126 public Object getProperty(String pname) 127 { 128 return addprops.get(pname); 129 } 130 131 132 public void setProperty(String pname, Object pval) 133 { 134 if (addprops == null) addprops = new HashMap (); 135 addprops.put(pname, pval); 136 } 137 138 147 public Map getColumnProperties(AbstractCommand cmd) 148 throws DDLException 149 { 150 HashMap args = new HashMap (); 151 String oname = getObjectName(); 152 String cname = getColumnName(); 153 154 if (addprops != null) args.putAll(addprops); 155 if (oname != null) args.put("object.name", cmd.quote(oname)); else throw new DDLException(NbBundle.getBundle("org.netbeans.lib.ddl.resources.Bundle").getString("EXC_Unknown")); if (cname != null) args.put("column.name", cmd.quote(cname)); else throw new DDLException(NbBundle.getBundle("org.netbeans.lib.ddl.resources.Bundle").getString("EXC_Unknown")); 160 if (reftab != null) args.put("fkobject.name", cmd.quote(reftab)); if (refcol != null) args.put("fkcolumn.name", cmd.quote(refcol)); 163 return args; 164 } 165 166 172 public String getCommand(AbstractCommand cmd) 173 throws DDLException 174 { 175 Map cprops; 176 if (format == null) throw new DDLException(NbBundle.getBundle("org.netbeans.lib.ddl.resources.Bundle").getString("EXC_NoFormatSpec")); try { 178 cprops = getColumnProperties(cmd); 179 return CommandFormatter.format(format, cprops); 180 } catch (Exception e) { 181 throw new DDLException(e.getMessage()); 182 } 183 } 184 185 186 public void readObject(java.io.ObjectInputStream in) 187 throws java.io.IOException , ClassNotFoundException 188 { 189 name = (String )in.readObject(); 190 cname = (String )in.readObject(); 191 format = (String )in.readObject(); 192 otype = (String )in.readObject(); 193 addprops = (Map )in.readObject(); 194 reftab = (String )in.readObject(); 195 refcol = (String )in.readObject(); 196 } 197 198 199 public void writeObject(java.io.ObjectOutputStream out) 200 throws java.io.IOException 201 { 202 out.writeObject(name); 203 out.writeObject(cname); 204 out.writeObject(format); 205 out.writeObject(otype); 206 out.writeObject(addprops); 207 out.writeObject(reftab); 208 out.writeObject(refcol); 209 } 210 } 211 | Popular Tags |