1 22 23 package org.xquark.extractor.algebra; 24 25 import java.sql.Types ; 26 27 import org.xquark.extractor.common.Debug; 28 import org.xquark.jdbc.typing.DbType; 29 30 31 public final class SqlTypeAtom extends SqlType 32 { 33 private static final String RCSRevision = "$Revision: 1.9 $"; 34 private static final String RCSName = "$Name: $"; 35 36 private DbType _type = null; 37 private String _name = null; 38 private String _relationName = null; 39 40 45 46 public SqlTypeAtom(DbType type, String name) 47 { 48 setType(type); 49 setName(name); 50 } 51 52 public SqlTypeAtom(DbType type, String name, int multiplicity ) 53 { 54 setType(type); 55 setName(name); 56 setMultiplicity(multiplicity); 57 } 58 59 public Object clone() 60 { 61 try { 63 SqlTypeAtom retVal = (SqlTypeAtom)super.clone(); 64 retVal.setName((getName() == null) ? null : new String (getName()) ); 65 retVal.setType(getType() ==null ? null : (DbType)getType().clone()); 66 return retVal; 68 } 69 catch (CloneNotSupportedException ex) { 70 Debug.assertTrue(false, "error in implementation of clone"); 71 return null; 73 } 74 } 75 76 81 public DbType getType() 82 { 83 return _type; 84 } 85 86 91 public void setType(DbType aType) 92 { 93 _type = aType; 94 } 95 96 101 public String getName() 102 { 103 return _name; 104 } 105 106 111 public void setName(String aName) 112 { 113 _name = aName; 114 } 115 116 public void setRelationName(String relationName) 117 { 118 _relationName = relationName; 119 } 120 121 public String getRelationName() 122 { 123 return _relationName; 124 } 125 126 public boolean isRelation() 127 { 128 return false; 129 } 130 131 public boolean isTuple() 132 { 133 return false; 134 } 135 136 public boolean isColumn() 137 { 138 return MANY == _multiplicity; 139 } 140 141 public boolean isAtom() 142 { 143 return ONE == _multiplicity; 144 } 145 146 147 148 public boolean isBoolean() 149 { 150 int typeCode = _type.getPrimitiveTypeCode(); 151 return Types.BIT == typeCode; 152 } 153 154 public boolean isNumeric() { return _type.isNumeric();} 155 156 public boolean isInteger() { return _type.isInteger();} 157 158 public boolean isString() { return _type.isString();}; 159 160 public boolean isDataTime() { return _type.isDataTime();} 161 162 public boolean isNull() { return _type.isNull();} 163 164 public boolean isOracleRowid() 165 { 166 return _type.getJDBCType() == DbType.ORACLE_ROWID; 167 } 168 169 public String pprint () 170 { 171 String retVal = null; 172 retVal = MANY == _multiplicity ? "Column" : "Value"; 173 retVal += "(" + ppprint()+")"; 174 175 return retVal; 176 } 177 178 String ppprint() 179 { 180 return _name + ":" + _type.getName(); 181 } 182 183 public boolean isCompatibleTo(SqlType type) 184 { 185 boolean retVal; 186 if ( type instanceof SqlTypeAtom ) { 187 SqlTypeAtom tmpType = (SqlTypeAtom)type; 188 retVal = _type.isCompatibleTo(tmpType.getType()); 189 } 190 else 191 retVal = false; 192 193 return retVal; 194 } 195 } 196 | Popular Tags |