1 19 20 package org.netbeans.lib.ddl.impl; 21 22 import java.text.MessageFormat ; 23 import java.util.Enumeration ; 24 import java.util.Map ; 25 import java.util.Vector ; 26 27 import org.openide.util.NbBundle; 28 29 import org.netbeans.lib.ddl.DDLException; 30 31 37 38 public class ColumnListCommand extends AbstractCommand 39 { 40 41 private Vector columns; 42 43 static final long serialVersionUID =3646663278680222131L; 44 45 public ColumnListCommand() 46 { 47 columns = new Vector (); 48 } 49 50 51 public Vector getColumns() 52 { 53 return columns; 54 } 55 56 61 public TableColumn specifyColumn(String type, String name, String cmd) 62 throws ClassNotFoundException , IllegalAccessException , InstantiationException 63 { 64 TableColumn column; 65 Map gprops = (Map )getSpecification().getProperties(); 66 Map props = (Map )getSpecification().getCommandProperties(cmd); 67 Map bindmap = (Map )props.get("Binding"); String tname = (String )bindmap.get(type); 69 if (tname != null) { 70 Map typemap = (Map )gprops.get(tname); 71 if (typemap != null) { 72 Class typeclass = Class.forName((String )typemap.get("Class")); String format = (String )typemap.get("Format"); column = (TableColumn)typeclass.newInstance(); 75 column.setObjectName(name); 76 column.setObjectType(type); 77 column.setColumnName(name); 78 column.setFormat(format); 79 columns.add(column); 80 } else throw new InstantiationException ( 81 MessageFormat.format( 82 NbBundle.getBundle("org.netbeans.lib.ddl.resources.Bundle").getString("EXC_UnableLocateType"), new String [] {tname, props.keySet().toString() } )); 84 } else throw new InstantiationException ( 85 MessageFormat.format( 86 NbBundle.getBundle("org.netbeans.lib.ddl.resources.Bundle").getString("EXC_UnableToBind"), new String [] {type, bindmap.toString() } )); 88 return column; 89 } 90 91 95 public Map getCommandProperties() 96 throws DDLException 97 { 98 Map props = (Map )getSpecification().getProperties(); 99 String cols = (String )props.get("ColumnListHeader"); String coldelim = (String )props.get("ColumnListDelimiter"); Map args = super.getCommandProperties(); 102 103 105 Enumeration col_e = columns.elements(); 106 while (col_e.hasMoreElements()) { 107 AbstractTableColumn col = (AbstractTableColumn)col_e.nextElement(); 108 boolean inscomma = col_e.hasMoreElements(); 109 cols = cols + col.getCommand(this)+(inscomma ? coldelim : ""); 110 } 111 112 args.put("columns", cols); return args; 114 } 115 116 117 public void readObject(java.io.ObjectInputStream in) 118 throws java.io.IOException , ClassNotFoundException 119 { 120 super.readObject(in); 121 columns = (Vector )in.readObject(); 122 } 123 124 125 public void writeObject(java.io.ObjectOutputStream out) 126 throws java.io.IOException 127 { 128 super.writeObject(out); 129 out.writeObject(columns); 130 } 131 } 132 | Popular Tags |