You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2005/01/21 15:06:50 UTC
svn commit: r125929 - in cocoon/trunk: src/core/java/org/apache/cocoon/core/container src/core/java/org/apache/cocoon/matching src/core/java/org/apache/cocoon/matching/helpers src/java/org/apache/cocoon/matching/helpers src/webapp/WEB-INF tools/targets
Author: cziegeler
Date: Fri Jan 21 06:06:49 2005
New Revision: 125929
URL: http://svn.apache.org/viewcvs?view=rev&rev=125929
Log:
Use flat patterns for include
Added:
cocoon/trunk/src/core/java/org/apache/cocoon/matching/
cocoon/trunk/src/core/java/org/apache/cocoon/matching/helpers/
cocoon/trunk/src/core/java/org/apache/cocoon/matching/helpers/WildcardHelper.java
- copied, changed from r125902, cocoon/trunk/src/java/org/apache/cocoon/matching/helpers/WildcardHelper.java
Removed:
cocoon/trunk/src/java/org/apache/cocoon/matching/helpers/WildcardHelper.java
Modified:
cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java
cocoon/trunk/src/webapp/WEB-INF/cocoon.xconf
cocoon/trunk/tools/targets/compile-build.xml
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java?view=diff&rev=125929&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java&r1=125928&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java&r2=125929
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CoreServiceManager.java Fri Jan 21 06:06:49 2005
@@ -50,6 +50,7 @@
import org.apache.cocoon.core.container.handler.InstanceComponentHandler;
import org.apache.cocoon.core.container.handler.LazyHandler;
import org.apache.cocoon.core.source.SimpleSourceResolver;
+import org.apache.cocoon.matching.helpers.WildcardHelper;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
import org.apache.excalibur.source.TraversableSource;
@@ -674,7 +675,11 @@
loadURI(src, loadedURIs, includeStatement);
} else {
- final String ending = includeStatement.getAttribute("postfix", null);
+ final String pattern = includeStatement.getAttribute("pattern", null);
+ int[] parsedPattern = null;
+ if ( pattern != null ) {
+ parsedPattern = WildcardHelper.compilePattern(pattern);
+ }
Source directory = null;
try {
directory = this.cachedSourceResolver.resolveURI(directoryURI, contextURI, CONTEXT_PARAMETERS);
@@ -682,7 +687,7 @@
final Iterator children = ((TraversableSource)directory).getChildren().iterator();
while ( children.hasNext() ) {
final Source s = (Source)children.next();
- if ( ending == null || s.getURI().endsWith(ending) ) {
+ if ( parsedPattern == null || this.match(s.getURI(), parsedPattern)) {
this.loadURI(s, loadedURIs, includeStatement);
}
}
@@ -766,6 +771,13 @@
}
}
+ private boolean match(String uri, int[] parsedPattern ) {
+ int pos = uri.lastIndexOf('/');
+ if ( pos != -1 ) {
+ uri = uri.substring(pos+1);
+ }
+ return WildcardHelper.match(null, uri, parsedPattern);
+ }
/**
* Release the source resolver that may have been created by the first call to
* loadConfiguration().
Copied: cocoon/trunk/src/core/java/org/apache/cocoon/matching/helpers/WildcardHelper.java (from r125902, cocoon/trunk/src/java/org/apache/cocoon/matching/helpers/WildcardHelper.java)
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/matching/helpers/WildcardHelper.java?view=diff&rev=125929&p1=cocoon/trunk/src/java/org/apache/cocoon/matching/helpers/WildcardHelper.java&r1=125902&p2=cocoon/trunk/src/core/java/org/apache/cocoon/matching/helpers/WildcardHelper.java&r2=125929
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/matching/helpers/WildcardHelper.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/matching/helpers/WildcardHelper.java Fri Jan 21 06:06:49 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
- * @version CVS $Id: WildcardHelper.java,v 1.2 2004/03/05 13:02:57 bdelacretaz Exp $
+ * @version CVS $Id$
*/
public class WildcardHelper {
@@ -133,14 +133,14 @@
* match a pattern agains a string and isolates wildcard replacement into a
* <code>Stack</code>.
*/
- public static boolean match (HashMap map, String data,
- int[] expr) throws NullPointerException {
- if (map == null)
- throw new NullPointerException ("No map provided");
- if (data == null)
+ public static boolean match (HashMap map, String data, int[] expr)
+ throws NullPointerException {
+ if (data == null) {
throw new NullPointerException ("No data provided");
- if (expr == null)
+ }
+ if (expr == null) {
throw new NullPointerException ("No pattern expression provided");
+ }
char buff[] = data.toCharArray();
@@ -161,8 +161,10 @@
// The matching count
int mcount = 0;
- // We want the complete data be in {0}
- map.put(Integer.toString(mcount),data);
+ if ( map != null ) {
+ // We want the complete data be in {0}
+ map.put(Integer.toString(mcount),data);
+ }
// First check for MATCH_BEGIN
boolean matchBegin = false;
@@ -204,13 +206,15 @@
// Check for END's
if (exprchr == MATCH_END) {
- if (rsltpos > 0)
+ if (rsltpos > 0 && map != null) {
map.put(Integer.toString(++mcount),new String(rslt, 0, rsltpos));
+ }
// Don't care about rest of input buffer
return (true);
} else if (exprchr == MATCH_THEEND) {
- if (rsltpos > 0)
+ if (rsltpos > 0 && map != null ) {
map.put (Integer.toString(++mcount),new String(rslt, 0, rsltpos));
+ }
// Check that we reach buffer's end
return (buffpos == buff.length);
}
@@ -245,7 +249,9 @@
}
}
- map.put(Integer.toString(++mcount),new String (rslt, 0, rsltpos));
+ if ( map != null ) {
+ map.put(Integer.toString(++mcount),new String (rslt, 0, rsltpos));
+ }
rsltpos = 0;
}
}
Deleted: /cocoon/trunk/src/java/org/apache/cocoon/matching/helpers/WildcardHelper.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/matching/helpers/WildcardHelper.java?view=auto&rev=125928
==============================================================================
Modified: cocoon/trunk/src/webapp/WEB-INF/cocoon.xconf
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/WEB-INF/cocoon.xconf?view=diff&rev=125929&p1=cocoon/trunk/src/webapp/WEB-INF/cocoon.xconf&r1=125928&p2=cocoon/trunk/src/webapp/WEB-INF/cocoon.xconf&r2=125929
==============================================================================
--- cocoon/trunk/src/webapp/WEB-INF/cocoon.xconf (original)
+++ cocoon/trunk/src/webapp/WEB-INF/cocoon.xconf Fri Jan 21 06:06:49 2005
@@ -32,11 +32,11 @@
| Include all configuration files ending with ".xconf"
| from the xconf directory.
+-->
- <include dir="context://WEB-INF/xconf" postfix=".xconf"/>
+ <include dir="context://WEB-INF/xconf" pattern="*.xconf"/>
<!--+
| Include all configuration files ending with ".samplesxconf"
| from the xconf directory.
+-->
- <include dir="context://WEB-INF/xconf" postfix=".samplesxconf"/>
+ <include dir="context://WEB-INF/xconf" pattern="*.samplesxconf"/>
</cocoon>
Modified: cocoon/trunk/tools/targets/compile-build.xml
Url: http://svn.apache.org/viewcvs/cocoon/trunk/tools/targets/compile-build.xml?view=diff&rev=125929&p1=cocoon/trunk/tools/targets/compile-build.xml&r1=125928&p2=cocoon/trunk/tools/targets/compile-build.xml&r2=125929
==============================================================================
--- cocoon/trunk/tools/targets/compile-build.xml (original)
+++ cocoon/trunk/tools/targets/compile-build.xml Fri Jan 21 06:06:49 2005
@@ -48,6 +48,11 @@
<exclude name="**/*.java"/>
</fileset>
</copy>
+ <copy todir="${build.dest}">
+ <fileset dir="${src.core}">
+ <exclude name="**/*.java"/>
+ </fileset>
+ </copy>
<echo message="Compiling Cocoon Core"/>
<javac srcdir="${src.core}"