You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gi...@locus.apache.org on 2000/12/15 21:35:18 UTC
cvs commit: xml-cocoon/src/org/apache/cocoon/sitemap AbstractSitemap.java
giacomo 00/12/15 12:35:17
Modified: src/org/apache/cocoon/acting Tag: xml-cocoon2 Action.java
HelloAction.java LangSelect.java
src/org/apache/cocoon/components/language/markup/sitemap/java
Tag: xml-cocoon2 sitemap.xsl
src/org/apache/cocoon/matching Tag: xml-cocoon2 Matcher.java
RegexpTargetHostMatcherFactory.java
RegexpURIMatcherFactory.java
WildcardURIMatcherFactory.java
src/org/apache/cocoon/matching/helpers Tag: xml-cocoon2
WildcardURIMatcher.java
src/org/apache/cocoon/sitemap Tag: xml-cocoon2
AbstractSitemap.java
Removed: src/org/apache/cocoon/matching Tag: xml-cocoon2
MatcherFactory.java
Log:
Changed return type of Action and Matcher from List to Map. This allows Matcher and Action to return a HashMap with named object and those names can be used in the sitemap as replacemant value ( {lang} )
Revision Changes Path
No revision
No revision
1.1.2.5 +2 -3 xml-cocoon/src/org/apache/cocoon/acting/Attic/Action.java
Index: Action.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/acting/Attic/Action.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- Action.java 2000/12/11 15:14:33 1.1.2.4
+++ Action.java 2000/12/15 20:35:08 1.1.2.5
@@ -7,7 +7,6 @@
*****************************************************************************/
package org.apache.cocoon.acting;
-import java.util.List;
import java.util.Map;
import org.apache.avalon.Component;
@@ -20,7 +19,7 @@
/**
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/12/11 15:14:33 $
+ * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/12/15 20:35:08 $
*/
public interface Action extends Component, ThreadSafe {
/**
@@ -48,7 +47,7 @@
* be skipped.
* @exception Exception Indicates something is totally wrong
*/
- List act(EntityResolver resolver, Map objectModel, String source, Parameters par)
+ Map act(EntityResolver resolver, Map objectModel, String source, Parameters par)
throws Exception;
}
1.1.2.7 +2 -3 xml-cocoon/src/org/apache/cocoon/acting/Attic/HelloAction.java
Index: HelloAction.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/acting/Attic/HelloAction.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- HelloAction.java 2000/12/06 22:54:10 1.1.2.6
+++ HelloAction.java 2000/12/15 20:35:09 1.1.2.7
@@ -7,7 +7,6 @@
*****************************************************************************/
package org.apache.cocoon.acting;
-import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
@@ -26,7 +25,7 @@
/**
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/12/06 22:54:10 $
+ * @version CVS $Revision: 1.1.2.7 $ $Date: 2000/12/15 20:35:09 $
*/
public class HelloAction extends ComposerAction {
@@ -40,7 +39,7 @@
* A simple Action that logs if the <code>Session</code> object
* has been created
*/
- public List act (EntityResolver resolver, Map objectModel, String src, Parameters par) throws Exception {
+ public Map act (EntityResolver resolver, Map objectModel, String src, Parameters par) throws Exception {
HttpServletRequest req = (HttpServletRequest) objectModel.get(Constants.REQUEST_OBJECT);
if (req != null) {
HttpSession session = req.getSession (false);
1.1.2.2 +149 -125 xml-cocoon/src/org/apache/cocoon/acting/Attic/LangSelect.java
Index: LangSelect.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/acting/Attic/LangSelect.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- LangSelect.java 2000/12/13 13:53:31 1.1.2.1
+++ LangSelect.java 2000/12/15 20:35:09 1.1.2.2
@@ -1,15 +1,17 @@
-/*****************************************************************************
+/**
+ ****************************************************************************
* 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.acting;
/**
* LangSelect Action returns two character language code to sitemap.
- *
+ *
* Definition in sitemap:
* <map:actions>
* <map:action name="lang_select" src="org.apache.cocoon.acting.LangSelect"/>
@@ -17,12 +19,12 @@
* And you use it in following way:
*
* <map:match pattern="file">
- * <map:act type="lang_select">
+ * <map:act type="lang_select">
* <map:generate src="file_{1}.xml"/>
- * </map:act>
+ * </map:act>
*
* {1} is substituted with language code.
- * eg. if user selects url ../file?lang=en
+ * eg. if user selects url ../file?lang=en
* then Sitemap engine generates file_en.xml source.
*
*
@@ -30,125 +32,147 @@
* @author: <a href="mailto:lassi.immonen@valkeus.com">Lassi Immonen</a>
*/
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
import org.apache.cocoon.acting.Action;
-import java.util.*;
-import javax.servlet.http.*;
+
import org.apache.avalon.Parameters;
-
-public class LangSelect implements Action {
- private final static String default_lang = "en";
-/**
-* Selects language if it is not set already in objectModel
-* Puts lang parameter to session and to objectModel
-* if it is not already there.
-*/
-public java.util.List act(
- org.xml.sax.EntityResolver resolver,
- java.util.Map objectModel,
- String source,
- org.apache.avalon.Parameters par)
- throws Exception {
-
- String lang;
-
- if (objectModel.containsKey("lang"))
- lang = (String)objectModel.get("lang");
- else {
- lang = getLang(objectModel, par);
- objectModel.put("lang", lang);
- }
-
- HttpServletRequest req = (HttpServletRequest) objectModel.get("request");
-
- HttpSession session = req.getSession();
- if (session != null) {
- if (session.getAttribute("lang") == null)
- session.setAttribute("lang", lang);
- }
-
- List l = new Vector();
- l.add(lang);
- return l;
-}
-/**
- * Returns two character language code by checking environment in following order
- * 1. Http request has parameter lang
- * 2. Http session has parameter lang
- * 3. Cookies has parameter lang
- * 4. User locales has matching language we are providing
- * 5. Otherwise we return default_lang from sitemap or if that is not found then 'en'
- * @return java.lang.String
- * @param objectModel java.util.Map
- * @param par org.apache.avalon.Parameters
- */
-public static String getLang(
- java.util.Map objectModel,
- org.apache.avalon.Parameters par) {
-
- Vector langs_avail = new Vector();
- Vector langs_user = new Vector();
-
- java.util.Iterator params = par.getParameterNames();
- while (params.hasNext()) {
- String paramname = (String) params.next();
- if (paramname.startsWith("available_lang"))
- langs_avail.add(par.getParameter(paramname, null));
- }
- String def_lang = par.getParameter("default_lang", default_lang);
-
- HttpServletRequest req = (HttpServletRequest) objectModel.get("request");
-
- String lang = null;
-
- lang = req.getParameter("lang");
-
- if (lang == null) {
- HttpSession session = req.getSession(false);
- if (session != null) {
- Object session_lang = session.getAttribute("lang");
- if (session_lang != null) {
- lang = session_lang.toString();
- }
- }
-
- }
-
- if (lang == null) {
- Cookie[] cookies = req.getCookies();
- if (cookies != null) {
- for (int i = 0; i < cookies.length; i++) {
- Cookie cookie = cookies[i];
- if (cookie.getName().equals("lang")) {
- lang = cookie.getValue();
- }
- }
- }
- }
-
- if (lang == null) {
-
- Enumeration locales = req.getLocales();
- while (locales.hasMoreElements()) {
- Locale locale = (Locale) locales.nextElement();
- langs_user.add(locale.getLanguage());
- }
-
- boolean match = false;
- int i = 0;
-
- for (; i < langs_user.size() && !match; i++) {
- for (int j = 0; j < langs_avail.size(); j++) {
- if (((String) langs_user.get(i)).equals((String) langs_avail.get(j))) {
- match = true;
- break;
- }
- }
- }
- if (match)
- lang = (String) langs_user.get(i - 1);
- else
- lang = def_lang;
- }
- return lang;
-}
+
+import org.xml.sax.EntityResolver;
+
+
+
+
+public class LangSelect extends java.lang.Object implements Action {
+ private final static String default_lang = "en";
+
+
+
+ /**
+ * Selects language if it is not set already in objectModel
+ * Puts lang parameter to session and to objectModel
+ * if it is not already there.
+ */
+ public Map act(EntityResolver resolver, Map objectModel, String source,
+ Parameters par) throws Exception {
+
+ String lang;
+
+ if (objectModel.containsKey("lang")) {
+ lang = (String)(objectModel.get("lang"));
+ } else {
+ lang = getLang(objectModel, par);
+ objectModel.put("lang", lang);
+ }
+
+ HttpServletRequest req =
+ (HttpServletRequest)(objectModel.get("request"));
+
+ HttpSession session = req.getSession();
+ if (session != null) {
+ if (session.getAttribute("lang") == null) {
+ session.setAttribute("lang", lang);
+ }
+ }
+
+ Map m = new HashMap(1);
+ m.put("lang", lang);
+ return m;
+ }
+
+
+
+ /**
+ * Returns two character language code by checking environment in following order
+ * 1. Http request has parameter lang
+ * 2. Http session has parameter lang
+ * 3. Cookies has parameter lang
+ * 4. User locales has matching language we are providing
+ * 5. Otherwise we return default_lang from sitemap or if that is not found then 'en'
+ * @return java.lang.String
+ * @param objectModel java.util.Map
+ * @param par org.apache.avalon.Parameters
+ */
+ public static String getLang(Map objectModel, Parameters par) {
+
+ List langs_avail = new ArrayList();
+ List langs_user = new ArrayList();
+
+ Iterator params = par.getParameterNames();
+ while (params.hasNext()) {
+ String paramname = (String)(params.next());
+ if (paramname.startsWith("available_lang")) {
+ langs_avail.add(par.getParameter(paramname, null));
+ }
+ }
+ String def_lang = par.getParameter("default_lang", default_lang);
+
+ HttpServletRequest req =
+ (HttpServletRequest)(objectModel.get("request"));
+
+ String lang = null;
+
+ lang = req.getParameter("lang");
+
+ if (lang == null) {
+ HttpSession session = req.getSession(false);
+ if (session != null) {
+ Object session_lang = session.getAttribute("lang");
+ if (session_lang != null) {
+ lang = session_lang.toString();
+ }
+ }
+
+ }
+
+ if (lang == null) {
+ Cookie[] cookies = req.getCookies();
+ if (cookies != null) {
+ for ( int i = 0; i < cookies.length; i++) {
+ Cookie cookie = cookies[i];
+ if (cookie.getName().equals("lang")) {
+ lang = cookie.getValue();
+ }
+ }
+ }
+ }
+
+ if (lang == null) {
+
+ Enumeration locales = req.getLocales();
+ while (locales.hasMoreElements()) {
+ Locale locale = (Locale)(locales.nextElement());
+ langs_user.add(locale.getLanguage());
+ }
+
+ boolean match = false;
+ int i = 0;
+
+ for ( ; i < langs_user.size() && !match; i++) {
+ for ( int j = 0; j < langs_avail.size(); j++) {
+ if (((String)(langs_user.get(i))).equals(
+ (String)(langs_avail.get(j)))) {
+ match = true;
+ break;
+ }
+ }
+ }
+ if (match) {
+ lang = (String)(langs_user.get(i - 1));
+ } else {
+ lang = def_lang;
+ }
+ }
+ return lang;
+ }
}
No revision
No revision
1.1.2.72 +34 -33 xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl
Index: sitemap.xsl
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl,v
retrieving revision 1.1.2.71
retrieving revision 1.1.2.72
diff -u -r1.1.2.71 -r1.1.2.72
--- sitemap.xsl 2000/12/15 01:02:41 1.1.2.71
+++ sitemap.xsl 2000/12/15 20:35:11 1.1.2.72
@@ -46,6 +46,7 @@
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
+ import java.util.HashMap;
import java.util.Stack;
import javax.servlet.http.HttpServletRequest;
@@ -77,7 +78,7 @@
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.2.71 $ $Date: 2000/12/15 01:02:41 $
+ * @version CVS $Revision: 1.1.2.72 $ $Date: 2000/12/15 20:35:11 $
*/
public class <xsl:value-of select="@file-name"/> extends AbstractSitemap {
static final String LOCATION = "<xsl:value-of select="translate(@file-path, '/', '.')"/>.<xsl:value-of select="@file-name"/>";
@@ -105,7 +106,7 @@
<xsl:variable name="type" select="translate(@name, '- ', '__')"/>
<xsl:variable name="default" select="$type = ../@default"/>
<xsl:variable name="config"><xsl:copy-of select="."/></xsl:variable>
- private List <xsl:value-of select="$type"/>Match (<xsl:value-of select="java:getParameterSource($factory-loader, string($src),$config)"/> pattern, Map objectModel) {
+ private Map <xsl:value-of select="$type"/>Match (<xsl:value-of select="java:getParameterSource($factory-loader, string($src),$config)"/> pattern, Map objectModel) {
<xsl:value-of select="java:getMethodSource($factory-loader, string($src),$config)"/>
}
<!-- process all map:match elements with a type attribute refering to the current matcher factory iteration -->
@@ -232,16 +233,16 @@
/**
* This is the internal resource named "<xsl:value-of select="@name"/>"
* @param pipeline A <code>ResourcePipeline</code> holding the sitemap component collected so far
- * @param listOfLists A <code>List</code> holding replacement values for src attributes
+ * @param listOfMaps A <code>List</code> of Maps holding replacement values for src attributes
* @param environment The <code>Environment</code> requesting a resource
* @param cocoon_view The view of the resource requested
* @return Wether the request has been processed or not
* @exception Exception If an error occurs during request evaluation and production
*/
private boolean resource_<xsl:value-of select="translate(@name, '- ', '__')"/> (ResourcePipeline pipeline,
- List listOfLists, Environment environment, String cocoon_view)
+ List listOfMaps, Environment environment, String cocoon_view)
throws Exception {
- List list = null;
+ Map map = null;
Parameters param = null;
<xsl:apply-templates select="./*"/>
return false;
@@ -253,15 +254,15 @@
/**
* This is the method to produce the "<xsl:value-of select="@name"/>" view of the requested resource
* @param pipeline A <code>ResourcePipeline</code> holding the sitemap component collected so far
- * @param listOfLists A <code>List</code> holding replacement values for src attributes
+ * @param listOfMaps A <code>List</code> of Maps holding replacement values for src attributes
* @param environment The <code>Environment</code> requesting a resource
* @return Wether the request has been processed or not
* @exception Exception If an error occurs during request evaluation and production
*/
private boolean view_<xsl:value-of select="translate(@name, '- ', '__')"/> (ResourcePipeline pipeline,
- List listOfLists, Environment environment)
+ List listOfMaps, Environment environment)
throws Exception {
- List list = null;
+ Map map = null;
Parameters param = null;
<xsl:apply-templates select="./*"/>
return false;
@@ -280,8 +281,8 @@
delivered from matchers and selectors to replace occurences of
XPath kind expressions in values of src attribute used with
generate and transform elements */
- List listOfLists = (List) new ArrayList();
- List list;
+ List listOfMaps = (List) new ArrayList();
+ Map map;
Parameters param;
Map objectModel = environment.getObjectModel();
String cocoon_view = environment.getView();
@@ -318,8 +319,8 @@
private boolean error_process_<xsl:value-of select="$pipeline-position"/> (Environment environment, Map objectModel, Exception e)
throws Exception {
ResourcePipeline pipeline = new ResourcePipeline (super.sitemapComponentManager);
- List listOfLists = (List)(new ArrayList());
- List list;
+ List listOfMaps = (List)(new ArrayList());
+ Map map;
Parameters param;
pipeline.setGenerator ("!generator:error-notifier!", e.getMessage(), emptyParam, e);
<xsl:apply-templates select="./map:handle-errors/*"/>
@@ -392,12 +393,12 @@
</xsl:variable>
<!-- this is the actual code produced -->
- if ((list = <xsl:value-of select="translate($matcher-type, '- ', '__')"/>Match(<xsl:value-of select="$matcher-name"/>_expr,
+ if ((map = <xsl:value-of select="translate($matcher-type, '- ', '__')"/>Match(<xsl:value-of select="$matcher-name"/>_expr,
objectModel)) != null) {
log.debug("Matched <xsl:value-of select="$matcher-name"/>");
- listOfLists.add (list);
+ listOfMaps.add (map);
<xsl:apply-templates/>
- listOfLists.remove (list);
+ listOfMaps.remove (map);
}
</xsl:template> <!-- match="map:match" -->
@@ -530,15 +531,15 @@
<!-- generate the invocation of the act method of the action component -->
<xsl:choose>
<xsl:when test="./*">
- if ((list = <xsl:value-of select="$action-name"/> (environment, objectModel, substitute(listOfLists,<xsl:value-of select="$action-source"/>), <xsl:value-of select="$component-param"/>)) != null) {
+ if ((map = <xsl:value-of select="$action-name"/> (environment, objectModel, substitute(listOfMaps,<xsl:value-of select="$action-source"/>), <xsl:value-of select="$component-param"/>)) != null) {
log.debug("Action <xsl:value-of select="translate($action-name,'"',' ')"/>");
- listOfLists.add (list);
+ listOfMaps.add (map);
<xsl:apply-templates/>
- listOfLists.remove(list);
+ listOfMaps.remove(map);
}
</xsl:when>
<xsl:otherwise>
- list = <xsl:value-of select="$action-name"/> (environment, objectModel, substitute(listOfLists,<xsl:value-of select="$action-source"/>), <xsl:value-of select="$component-param"/>);
+ map = <xsl:value-of select="$action-name"/> (environment, objectModel, substitute(listOfMaps,<xsl:value-of select="$action-source"/>), <xsl:value-of select="$component-param"/>);
</xsl:otherwise>
</xsl:choose>
</xsl:template> <!-- match="map:act" -->
@@ -617,18 +618,18 @@
<!-- here we make sure the uri-prefix ends with a slash -->
<xsl:choose>
<xsl:when test="substring(@uri-prefix,string-length(@uri-prefix))='/'">
- if(true)return sitemapManager.invoke (environment, substitute(listOfLists,"<xsl:value-of select="@uri-prefix"/>"), substitute(listOfLists,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
+ if(true)return sitemapManager.invoke (environment, substitute(listOfMaps,"<xsl:value-of select="@uri-prefix"/>"), substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
</xsl:when>
<xsl:when test="substring(@uri-prefix,string-length(@uri-prefix))='}'">
- String uri_prefix<xsl:value-of select="count(.)"/>=substitute(listOfLists,"<xsl:value-of select="@uri-prefix"/>");
+ String uri_prefix<xsl:value-of select="count(.)"/>=substitute(listOfMaps,"<xsl:value-of select="@uri-prefix"/>");
if (uri_prefix<xsl:value-of select="count(.)"/>.charAt(uri_prefix<xsl:value-of select="count(.)"/>.length()-1)=='/'){
- if(true)return sitemapManager.invoke (environment, uri_prefix<xsl:value-of select="count(.)"/>, substitute(listOfLists,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
+ if(true)return sitemapManager.invoke (environment, uri_prefix<xsl:value-of select="count(.)"/>, substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
} else {
- return sitemapManager.invoke (environment, uri_prefix<xsl:value-of select="count(.)"/>+"/", substitute(listOfLists,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
+ return sitemapManager.invoke (environment, uri_prefix<xsl:value-of select="count(.)"/>+"/", substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
}
</xsl:when>
<xsl:otherwise>
- if(true)return sitemapManager.invoke (environment, substitute(listOfLists,"<xsl:value-of select="@uri-prefix"/>/"), substitute(listOfLists,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
+ if(true)return sitemapManager.invoke (environment, substitute(listOfMaps,"<xsl:value-of select="@uri-prefix"/>/"), substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of select="$check-reload"/>);
</xsl:otherwise>
</xsl:choose>
</xsl:template> <!-- match="map:mount" -->
@@ -639,13 +640,13 @@
<!-- redirect to a internal resource definition -->
<xsl:when test="@resource">
- if(true)return resource_<xsl:value-of select="translate(@resource, '- ', '__')"/>(pipeline, listOfLists, environment, cocoon_view);
+ if(true)return resource_<xsl:value-of select="translate(@resource, '- ', '__')"/>(pipeline, listOfMaps, environment, cocoon_view);
</xsl:when>
<!-- redirect to a external resource definition. Let the environment do the redirect -->
<xsl:when test="@uri">
log.debug("Redirecting to '<xsl:value-of select="@uri"/>'");
- environment.redirect (substitute(listOfLists, "<xsl:value-of select="@uri"/>"));
+ environment.redirect (substitute(listOfMaps, "<xsl:value-of select="@uri"/>"));
if(true)return true;
</xsl:when>
@@ -662,12 +663,12 @@
<xsl:template match="map:label">
<xsl:apply-templates/>
if ("<xsl:value-of select="@name"/>".equals(cocoon_view))
- return view_<xsl:value-of select="translate(@name, '- ', '__')"/> (pipeline, listOfLists, environment);
+ return view_<xsl:value-of select="translate(@name, '- ', '__')"/> (pipeline, listOfMaps, environment);
</xsl:template> <!-- match="map:label" -->
<!-- collect parameter definitions -->
<xsl:template match="map:pipeline//parameter">
- param.setParameter ("<xsl:value-of select="@name"/>", substitute(listOfLists, "<xsl:value-of select="@value"/>"));
+ param.setParameter ("<xsl:value-of select="@name"/>", substitute(listOfMaps, "<xsl:value-of select="@value"/>"));
</xsl:template>
<!-- FIXME:(GP) is this still valid? -->
@@ -782,7 +783,7 @@
<xsl:for-each select="/map:sitemap/map:views/map:view[@from-position='last']">
if ("<xsl:value-of select="@name"/>".equals(cocoon_view)) {
log.debug("View <xsl:value-of select="@name"/>");
- return view_<xsl:value-of select="translate(@name, '- ', '__')"/> (pipeline, listOfLists, environment);
+ return view_<xsl:value-of select="translate(@name, '- ', '__')"/> (pipeline, listOfMaps, environment);
}
</xsl:for-each>
// performing link translation
@@ -852,12 +853,12 @@
<xsl:when test="$mime-type!=''">
log.debug("Mime-type: <xsl:value-of select="$mime-type"/>");
pipeline.<xsl:value-of select="$method"/> ("<xsl:value-of select="$prefix"/>:<xsl:value-of select="$component-type"/>",
- substitute(listOfLists,"<xsl:value-of select="$component-source"/>"),
+ substitute(listOfMaps,"<xsl:value-of select="$component-source"/>"),
<xsl:value-of select="$component-param"/>,"<xsl:value-of select="$mime-type"/>");
</xsl:when>
<xsl:otherwise>
pipeline.<xsl:value-of select="$method"/> ("<xsl:value-of select="$prefix"/>:<xsl:value-of select="$component-type"/>",
- substitute(listOfLists,"<xsl:value-of select="$component-source"/>"),
+ substitute(listOfMaps,"<xsl:value-of select="$component-source"/>"),
<xsl:value-of select="$component-param"/>);
</xsl:otherwise>
</xsl:choose>
@@ -877,14 +878,14 @@
<xsl:if test="$component-label">
<xsl:for-each select="/map:sitemap/map:views/map:view[@from-label=$component-label]">
if ("<xsl:value-of select="@name"/>".equals(cocoon_view)) {
- return view_<xsl:value-of select="translate(@name, '- ', '__')"/> (pipeline, listOfLists, environment);
+ return view_<xsl:value-of select="translate(@name, '- ', '__')"/> (pipeline, listOfMaps, environment);
}
</xsl:for-each>
</xsl:if>
<xsl:if test="$prefix='generator'">
<xsl:for-each select="/map:sitemap/map:views/map:view[@from-position='first']">
if ("<xsl:value-of select="@name"/>".equals(cocoon_view)) {
- return view_<xsl:value-of select="translate(@name, '- ', '__')"/> (pipeline, listOfLists, environment);
+ return view_<xsl:value-of select="translate(@name, '- ', '__')"/> (pipeline, listOfMaps, environment);
}
</xsl:for-each>
</xsl:if>
No revision
No revision
1.1.2.9 +2 -3 xml-cocoon/src/org/apache/cocoon/matching/Attic/Matcher.java
Index: Matcher.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/Matcher.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- Matcher.java 2000/12/11 16:06:51 1.1.2.8
+++ Matcher.java 2000/12/15 20:35:12 1.1.2.9
@@ -7,7 +7,6 @@
*****************************************************************************/
package org.apache.cocoon.matching;
-import java.util.List;
import java.util.Map;
import org.apache.avalon.Component;
@@ -15,7 +14,7 @@
/**
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.8 $ $Date: 2000/12/11 16:06:51 $
+ * @version CVS $Revision: 1.1.2.9 $ $Date: 2000/12/15 20:35:12 $
*/
public interface Matcher extends Component {
/**
@@ -33,7 +32,7 @@
* contained in the pattern.
* If the return value is null there was no match.
*/
- List match (String pattern, Map objectModel);
+ Map match (String pattern, Map objectModel);
}
1.1.2.4 +4 -4 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.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- RegexpTargetHostMatcherFactory.java 2000/12/08 20:39:48 1.1.2.3
+++ RegexpTargetHostMatcherFactory.java 2000/12/15 20:35:12 1.1.2.4
@@ -25,7 +25,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.3 $ $Date: 2000/12/08 20:39:48 $
+ * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/12/15 20:35:12 $
*/
public class RegexpTargetHostMatcherFactory implements MatcherFactory {
@@ -78,7 +78,7 @@
public String generateMethodSource (NodeIterator conf)
throws ConfigurationException {
StringBuffer sb = new StringBuffer ();
- sb.append("ArrayList list = new ArrayList ();")
+ sb.append("HashMap map = new HashMap ();")
.append("String uri = ((HttpServletRequest)objectModel.get(Cocoon.REQUEST_OBJECT)).getHeader(\"Host\");")
.append("if(uri.startsWith(\"/\")) uri = uri.substring(1);")
.append("if(pattern.match(uri)) {");
@@ -88,9 +88,9 @@
*/
sb.append("int parenCount = pattern.getParenCount();")
.append("for (int paren = 1; paren <= parenCount; paren++) {")
- .append("list.add(pattern.getParen(paren));")
+ .append("map.put(Integer.toString(paren), pattern.getParen(paren));")
.append("}");
- sb.append("return list; } else { return null; }");
+ sb.append("return map; } else { return null; }");
return sb.toString();
}
1.1.2.18 +7 -5 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.17
retrieving revision 1.1.2.18
diff -u -r1.1.2.17 -r1.1.2.18
--- RegexpURIMatcherFactory.java 2000/12/08 20:39:50 1.1.2.17
+++ RegexpURIMatcherFactory.java 2000/12/15 20:35:12 1.1.2.18
@@ -7,6 +7,8 @@
*****************************************************************************/
package org.apache.cocoon.matching;
+import org.apache.cocoon.CodeFactory;
+
import org.apache.regexp.RECompiler;
import org.apache.regexp.REProgram;
import org.apache.regexp.RESyntaxException;
@@ -24,10 +26,10 @@
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.2.17 $ $Date: 2000/12/08 20:39:50 $
+ * @version CVS $Revision: 1.1.2.18 $ $Date: 2000/12/15 20:35:12 $
*/
-public class RegexpURIMatcherFactory implements MatcherFactory {
+public class RegexpURIMatcherFactory implements CodeFactory {
protected Logger log = LogKit.getLoggerFor("cocoon");
public String generateParameterSource (NodeIterator conf)
@@ -93,7 +95,7 @@
public String generateMethodSource (NodeIterator conf)
throws ConfigurationException {
StringBuffer sb = new StringBuffer ();
- sb.append("ArrayList list = new ArrayList ();")
+ sb.append("HashMap map = new HashMap ();")
.append("String uri = ((HttpServletRequest)objectModel.get(Cocoon.REQUEST_OBJECT)).getRequestURI();")
.append("if(uri.startsWith(\"/\")) uri = uri.substring(1);")
.append("if(pattern.match(uri)) {");
@@ -103,10 +105,10 @@
*/
sb.append("int parenCount = pattern.getParenCount();")
.append("for (int paren = 1; paren <= parenCount; paren++) {")
- .append("list.add(pattern.getParen(paren));")
+ .append("map.put(Integer.toString(paren), pattern.getParen(paren));")
.append("}");
- sb.append("return list; } else { return null; }");
+ sb.append("return map; } else { return null; }");
return sb.toString();
}
1.1.2.24 +4 -4 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.23
retrieving revision 1.1.2.24
diff -u -r1.1.2.23 -r1.1.2.24
--- WildcardURIMatcherFactory.java 2000/12/08 20:39:51 1.1.2.23
+++ WildcardURIMatcherFactory.java 2000/12/15 20:35:13 1.1.2.24
@@ -22,7 +22,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 $Revision: 1.1.2.23 $ $Date: 2000/12/08 20:39:51 $
+ * @version CVS $Revision: 1.1.2.24 $ $Date: 2000/12/15 20:35:13 $
*/
public class WildcardURIMatcherFactory implements MatcherFactory {
@@ -55,11 +55,11 @@
*/
public String generateMethodSource (NodeIterator conf)
throws ConfigurationException {
- return "ArrayList list = new ArrayList();" +
+ return "HashMap map = new HashMap();" +
"String uri = ((org.apache.cocoon.environment.http.HttpRequest) 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;" +
+ "if (org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (map, uri, pattern)) {" +
+ "return map;" +
"} else {" +
"return null;}";
}
No revision
No revision
1.1.2.6 +10 -8 xml-cocoon/src/org/apache/cocoon/matching/helpers/Attic/WildcardURIMatcher.java
Index: WildcardURIMatcher.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/helpers/Attic/WildcardURIMatcher.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- WildcardURIMatcher.java 2000/08/31 12:20:17 1.1.2.5
+++ WildcardURIMatcher.java 2000/12/15 20:35:15 1.1.2.6
@@ -8,7 +8,7 @@
package org.apache.cocoon.matching.helpers;
-import java.util.List;
+import java.util.HashMap;
/**
* This class is an utility class that perform wilcard-patterns matching and
@@ -18,7 +18,7 @@
* (Apache Software Foundation, Exoffice Technologies)
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/08/31 12:20:17 $
+ * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/12/15 20:35:15 $
*/
public class WildcardURIMatcher {
@@ -37,10 +37,10 @@
* match a pattern agains a string and isolates wildcard replacement into a
* <code>Stack</code>.
*/
- public static boolean match (List list, String data,
+ public static boolean match (HashMap map, String data,
int[] expr) throws NullPointerException {
- if (list == null)
- throw new NullPointerException ("No list provided");
+ if (map == null)
+ throw new NullPointerException ("No map provided");
if (data == null)
throw new NullPointerException ("No data provided");
if (expr == null)
@@ -62,6 +62,8 @@
int rsltpos = 0;
int offset = -1;
+ // The matching count
+ int mcount = 0;
// First check for MATCH_BEGIN
boolean matchBegin = false;
@@ -104,12 +106,12 @@
// Check for END's
if (exprchr == MATCH_END) {
if (rsltpos > 0)
- list.add (new String(rslt, 0, rsltpos));
+ 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)
- list.add (new String(rslt, 0, rsltpos));
+ map.put (Integer.toString(++mcount),new String(rslt, 0, rsltpos));
// Check that we reach buffer's end
return (buffpos == buff.length);
}
@@ -144,7 +146,7 @@
}
}
- list.add (new String (rslt, 0, rsltpos));
+ map.put(Integer.toString(++mcount),new String (rslt, 0, rsltpos));
rsltpos = 0;
}
}
No revision
No revision
1.1.2.16 +5 -5 xml-cocoon/src/org/apache/cocoon/sitemap/Attic/AbstractSitemap.java
Index: AbstractSitemap.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/AbstractSitemap.java,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -u -r1.1.2.15 -r1.1.2.16
--- AbstractSitemap.java 2000/12/08 20:40:30 1.1.2.15
+++ AbstractSitemap.java 2000/12/15 20:35:16 1.1.2.16
@@ -11,6 +11,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
+import java.util.Map;
import org.apache.avalon.ComponentManager;
import org.apache.avalon.Component;
@@ -34,7 +35,7 @@
* Base class for generated <code>Sitemap</code> classes
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.15 $ $Date: 2000/12/08 20:40:30 $
+ * @version CVS $Revision: 1.1.2.16 $ $Date: 2000/12/15 20:35:16 $
*/
public abstract class AbstractSitemap implements Sitemap {
protected Logger log = LogKit.getLoggerFor("cocoon");
@@ -108,7 +109,7 @@
/**
* Replaces occurences of xpath like expressions in an argument String
- * with content from a List of Lists
+ * with content from a List of Maps
*/
protected String substitute (List list, String expr)
throws PatternException, NumberFormatException {
@@ -137,11 +138,10 @@
for (l = -1; (l = s.indexOf("../",l+1)) != -1; k--);
m = s.lastIndexOf('/');
if (m == -1) {
- n = Integer.parseInt(s) - 1;
+ result.append((String)((Map)list.get(k)).get(s));
} else {
- n = Integer.parseInt(s.substring(m+1)) - 1;
+ result.append((String)((Map)list.get(k)).get(s.substring(m+1)));
}
- result.append((String)((List)list.get(k)).get(n));
}
if (ii < expr.length()) {
result.append(expr.substring(ii));