You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by pr...@apache.org on 2001/02/23 16:08:11 UTC
cvs commit: xml-cocoon/src/org/apache/cocoon/matching RegexpTargetHostMatcherFactory.java
prussell 01/02/23 07:08:11
Modified: src/org/apache/cocoon/matching Tag: xml-cocoon2
RegexpTargetHostMatcherFactory.java
Log:
Fixing some braindead copy/paste code. I will refactor, I will refactor, I
will [snip - ed]
Revision Changes Path
No revision
No revision
1.1.2.9 +6 -6 xml-cocoon/src/org/apache/cocoon/matching/Attic/RegexpTargetHostMatcherFactory.java
Index: RegexpTargetHostMatcherFactory.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/RegexpTargetHostMatcherFactory.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- RegexpTargetHostMatcherFactory.java 2001/02/20 13:50:21 1.1.2.8
+++ RegexpTargetHostMatcherFactory.java 2001/02/23 15:08:10 1.1.2.9
@@ -27,7 +27,7 @@
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
* @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
- * @version CVS $Revision: 1.1.2.8 $ $Date: 2001/02/20 13:50:21 $
+ * @version CVS $Revision: 1.1.2.9 $ $Date: 2001/02/23 15:08:10 $
*/
public class RegexpTargetHostMatcherFactory implements CodeFactory, Loggable {
@@ -48,11 +48,11 @@
NodeList conf)
throws ConfigurationException {
StringBuffer sb = new StringBuffer ();
+ String pat = correctPattern(pattern);
try {
RECompiler r = new RECompiler();
String name = prefix;
String instructions = name + "PatternInstructions";
- String pat = correctPattern (pattern);
sb.append("\n // Pre-compiled regular expression '")
.append(pat).append("'\n")
.append(" static char[] ");
@@ -78,7 +78,7 @@
.append("));");
return sb.toString();
} catch (RESyntaxException rse) {
- log.warn("RegexpTargetHostMatcherFactory:RESyntaxException", rse);
+ log.warn("Syntax exception while compiling regexp '" + pat + "'.", rse);
throw new ConfigurationException (rse.getMessage(), rse);
}
}
@@ -87,9 +87,9 @@
throws ConfigurationException {
StringBuffer sb = new StringBuffer ();
sb.append("HashMap map = new HashMap ();")
- .append("String uri = ((HttpServletRequest)objectModel.get(Constants.REQUEST_OBJECT)).getHeader(\"Host\");")
- .append("if(uri.startsWith(\"/\")) uri = uri.substring(1);")
- .append("if(pattern.match(uri)) {");
+ .append("String host = ((HttpServletRequest)objectModel.get(Constants.REQUEST_OBJECT)).getHeader(\"Host\");")
+ .append("getLogger().debug(\"Matching against host: \" + host + \".\");")
+ .append("if(pattern.match(host)) {");
/* Handle parenthesised subexpressions. XXX: could be faster if we count
* parens *outside* the generated code.
* Note: *ONE* based, not zero.