src/org/objectweb/cjdbc/controller/backend/rewriting/SimpleRewritingRule.java

説明を見る。
00001 00025 package org.objectweb.cjdbc.controller.backend.rewriting; 00026 00033 public class SimpleRewritingRule extends AbstractRewritingRule 00034 { 00035 00036 private int queryPatternLength; 00037 00047 public SimpleRewritingRule(String queryPattern, String rewrite, 00048 boolean caseSensitive, boolean stopOnMatch) 00049 { 00050 super(queryPattern, caseSensitive ? rewrite : rewrite.toLowerCase(), 00051 caseSensitive, stopOnMatch); 00052 queryPatternLength = queryPattern.length(); 00053 } 00054 00058 public String rewrite(String sqlQuery) 00059 { 00060 // Check first if it is a match 00061 int start; 00062 if (isCaseSensitive) 00063 start = sqlQuery.indexOf(queryPattern); 00064 else 00065 start = sqlQuery.toLowerCase().indexOf(queryPattern); 00066 if (start == -1) 00067 { // No match 00068 hasMatched = false; 00069 return sqlQuery; 00070 } 00071 // Match, rewrite the query 00072 hasMatched = true; 00073 if (start == 0) 00074 { 00075 if (queryPatternLength < sqlQuery.length()) 00076 // Match at the beginning of the pattern 00077 return rewrite + sqlQuery.substring(queryPatternLength); 00078 else 00079 // The query was exactly the pattern 00080 return rewrite; 00081 } 00082 else 00083 { 00084 if (start + queryPatternLength < sqlQuery.length()) 00085 return sqlQuery.substring(0, start) + rewrite 00086 + sqlQuery.substring(start + queryPatternLength); 00087 else 00088 // Match at the end of the pattern 00089 return sqlQuery.substring(0, start) + rewrite; 00090 } 00091 } 00092 00093 }

CJDBCversion1.0.4に対してTue Oct 12 15:16:00 2004に生成されました。 doxygen 1.3.8