1 22 package org.jboss.ejb.plugins.cmp.jdbc.metadata; 23 24 import org.jboss.deployment.DeploymentException; 25 import org.jboss.metadata.MetaData; 26 27 import org.w3c.dom.Element ; 28 29 35 public final class JDBCCMPFieldPropertyMetaData { 36 39 private final JDBCCMPFieldMetaData cmpField; 40 41 44 private final String propertyName; 45 46 49 private final String columnName; 50 51 54 private final int jdbcType; 55 56 59 private final String sqlType; 60 61 64 private final boolean notNull; 65 66 75 public JDBCCMPFieldPropertyMetaData( 76 JDBCCMPFieldMetaData cmpField, 77 Element element) throws DeploymentException { 78 79 this.cmpField = cmpField; 80 81 propertyName = MetaData.getUniqueChildContent(element, "property-name"); 83 84 String columnStr = 86 MetaData.getOptionalChildContent(element, "column-name"); 87 if(columnStr != null) { 88 columnName = columnStr; 89 } else { 90 columnName = null; 91 } 92 93 String jdbcStr = MetaData.getOptionalChildContent(element, "jdbc-type"); 95 if(jdbcStr != null) { 96 jdbcType = JDBCMappingMetaData.getJdbcTypeFromName(jdbcStr); 97 sqlType = MetaData.getUniqueChildContent(element, "sql-type"); 98 } else { 99 jdbcType = Integer.MIN_VALUE; 100 sqlType = null; 101 } 102 103 notNull = (MetaData.getOptionalChild(element, "not-null") != null); 105 } 106 107 116 public JDBCCMPFieldPropertyMetaData( 117 JDBCCMPFieldMetaData cmpField, 118 JDBCCMPFieldPropertyMetaData defaultValues) { 119 120 this.cmpField = cmpField; 121 122 propertyName = defaultValues.propertyName; 124 125 columnName = defaultValues.columnName; 127 128 jdbcType = defaultValues.jdbcType; 130 131 sqlType = defaultValues.sqlType; 133 134 notNull = defaultValues.notNull; 136 } 137 138 141 public String getPropertyName() { 142 return propertyName; 143 } 144 145 149 public String getColumnName() { 150 return columnName; 151 } 152 153 157 public int getJDBCType() { 158 return jdbcType; 159 } 160 161 165 public String getSQLType() { 166 return sqlType; 167 } 168 169 173 public boolean isNotNull() { 174 return notNull; 175 } 176 177 186 public boolean equals(Object o) { 187 if(o instanceof JDBCCMPFieldPropertyMetaData) { 188 JDBCCMPFieldPropertyMetaData cmpFieldProperty = 189 (JDBCCMPFieldPropertyMetaData)o; 190 return propertyName.equals(cmpFieldProperty.propertyName) && 191 cmpField.equals(cmpFieldProperty.cmpField); 192 } 193 return false; 194 } 195 196 202 public int hashCode() { 203 int result = 17; 204 result = 37*result + cmpField.hashCode(); 205 result = 37*result + propertyName.hashCode(); 206 return result; 207 } 208 209 220 public String toString() { 221 return "[JDBCCMPFieldPropertyMetaData : propertyName=" + 222 propertyName + ", " + cmpField + "]"; 223 } 224 } 225 | Popular Tags |