1 22 23 package org.xquark.extractor.algebra; 24 25 import java.util.ArrayList ; 26 import java.util.List ; 27 28 import org.xquark.extractor.common.Debug; 29 30 public final class SqlTypeCombinedStructure extends SqlType 31 { 32 private static final String RCSRevision = "$Revision: 1.5 $"; 33 private static final String RCSName = "$Name: $"; 34 35 protected List _structures = null;; 36 37 public SqlTypeCombinedStructure() 38 { 39 } 40 45 public SqlTypeCombinedStructure(List structureList) 46 { 47 setStructures(structureList); 48 } 49 50 public Object clone() { 51 try { 53 SqlTypeCombinedStructure retVal = (SqlTypeCombinedStructure)super.clone(); 54 if (null != _structures) { 55 retVal.setStructures( AlgebraTools.clone(_structures)); 56 } 57 return retVal; 59 } 60 catch (CloneNotSupportedException ex) { 61 Debug.assertTrue(false, "error in implementation of clone"); 62 return null; 64 } 65 } 66 67 72 public List getStructures() 73 { 74 return _structures; 75 } 76 77 82 public void setStructures(List aStructures) 83 { 84 _structures = aStructures; 85 } 86 87 public void addStructure(SqlType sqlType) 88 { 89 if (null == _structures) { 90 _structures = new ArrayList (); 91 } 92 _structures.add(sqlType); 93 94 } 95 96 public List getAttributes() { 97 List retVal = new ArrayList (); 98 99 for (int i = 0; i < _structures.size(); i++) { 100 SqlType type = (SqlType)_structures.get(i); 101 if (type instanceof SqlTypeAtom) { 102 retVal.add(type); 103 } 104 else if (type instanceof SqlTypeStructure) { 105 retVal.addAll( ((SqlTypeStructure)type).getAttributes() ); 106 } 107 } 108 return retVal; 109 } 110 111 115 public boolean isTuple() 116 { 117 return SqlType.ONE == _multiplicity ; 118 } 119 120 125 public boolean isCompatibleTo(SqlType type) 126 { 127 return true; 128 } 129 130 134 public boolean isRelation() 135 { 136 return SqlType.MANY == _multiplicity ; 137 } 138 139 143 public boolean isAtom() 144 { 145 return false; 146 } 147 148 152 public boolean isBoolean() 153 { 154 boolean retVal = true; 155 for (int i = 0; i < _structures.size(); i++) { 156 if (! ((SqlType)_structures.get(i)).isBoolean() ) { 157 retVal = false; 158 break; 159 } 160 } 161 return retVal; 162 } 163 164 168 public boolean isNumeric() 169 { 170 boolean retVal = true; 171 for (int i = 0; i < _structures.size(); i++) { 172 if (! ((SqlType)_structures.get(i)).isNumeric() ) { 173 retVal = false; 174 break; 175 } 176 } 177 return retVal; 178 } 179 180 184 public boolean isInteger() 185 { 186 boolean retVal = true; 187 for (int i = 0; i < _structures.size(); i++) { 188 if (! ((SqlType)_structures.get(i)).isInteger() ) { 189 retVal = false; 190 break; 191 } 192 } 193 return retVal; 194 } 195 196 200 public boolean isString() 201 { 202 boolean retVal = true; 203 for (int i = 0; i < _structures.size(); i++) { 204 if (! ((SqlType)_structures.get(i)).isString() ) { 205 retVal = false; 206 break; 207 } 208 } 209 return retVal; 210 } 211 212 216 public boolean isDataTime() 217 { 218 boolean retVal = true; 219 for (int i = 0; i < _structures.size(); i++) { 220 if (! ((SqlType)_structures.get(i)).isDataTime() ) { 221 retVal = false; 222 break; 223 } 224 } 225 return retVal; 226 } 227 228 232 public String pprint() 233 { 234 StringBuffer retVal = new StringBuffer (); 235 retVal.append("CombinedStructure ["); 236 for (int i = 0; i < _structures.size(); i++) { 237 retVal.append(((SqlType)_structures.get(i)).pprint()); 238 retVal.append("\t"); 239 } 240 retVal.append("]"); 241 return retVal.toString(); 242 } 243 244 } 245 | Popular Tags |