1 21 22 package org.apache.derby.impl.sql; 23 24 import org.apache.derby.iapi.sql.ResultColumnDescriptor; 25 import org.apache.derby.iapi.sql.execute.ExecCursorTableReference; 26 import org.apache.derby.iapi.services.sanity.SanityManager; 27 28 import org.apache.derby.iapi.services.io.ArrayUtil; 29 import org.apache.derby.iapi.services.io.StoredFormatIds; 30 import org.apache.derby.iapi.services.io.FormatIdUtil; 31 import org.apache.derby.iapi.services.io.Formatable; 32 33 import java.io.ObjectOutput ; 34 import java.io.ObjectInput ; 35 import java.io.IOException ; 36 42 public class CursorInfo 43 implements Formatable 44 { 45 46 59 60 ExecCursorTableReference targetTable; 61 ResultColumnDescriptor[] targetColumns; 62 String [] updateColumns; 63 int updateMode; 64 65 68 public CursorInfo() 69 { 70 } 71 72 75 public CursorInfo 76 ( 77 int updateMode, 78 ExecCursorTableReference targetTable, 79 ResultColumnDescriptor[] targetColumns, 80 String [] updateColumns 81 ) 82 { 83 this.updateMode = updateMode; 84 this.targetTable = targetTable; 85 this.targetColumns = targetColumns; 86 this.updateColumns = updateColumns; 87 } 88 89 101 public void writeExternal(ObjectOutput out) throws IOException 102 { 103 out.writeInt(updateMode); 104 out.writeObject(targetTable); 105 ArrayUtil.writeArray(out, targetColumns); 106 ArrayUtil.writeArray(out, updateColumns); 107 } 108 109 117 public void readExternal(ObjectInput in) 118 throws IOException , ClassNotFoundException 119 { 120 updateMode = in.readInt(); 121 targetTable = (ExecCursorTableReference)in.readObject(); 122 int len = ArrayUtil.readArrayLength(in); 123 if (len != 0) 124 { 125 targetColumns = new ResultColumnDescriptor[len]; 126 ArrayUtil.readArrayItems(in, targetColumns); 127 } 128 len = ArrayUtil.readArrayLength(in); 129 if (len != 0) 130 { 131 updateColumns = new String [len]; 132 ArrayUtil.readArrayItems(in, updateColumns); 133 } 134 } 135 136 141 public int getTypeFormatId() { return StoredFormatIds.CURSOR_INFO_V01_ID; } 142 143 public String toString() 144 { 145 if (SanityManager.DEBUG) 146 { 147 StringBuffer strbuf = new StringBuffer (); 148 149 strbuf.append("CursorInfo"+ 150 "\n\tupdateMode: "+updateMode+ 151 "\n\ttargetTable: "+targetTable+ 152 "\n\tupdateColumns: "); 153 154 if (updateColumns == null) 155 { 156 strbuf.append("NULL\n"); 157 } 158 else 159 { 160 strbuf.append("{"); 161 for (int i = 0; i < updateColumns.length; i++) 162 { 163 if (i > 0) 164 strbuf.append(","); 165 strbuf.append(updateColumns[i]); 166 } 167 strbuf.append(")\n"); 168 } 169 170 strbuf.append("\tTargetColumnDescriptors: \n"); 171 if (targetColumns == null) 172 { 173 strbuf.append("NULL"); 174 } 175 else 176 { 177 for (int i = 0; i < targetColumns.length; i++) 178 { 179 strbuf.append(targetColumns[i]); 180 } 181 strbuf.append("\n"); 182 } 183 return strbuf.toString(); 184 } 185 else 186 { 187 return ""; 188 } 189 } 190 } 191 | Popular Tags |