1 2 12 package com.versant.core.jdbc.fetch; 13 14 import com.versant.core.common.BindingSupportImpl; 15 import com.versant.core.jdbc.sql.exp.SelectExp; 16 import com.versant.core.jdbc.sql.exp.SqlExp; 17 18 import java.sql.SQLException ; 19 import java.io.PrintStream ; 20 21 26 public abstract class FetchOp { 27 28 protected final FetchSpec spec; 29 private int index; 30 31 public FetchOp(FetchSpec spec) { 32 this.spec = spec; 33 } 34 35 40 public abstract SqlExp init(SelectExp root, int firstColIndex); 41 42 46 public abstract FetchOpData getOutputData(); 47 48 51 public abstract void fetch(FetchResultImp fetchResult) throws SQLException ; 52 53 56 public abstract String getDescription(); 57 58 61 public void printPlan(PrintStream p, String indent) { 62 p.println(indent + getIndex() + ": " + getName() + " " + 63 getDescription()); 64 } 65 66 70 public String getName() { 71 String cname = getClass().getName(); 72 int i = cname.lastIndexOf(".Fop"); 73 if (i < 0) { 74 i = cname.lastIndexOf('.') + 1; 75 } else { 76 i += 4; 77 } 78 return cname.substring(i); 79 } 80 81 86 public void generateSQL() { 87 } 88 89 93 public void fetchResultClosed(FetchResult fetchResult) { 94 } 95 96 99 public Object getResult(FetchResultImp fetchResult) { 100 throw notImplemented(); 101 } 102 103 108 public int getResultType() { 109 throw notImplemented(); 110 } 111 112 public FetchSpec getSpec() { 113 return spec; 114 } 115 116 public int getIndex() { 117 return index; 118 } 119 120 public void setIndex(int index) { 121 this.index = index; 122 } 123 124 public RuntimeException notImplemented() { 125 return notImplemented("Not implemented for " + toString()); 126 } 127 128 public RuntimeException notImplemented(String msg) { 129 return internal(msg); 130 } 131 132 public RuntimeException internal(String msg) { 133 return BindingSupportImpl.getInstance().internal(msg); 134 } 135 136 public String toString() { 137 String s; 138 try { 139 s = toStringImp(); 140 } catch (Exception e) { 141 s = "<toStringImp failed: " + e + ">"; 142 } 143 return index + ": " + getName() + " " + getDescription() + 144 (s == null ? "" : " " + s); 145 } 146 147 151 protected String toStringImp() { 152 return null; 153 } 154 155 } 156 157 | Popular Tags |