1 22 23 package org.continuent.sequoia.controller.requests; 24 25 36 public final class RequestType 37 { 38 40 public static final int CACHEABLE = 0; 41 42 43 public static final int UNCACHEABLE = 1; 44 45 49 public static final int UNIQUE_CACHEABLE = 2; 50 51 52 public static final int UNDEFINED = 0; 53 54 public static final int DELETE = 1; 55 56 public static final int INSERT = 2; 57 58 public static final int UPDATE = 3; 59 60 public static final int SELECT = 4; 61 62 public static final int UNKNOWN_READ = 5; 63 64 public static final int UNKNOWN_WRITE = 6; 65 66 69 70 public static final int STORED_PROCEDURE = 10; 71 72 75 76 public static final int CREATE = 20; 77 78 public static final int ALTER = 21; 79 80 public static final int DROP = 22; 81 82 94 static boolean isDDL(int requestType) 95 { 96 return RequestType.STORED_PROCEDURE >= requestType; 97 } 98 99 110 static boolean isDML(int requestType) 111 { 112 return RequestType.STORED_PROCEDURE <= requestType; 113 } 114 115 122 static boolean isDelete(int requestType) 123 { 124 return RequestType.DELETE == requestType; 125 } 126 127 134 static boolean isInsert(int requestType) 135 { 136 return RequestType.INSERT == requestType; 137 } 138 139 146 static boolean isUpdate(int requestType) 147 { 148 return RequestType.UPDATE == requestType; 149 } 150 151 158 static boolean isDrop(int requestType) 159 { 160 return RequestType.DROP == requestType; 161 } 162 163 170 static boolean isCreate(int requestType) 171 { 172 return RequestType.CREATE == requestType; 173 } 174 175 182 static boolean isAlter(int requestType) 183 { 184 return RequestType.ALTER == requestType; 185 } 186 187 194 static boolean isSelect(int requestType) 195 { 196 return RequestType.SELECT == requestType; 197 } 198 199 206 static boolean isStoredProcedure(int requestType) 207 { 208 return RequestType.STORED_PROCEDURE == requestType; 209 } 210 211 218 public static int getRequestType(AbstractRequest request) 219 { 220 return request.requestType; 221 } 222 223 227 static void setRequestType(AbstractRequest request, int type) 228 { 229 request.requestType = type; 230 } 231 232 238 public static String getInformation(int type) 239 { 240 switch (type) 241 { 242 case RequestType.CACHEABLE : 243 return "CACHEABLE"; 244 case RequestType.UNCACHEABLE : 245 return "UNCACHEABLE"; 246 case RequestType.UNIQUE_CACHEABLE : 247 return "UNIQUE_CACHEABLE"; 248 default : 249 return "Illegal request type"; 250 } 251 } 252 253 267 static String getTypeAsString(AbstractRequest request) 268 { 269 if (request instanceof SelectRequest) 270 { 271 return "read request"; 272 } 273 if (request instanceof AbstractWriteRequest) 274 { 275 return "write request"; 276 } 277 if (request instanceof StoredProcedure) 278 { 279 return "stored procedure"; 280 } 281 return "request of undefined type"; 282 } 283 284 303 static String getTypeAsString(int type) 304 { 305 switch (type) 306 { 307 case DELETE : 308 return "DELETE"; 309 case INSERT : 310 return "INSERT"; 311 case UPDATE : 312 return "UPDATE"; 313 case SELECT : 314 return "SELECT"; 315 case UNKNOWN_READ : 316 return "UNKNOWN_READ"; 317 case UNKNOWN_WRITE : 318 return "UNKNOWN_WRITE"; 319 case STORED_PROCEDURE : 320 return "STORED_PROCEDURE"; 321 case CREATE : 322 return "CREATE"; 323 case ALTER : 324 return "ALTER"; 325 case DROP : 326 return "DROP"; 327 default : return "UNDEFINED"; 329 } 330 } 331 } 332 | Popular Tags |