1 19 package org.openharmonise.commons.dsi; 20 21 29 public class ColumnRef extends Object { 30 31 34 static public int DATE = 0; 35 36 39 static public int TEXT = 1; 40 41 44 static public int NUMBER = 2; 45 46 49 static public int LONG_TEXT = 3; 50 51 54 private String m_sTable = null; 55 56 59 private String m_sTableAlias = null; 60 61 64 private String m_sColumn = null; 65 66 69 private int m_nDataType = 1; 70 71 74 private String m_sFullRefCache = null; 75 76 79 private int m_nHashcode = 0; 80 81 89 public ColumnRef(String sTable, String sColumn, int nDataType) 90 throws DataStoreException { 91 if ((sTable == null) || (sColumn == null)) { 92 throw new DataStoreException("Invalid Type: table:" + sTable + 93 ",column:" + sColumn); 94 } 95 96 if ((nDataType < DATE) || (nDataType > LONG_TEXT)) { 97 throw new DataStoreException("Invalid data type"); 98 } 99 100 m_sTable = sTable; 101 m_sColumn = sColumn; 102 m_nDataType = nDataType; 103 } 104 105 110 public String getTable() { 111 return m_sTable; 112 } 113 114 119 public void setTable(String sTable) { 120 if( this.m_sFullRefCache!=null ) { 121 this.m_sFullRefCache=null; 122 } 123 m_sTable = sTable; 124 } 125 126 131 public String getTableAlias() { 132 return m_sTableAlias; 133 } 134 135 140 public void setTableAlias(String sTableAlias) { 141 if( this.m_sFullRefCache!=null ) { 142 this.m_sFullRefCache=null; 143 } 144 145 m_sTableAlias = sTableAlias; 146 } 147 148 153 public boolean hasTableAlias() { 154 return (m_sTableAlias != null); 155 } 156 157 162 public String getColumn() { 163 return m_sColumn; 164 } 165 166 171 public void setColumn(String sColumn) { 172 if( this.m_sFullRefCache!=null ) { 173 this.m_sFullRefCache=null; 174 } 175 m_sColumn = sColumn; 176 } 177 178 183 public String getFullRef() { 184 if( this.m_sFullRefCache==null ) { 185 String sTable = m_sTable; 186 if(hasTableAlias() == true) { 187 sTable = m_sTableAlias; 188 } 189 190 m_sFullRefCache= sTable + "." + m_sColumn; 191 } 192 return this.m_sFullRefCache; 193 } 194 195 200 public int getDataType() { 201 return m_nDataType; 202 } 203 204 205 208 public boolean equals(Object obj) { 209 boolean bEq = false; 210 211 if (this == obj) { 212 bEq = true; 213 } else if(obj instanceof ColumnRef) { 214 ColumnRef colref = (ColumnRef) obj; 215 216 if(colref.getColumn().equals(getColumn()) == true 217 && colref.getTable().equals(getTable())) { 218 bEq = true; 219 } 220 } 221 222 return bEq; 223 } 224 225 228 public int hashCode() { 229 230 if (m_nHashcode == 0) { 231 int nHash = 17; 232 233 nHash = 37 * nHash + m_nDataType; 234 if (m_sColumn != null) { 235 nHash = 37 * nHash + m_sColumn.hashCode(); 236 } 237 if (m_sTable != null) { 238 nHash = 37 * nHash + m_sTable.hashCode(); 239 } 240 if (m_sTableAlias != null) { 241 nHash = 37 * nHash + m_sTableAlias.hashCode(); 242 } 243 244 m_nHashcode = nHash; 245 } 246 247 return m_nHashcode; 248 } 249 250 } | Popular Tags |