1 9 package org.jboss.portal.setup.impl.dl.dbloader; 10 11 import org.w3c.dom.Element ; 12 import org.w3c.dom.NodeList ; 13 import org.jboss.portal.common.util.XML; 14 import org.jboss.portal.setup.PortalSetupException; 15 import org.jboss.portal.setup.impl.dl.dbloader.ColumnMetaData; 16 import org.jboss.portal.setup.impl.dl.StatementMetaData; 17 import org.jboss.portal.setup.impl.dl.StatementType; 18 19 import java.util.List ; 20 import java.util.ArrayList ; 21 22 28 public abstract class DbStatementMetaData extends StatementMetaData 29 { 30 private StatementType m_type = null; 31 private String m_tableName = null; 32 private List m_columns = new ArrayList (); 33 private List m_values = new ArrayList (); 34 35 36 protected DbStatementMetaData(Element config) throws PortalSetupException 37 { 38 super(config); 39 buildMetaData(config); 40 } 41 42 43 46 public StatementType getType() 47 { 48 return m_type; 49 } 50 51 54 public String getTableName() 55 { 56 return m_tableName; 57 } 58 59 62 public List getColumns() 63 { 64 return m_columns; 65 } 66 67 70 public List getValues() 71 { 72 return m_values; 73 } 74 75 79 protected void buildMetaData(Element config) throws PortalSetupException 80 { 81 String strType = XML.asString(XML.getUniqueChild(config, "type", true)); 82 m_type = StatementType.parseString(strType); 83 m_tableName = XML.asString(XML.getUniqueChild(config, "table-name", true)); 84 Element columns = XML.getUniqueChild(config, "columns", true); 85 List columnsDef = XML.getChildren(columns, "column"); 86 87 for (int i = 0; i < columnsDef.size(); i++) 88 { 89 Element column = (Element )columnsDef.get(i); 90 91 m_columns.add(buildColumnMetaData(column)); 92 } 93 94 Element values = XML.getUniqueChild(config, "values", true); 95 List rows = XML.getChildren(values, "row"); 96 for (int j = 0; j < rows.size(); j++) 97 { 98 Element row = (Element )rows.get(j); 99 m_values.add(buildValueRowMetaData(row)); 100 } 101 102 } 103 104 108 protected abstract ColumnMetaData buildColumnMetaData(Element column); 109 110 protected abstract ValueRowMetaData buildValueRowMetaData(Element row) throws PortalSetupException; 111 } 112 | Popular Tags |