1 22 23 package org.xquark.mapper.storage; 24 25 import java.sql.SQLException ; 26 27 import org.xquark.mapper.mapping.ColumnMapping; 28 import org.xquark.mapper.metadata.CollectionMappingInfo; 29 import org.xquark.schema.Declaration; 30 import org.xquark.schema.validation.ValidationContextProvider; 31 import org.xquark.xml.xdbc.XMLDBCException; 32 33 abstract class QueryTuple extends Tuple 34 { 35 36 private static final String RCSRevision = "$Revision: 1.1 $"; 37 private static final String RCSName = "$Name: $"; 38 39 protected int subPathIndex = -1; 40 41 protected int valueOffset = 0; 42 43 protected boolean currentResultExhausted = true; 44 45 protected int currentSubPathIndex = -2; 46 47 protected short tablePath = 0; 49 QueryTuple(CollectionMappingInfo table) 50 { 51 super(table); 52 } 53 54 QueryTuple(CollectionMappingInfo table, short pathID) 55 { 56 this(table); 57 tablePath = pathID; 58 } 59 60 protected String fetchValue(ColumnMapping column, Declaration decl, ValidationContextProvider nsContext) 61 throws SQLException , XMLDBCException 62 { 63 String ret = null; 64 try 65 { 66 if (resultActive()) 67 { 68 ret = column.getTypeInfo().getParameter(resultSet, 69 column.getInsertColumnIndex() + (table.getTableMapping().isClustered()?0:2) + valueOffset, 70 decl, 71 nsContext); 72 } 75 } 76 catch (SQLException e) 77 { 78 selectStmt.close(); 79 throw e; 80 } 81 return ret; 82 } 83 84 boolean resultActive() 85 { 86 return notExhausted && !currentResultExhausted; 87 } 88 89 long getUOID() 90 { 91 if (resultActive()) 92 return uoid; 93 else 94 return -1; 95 } 96 97 short getPathID() 98 { 99 if (resultActive()) 100 return super.getPathID(); 101 else 102 return -2; 103 } 104 105 void reset() throws SQLException 106 { 107 super.reset(); 108 subPathIndex = -1; 109 currentResultExhausted = true; 110 currentSubPathIndex = -2; 111 } 112 113 void freezeCurrentSubPath() 114 { 115 currentSubPathIndex++; 116 updateResultSegmentationFlag(); 117 } 118 119 protected void updateResultSegmentationFlag() 120 { 121 currentResultExhausted = (currentSubPathIndex != subPathIndex); 122 } 123 } 124 125 | Popular Tags |