bloritsch 00/11/15 08:49:40
Modified: src/org/apache/cocoon/matching Tag: xml-cocoon2
RegexpURIMatcherFactory.java
WildcardURIMatcherFactory.java
Log:
Made changes so that Cocoon works with WebSphere!!!!!!!!!!!
Revision Changes Path
No revision
No revision
1.1.2.14 +19 -17
xml-cocoon/src/org/apache/cocoon/matching/Attic/RegexpURIMatcherFactory.java
Index: RegexpURIMatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/RegexpURIMatcherFactory.java,v
retrieving revision 1.1.2.13
retrieving revision 1.1.2.14
diff -u -r1.1.2.13 -r1.1.2.14
--- RegexpURIMatcherFactory.java 2000/10/30 23:02:44 1.1.2.13
+++ RegexpURIMatcherFactory.java 2000/11/15 16:49:39 1.1.2.14
@@ -1,11 +1,11 @@
-/*****************************************************************************
- * Copyright (C) The Apache Software Foundation. All rights reserved.
*
- * -------------------------------------------------------------------------
*
- * This software is published under the terms of the Apache Software License
*
- * version 1.1, a copy of which has been included with this distribution in
*
- * the LICENSE file.
*
-
*****************************************************************************/
-package org.apache.cocoon.matching;
+/*****************************************************************************
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
*
+ * -------------------------------------------------------------------------
*
+ * This software is published under the terms of the Apache Software License
*
+ * version 1.1, a copy of which has been included with this distribution in
*
+ * the LICENSE file.
*
+
*****************************************************************************/
+package org.apache.cocoon.matching;
import org.apache.regexp.RECompiler;
import org.apache.regexp.REProgram;
@@ -14,15 +14,15 @@
import org.apache.avalon.ConfigurationException;
import org.w3c.dom.traversal.NodeIterator;
-
-/**
+
+/**
* This class generates source code which represents a specific pattern
matcher
* for request URIs
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.2.13 $ $Date: 2000/10/30 23:02:44 $
- */
+ * @version CVS $Revision: 1.1.2.14 $ $Date: 2000/11/15 16:49:39 $
+ */
public class RegexpURIMatcherFactory implements MatcherFactory {
public String generateParameterSource (NodeIterator conf)
@@ -30,7 +30,7 @@
return "RE";
}
- public String generateClassSource (String prefix, String pattern,
+ public String generateClassSource (String prefix, String pattern,
NodeIterator conf)
throws ConfigurationException {
StringBuffer sb = new StringBuffer ();
@@ -57,7 +57,7 @@
sb.append("0x").append(hex).append(", ");
}
sb.append("\n };")
- .append("\n static RE ")
+ .append("\n static RE ")
.append(name)
.append("_expr = new RE(new REProgram(")
.append(instructions)
@@ -72,7 +72,9 @@
throws ConfigurationException {
StringBuffer sb = new StringBuffer ();
sb.append("ArrayList list = new ArrayList ();")
-
.append("if(pattern.match(((HttpServletRequest)objectModel.get(Cocoon.REQUEST_OBJECT)).getRequestURI()))
{");
+ .append("String uri =
((HttpServletRequest)objectModel.get(Cocoon.REQUEST_OBJECT)).getRequestURI();")
+ .append("if(uri.startsWith(\"/\")) uri = uri.substring(1);")
+ .append("if(pattern.match(uri)) {");
// Count number of parens
/* int i = 0;
int j = -1;
1.1.2.20 +28 -22
xml-cocoon/src/org/apache/cocoon/matching/Attic/WildcardURIMatcherFactory.java
Index: WildcardURIMatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/WildcardURIMatcherFactory.java,v
retrieving revision 1.1.2.19
retrieving revision 1.1.2.20
diff -u -r1.1.2.19 -r1.1.2.20
--- WildcardURIMatcherFactory.java 2000/11/05 10:11:07 1.1.2.19
+++ WildcardURIMatcherFactory.java 2000/11/15 16:49:39 1.1.2.20
@@ -1,26 +1,26 @@
-/*****************************************************************************
- * Copyright (C) The Apache Software Foundation. All rights reserved.
*
- * -------------------------------------------------------------------------
*
- * This software is published under the terms of the Apache Software License
*
- * version 1.1, a copy of which has been included with this distribution in
*
- * the LICENSE file.
*
+/*****************************************************************************
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
*
+ * -------------------------------------------------------------------------
*
+ * This software is published under the terms of the Apache Software License
*
+ * version 1.1, a copy of which has been included with this distribution in
*
+ * the LICENSE file.
*
*****************************************************************************/
-
-package org.apache.cocoon.matching;
+package org.apache.cocoon.matching;
+
import org.apache.avalon.ConfigurationException;
import org.w3c.dom.traversal.NodeIterator;
-
-/**
+
+/**
* This class generates source code which represents a specific pattern
matcher
* for request URIs
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.2.19 $ $Date: 2000/11/05 10:11:07 $
- */
+ * @version CVS $Revision: 1.1.2.20 $ $Date: 2000/11/15 16:49:39 $
+ */
public class WildcardURIMatcherFactory implements MatcherFactory {
@@ -51,19 +51,25 @@
*/
public String generateMethodSource (NodeIterator conf)
throws ConfigurationException {
- return " ArrayList list = new ArrayList();\n if
(org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (list,
((HttpServletRequest) objectModel.get(Cocoon.REQUEST_OBJECT))\n
.getRequestURI(), pattern)) {\n return list;\n
} else {\n return null;\n }\n";
+ return "ArrayList list = new ArrayList();" +
+ "String uri = ((HttpServletRequest)
objectModel.get(Cocoon.REQUEST_OBJECT)).getRequestURI();" +
+ "if (uri.startsWith(\"/\")) uri = uri.substring(1);" +
+ "if
(org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (list, uri,
pattern)) {" +
+ "return list;" +
+ "} else {" +
+ "return null;}";
}
/**
* Generates the matcher class level source code
*/
- public String generateClassSource (String prefix, String pattern,
+ public String generateClassSource (String prefix, String pattern,
NodeIterator conf)
throws ConfigurationException {
StringBuffer result = new StringBuffer();
try {
this.setPattern (pattern);
-
+
result.append ("\n// wildcard pattern = \"" + pattern + "\"\n\t")
.append ("static int[] ").append(prefix).append("_expr =
{");
@@ -124,18 +130,18 @@
*/
protected int[] convertPattern(String data)
throws NullPointerException {
-
+
// Prepare the arrays
int expr[] = new int[data.length() + 2];
char buff[] = data.toCharArray();
-
+
// Prepare variables for the translation loop
int y = 0;
boolean slash = false;
// Must start from beginning
expr[y++] = MATCH_BEGIN;
-
+
if (buff.length > 0) {
if (buff[0]=='\\') {
slash = true;
@@ -144,7 +150,7 @@
} else {
expr[y++] = buff[0];
}
-
+
// Main translation loop
for (int x = 1; x < buff.length; x++) {
// If the previous char was '\' simply copy this char.
@@ -175,5 +181,5 @@
// Must match end at the end
expr[y] = MATCH_THEEND;
return expr;
- }
+ }
}