1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.error.StandardException; 25 import org.apache.derby.iapi.reference.SQLState; 26 import org.apache.derby.iapi.sql.Activation; 27 28 import org.apache.derby.iapi.types.BooleanDataValue; 29 import org.apache.derby.iapi.types.StringDataValue; 30 import org.apache.derby.iapi.types.XML; 31 import org.apache.derby.iapi.types.XMLDataValue; 32 import org.apache.derby.iapi.types.SqlXmlUtil; 33 34 120 121 public class SqlXmlExecutor { 122 123 private Activation activation; 127 private int sqlXUtilId; 128 129 private int targetTypeId; 132 private int targetMaxWidth; 133 134 private boolean preserveWS; 137 138 144 public SqlXmlExecutor(Activation activation, int utilId, 145 boolean preserveWS) 146 { 147 this.activation = activation; 148 this.sqlXUtilId = utilId; 149 this.preserveWS = preserveWS; 150 } 151 152 157 public SqlXmlExecutor(int targetTypeId, int targetMaxWidth) 158 { 159 this.targetTypeId = targetTypeId; 160 this.targetMaxWidth = targetMaxWidth; 161 } 162 163 168 public SqlXmlExecutor(Activation activation, int utilId) 169 { 170 this.activation = activation; 171 this.sqlXUtilId = utilId; 172 } 173 174 187 public XMLDataValue XMLParse(StringDataValue xmlText, XMLDataValue result) 188 throws StandardException 189 { 190 if (result == null) 191 result = new XML(); 192 193 if (xmlText.isNull()) 194 { 195 result.setToNull(); 196 return result; 197 } 198 199 return result.XMLParse( 200 xmlText.getString(), preserveWS, getSqlXmlUtil()); 201 } 202 203 213 public StringDataValue XMLSerialize(XMLDataValue xmlVal, 214 StringDataValue result) throws StandardException 215 { 216 return xmlVal.XMLSerialize(result, targetTypeId, targetMaxWidth); 217 } 218 219 230 public BooleanDataValue XMLExists(StringDataValue xExpr, 231 XMLDataValue xmlContext) throws StandardException 232 { 233 return xmlContext.XMLExists(getSqlXmlUtil()); 234 } 235 236 251 public XMLDataValue XMLQuery(StringDataValue xExpr, 252 XMLDataValue xmlContext, XMLDataValue result) 253 throws StandardException 254 { 255 return xmlContext.XMLQuery(result, getSqlXmlUtil()); 256 } 257 258 263 private SqlXmlUtil getSqlXmlUtil() 264 throws StandardException 265 { 266 return (SqlXmlUtil) 267 activation.getPreparedStatement().getSavedObject(sqlXUtilId); 268 } 269 270 } 271 | Popular Tags |