1 21 package oracle.toplink.essentials.internal.ejb.cmp3.xml.sequencing; 23 24 import java.util.List ; 25 import java.util.ArrayList ; 26 27 import org.w3c.dom.Node ; 28 import org.w3c.dom.NodeList ; 29 30 import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLConstants; 31 32 import oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors.XMLAccessor; 33 34 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.sequencing.MetadataTableGenerator; 35 36 42 public class XMLTableGenerator extends MetadataTableGenerator { 43 protected Node m_node; 44 protected XMLAccessor m_accessor; 45 46 49 public XMLTableGenerator(Node node, XMLAccessor accessor) { 50 super(accessor.getDocumentName()); 51 52 m_node = node; 53 m_accessor = accessor; 54 } 55 56 59 public int getAllocationSize() { 60 return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_ALLOCATION_SIZE, 50); 61 } 62 63 66 public String getCatalog() { 67 return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_CATALOG, m_accessor.getCatalog()); 68 } 69 70 73 public int getInitialValue() { 74 return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_INITIAL_VALUE, 0); 75 } 76 77 80 public String getName() { 81 return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_NAME); 82 } 83 84 87 public String getPkColumnName() { 88 return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_PK_COLUMN_NAME); 89 } 90 91 94 public String getPkColumnValue() { 95 return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_PK_COLUMN_VALUE); 96 } 97 98 101 public String getSchema() { 102 return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_SCHEMA, m_accessor.getSchema()); 103 } 104 105 108 public String getTable() { 109 return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_TABLE); 110 } 111 112 115 public List <String > getUniqueConstraints() { 116 if (m_uniqueConstraints == null) { 117 m_uniqueConstraints = new ArrayList <String >(); 118 NodeList uniqueConstraintNodes = m_accessor.getHelper().getNodes(m_node, XMLConstants.UNIQUE_CONSTRAINTS); 119 120 if (uniqueConstraintNodes != null) { 121 for (int i = 0; i < uniqueConstraintNodes.getLength(); i++) { 122 NodeList columnNameNodes = m_accessor.getHelper().getTextColumnNodes(uniqueConstraintNodes.item(i)); 123 124 if (columnNameNodes != null) { 125 for (int k = 0; k < columnNameNodes.getLength(); k++) { 126 String columnName = columnNameNodes.item(k).getNodeValue(); 127 128 if (columnName != null && !columnName.equals("")) { 129 m_uniqueConstraints.add(columnName); 130 } 131 } 132 } 133 } 134 } 135 } 136 137 return m_uniqueConstraints; 138 } 139 140 143 public String getValueColumnName() { 144 return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_VALUE_COLUMN_NAME); 145 } 146 147 150 public boolean loadedFromAnnotations() { 151 return false; 152 } 153 154 157 public boolean loadedFromXML() { 158 return true; 159 } 160 } 161 | Popular Tags |