1 21 package oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors; 23 24 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.BasicAccessor; 25 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.objects.MetadataAccessibleObject; 26 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.columns.MetadataColumn; 27 28 import oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors.XMLClassAccessor; 29 30 import oracle.toplink.essentials.internal.ejb.cmp3.xml.columns.XMLColumn; 31 32 import oracle.toplink.essentials.internal.ejb.cmp3.xml.sequencing.XMLGeneratedValue; 33 import oracle.toplink.essentials.internal.ejb.cmp3.xml.sequencing.XMLTableGenerator; 34 import oracle.toplink.essentials.internal.ejb.cmp3.xml.sequencing.XMLSequenceGenerator; 35 36 import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper; 37 import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLConstants; 38 39 import oracle.toplink.essentials.internal.helper.DatabaseField; 40 41 import org.w3c.dom.Node ; 42 43 49 public class XMLBasicAccessor extends BasicAccessor implements XMLAccessor { 50 private Node m_node; 51 private XMLHelper m_helper; 52 53 56 public XMLBasicAccessor(MetadataAccessibleObject accessibleObject, Node node, XMLClassAccessor classAccessor) { 57 super(accessibleObject, classAccessor); 58 m_node = node; 59 m_helper = classAccessor.getHelper(); 60 } 61 62 65 public String getCatalog() { 66 return m_descriptor.getCatalog(); 67 } 68 69 74 protected MetadataColumn getColumn() { 75 Node node = m_helper.getNode(m_node, XMLConstants.COLUMN); 76 77 if (node != null) { 78 return new XMLColumn(node, m_helper, this); 79 } else { 80 return super.getColumn(); 81 } 82 } 83 84 87 public String getDocumentName() { 88 return m_helper.getDocumentName(); 89 } 90 91 94 public String getEnumeratedType() { 95 if (hasEnumerated()) { 96 return m_helper.getNodeTextValue(m_node, XMLConstants.ENUMERATED); 97 } else { 98 return super.getEnumeratedType(); 99 } 100 } 101 102 105 public XMLHelper getHelper() { 106 return m_helper; 107 } 108 109 112 public String getSchema() { 113 return m_descriptor.getSchema(); 114 } 115 116 121 public String getTemporalType() { 122 if (hasTemporal()) { 123 return m_helper.getNodeTextValue(m_node, XMLConstants.TEMPORAL); 124 } else { 125 return super.getTemporalType(); 126 } 127 } 128 129 133 public boolean hasEnumerated() { 134 Node node = m_helper.getNode(m_node, XMLConstants.ENUMERATED); 135 136 if (node == null) { 137 return super.hasEnumerated(); 138 } else { 139 return true; 140 } 141 } 142 143 147 public boolean hasTemporal() { 148 Node node = m_helper.getNode(m_node, XMLConstants.TEMPORAL); 149 150 if (node == null) { 151 return super.hasTemporal(); 152 } else { 153 return true; 154 } 155 } 156 157 161 public boolean isId() { 162 if (m_node.getLocalName().equals(XMLConstants.ID)) { 163 return true; 164 } else { 165 return super.isId(); 166 } 167 } 168 169 174 public boolean isLob() { 175 Node node = m_helper.getNode(m_node, XMLConstants.LOB); 176 177 if (node == null) { 178 return super.isLob(); 179 } else { 180 return true; 181 } 182 } 183 184 188 public boolean isVersion() { 189 Node node = m_helper.getNode(m_node, XMLConstants.VERSION); 190 191 if (node == null) { 192 return super.isVersion(); 193 } else { 194 return true; 195 } 196 } 197 198 201 protected void processGeneratedValue(DatabaseField field) { 202 Node node = m_helper.getNode(m_node, XMLConstants.GENERATED_VALUE); 203 204 if (node == null) { 205 super.processGeneratedValue(field); 206 } else { 207 processGeneratedValue(new XMLGeneratedValue(node, m_helper), field); 209 } 210 } 211 212 217 protected void processSequenceGenerator() { 218 Node node = m_helper.getNode(m_node, XMLConstants.SEQUENCE_GENERATOR); 219 220 if (node != null) { 221 processSequenceGenerator(new XMLSequenceGenerator(node, m_helper)); 223 } 224 225 super.processSequenceGenerator(); 227 } 228 229 234 protected void processTableGenerator() { 235 Node node = m_helper.getNode(m_node, XMLConstants.TABLE_GENERATOR); 236 237 if (node != null) { 238 processTableGenerator(new XMLTableGenerator(node, this)); 240 } 241 242 super.processTableGenerator(); 244 } 245 } 246 | Popular Tags |