1 22 23 28 29 package org.xquark.mapper.storage; 30 31 import java.sql.SQLException ; 32 import java.util.*; 33 34 import org.xquark.mapper.dbms.AbstractConnection; 35 import org.xquark.mapper.mapping.TableMapping; 36 import org.xquark.xml.xdbc.XMLDBCException; 37 38 41 abstract class QueryExplorer extends TableExplorer 42 { 43 private static final String RCSRevision = "$Revision: 1.1 $"; 44 private static final String RCSName = "$Name: $"; 45 protected QueryTuple[] queryTuples; 46 protected QueryStructExplorer qNode; 47 protected QueryExtraDataExplorer qExtraNode; 48 private int subPathCount; 49 50 51 QueryExplorer(_RepositoryCollection collection) throws SQLException , XMLDBCException 52 { 53 super(collection); 54 55 tuples = queryTuples = 57 new QueryTuple[collection.getMetadata().getMappingStatementsCount()]; 58 } 59 60 int getSubPathCount() 61 { 62 return subPathCount; 63 } 64 65 70 protected Object [] dispatchSubPaths(VarInfoSet varInfoSet) 71 { 72 HashMap tableMappingSubset = new HashMap(); 73 SubPathInfo subPathInfo; 74 ArrayList subPathNodes = new ArrayList(); 75 TableMapping table; 76 List tablePaths; 77 78 List rangeList = varInfoSet.getExpandedPathList(); 80 List subPathList; 81 ExpandedPathInfoSet expandedPathInfo; 82 int expandedPathCount = rangeList.size(); 83 84 for (int i = 0; i < expandedPathCount; i++) 85 { 86 expandedPathInfo = (ExpandedPathInfoSet)rangeList.get(i); 87 subPathList = expandedPathInfo.getSubPaths(); 88 subPathCount = subPathList.size(); 89 90 for (int j = 0; j < subPathCount; j++) 91 { 92 SubPathInfoSet subPathInfoSet = (SubPathInfoSet)subPathList.get(j); 93 subPathInfo = new SubPathInfo( 94 subPathInfoSet.getSubPath(), 95 j+1, 96 subPathInfoSet.getText(), 97 expandedPathInfo.getPhysicalPath()); 98 subPathNodes.add(subPathInfo); 99 100 if ((subPathInfo.subPath.getBuildMappings() == null) || subPathInfo.isText) { 102 table = subPathInfo.subPath.getReadColumnMapping().getTableMapping(); 103 tablePaths = (List)tableMappingSubset.get(table); 104 if (tablePaths == null) 105 { 106 tablePaths = new ArrayList(2); 107 tableMappingSubset.put(table, tablePaths); 108 } 109 tablePaths.add(subPathInfo); 110 } 111 else { 113 Iterator it = subPathInfo.subPath.getBuilderAncestor().getBuildMappings().iterator(); 114 115 while (it.hasNext()) 116 { 117 table = (TableMapping)it.next(); 118 tablePaths = (List)tableMappingSubset.get(table); 119 if (tablePaths == null) 120 { 121 tablePaths = new ArrayList(2); 122 tableMappingSubset.put(table, tablePaths); 123 } 124 tablePaths.add(subPathInfo); 125 } 126 } 127 } 128 } 129 return new Object [] {tableMappingSubset, subPathNodes}; 130 } 131 132 abstract void initExploration(VarInfoSet varInfoSet, AbstractConnection connection) 133 throws SQLException , XMLDBCException; 134 135 void freezeCurrentSubPath() 136 { 137 for (int i=0; i < queryTuples.length; i++) 138 { 139 if (queryTuples[i] != null) 140 ((QueryTuple)queryTuples[i]).freezeCurrentSubPath(); 141 } 142 qNode.freezeCurrentSubPath(); 143 qExtraNode.freezeCurrentSubPath(); 144 } 145 146 } 147 | Popular Tags |