You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2005/03/11 21:15:53 UTC
svn commit: r157146 - in
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor:
SimpleParentProcessingNode.java sitemap/AggregateNode.java
sitemap/AggregateNodeBuilder.java sitemap/PipelineNodeBuilder.java
Author: vgritsenko
Date: Fri Mar 11 12:15:51 2005
New Revision: 157146
URL: http://svn.apache.org/viewcvs?view=rev&rev=157146
Log:
SimpleParentProcessingNode: fix logic in hasChildren method.
Whitespaces, Javadoc, cleanup.
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/SimpleParentProcessingNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNodeBuilder.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/SimpleParentProcessingNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/SimpleParentProcessingNode.java?view=diff&r1=157145&r2=157146
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/SimpleParentProcessingNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/SimpleParentProcessingNode.java Fri Mar 11 12:15:51 2005
@@ -1,12 +1,12 @@
/*
- * 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,11 +21,9 @@
import org.apache.cocoon.environment.Environment;
/**
- *
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: SimpleParentProcessingNode.java,v 1.3 2004/06/09 11:59:23 cziegeler Exp $
+ * @version $Id$
*/
-
public abstract class SimpleParentProcessingNode extends AbstractParentProcessingNode {
/** The childrens of this matcher */
@@ -40,27 +38,22 @@
}
/**
- * Boolean method with returns true if this Node has children
- * and false otherwise
+ * Boolean method with returns true if this Node has children
+ * and false otherwise.
*
- * @return boolean
+ * @return boolean true if has children.
*/
public boolean hasChildren() {
- if ((this.children == null) || (this.children.length > 0))
- return true;
- return false;
+ return this.children != null && this.children.length > 0;
}
-
/**
* Define common invoke behavior here
*/
public boolean invoke(Environment env, InvokeContext context) throws Exception {
-
-
- // inform the pipeline (if available) that we have come across
+ // Inform the pipeline (if available) that we have come across
// a possible branch point
- if (context.pipelineIsSet() && this.hasChildren() ) {
+ if (context.pipelineIsSet() && hasChildren()) {
context.getProcessingPipeline().informBranchPoint();
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNode.java?view=diff&r1=157145&r2=157146
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNode.java Fri Mar 11 12:15:51 2005
@@ -1,12 +1,12 @@
/*
- * 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,9 +15,8 @@
*/
package org.apache.cocoon.components.treeprocessor.sitemap;
-import java.util.Map;
-
import org.apache.avalon.framework.parameters.Parameters;
+
import org.apache.cocoon.components.pipeline.ProcessingPipeline;
import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode;
import org.apache.cocoon.components.treeprocessor.InvokeContext;
@@ -25,11 +24,13 @@
import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.sitemap.ContentAggregator;
-import org.apache.cocoon.sitemap.PatternException;
+
+import java.util.Map;
/**
+ * Aggregate sitemap node.
*
- * View-handling in aggregation :
+ * <h3>View handling in aggregation</h3>
* <ul>
* <li>map:aggregate can have a label, but doesn't match view from-position="first" like generators
* </li>
@@ -44,9 +45,8 @@
* <a href="http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=100517130418424">here</a>.
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: AggregateNode.java,v 1.5 2004/06/09 11:59:23 cziegeler Exp $
+ * @version $Id$
*/
-
public class AggregateNode extends AbstractProcessingNode {
private VariableResolver element;
@@ -62,7 +62,7 @@
/** View nodes to jump to */
private Map viewNodes;
- public AggregateNode(VariableResolver element, VariableResolver nsURI, VariableResolver nsPrefix) throws PatternException {
+ public AggregateNode(VariableResolver element, VariableResolver nsURI, VariableResolver nsPrefix) {
super(null);
this.element = element;
this.nsURI = nsURI;
@@ -79,23 +79,19 @@
}
public boolean invoke(Environment env, InvokeContext context)
- throws Exception {
-
- boolean infoEnabled = getLogger().isInfoEnabled();
+ throws Exception {
+ final boolean infoEnabled = getLogger().isInfoEnabled();
Map objectModel = env.getObjectModel();
// Setup aggregator
ProcessingPipeline processingPipeline = context.getProcessingPipeline();
-
processingPipeline.setGenerator("<aggregator>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
- ContentAggregator aggregator = (ContentAggregator)processingPipeline.getGenerator();
- aggregator.setRootElement(
- this.element.resolve(context, objectModel),
- this.nsURI.resolve(context, objectModel),
- this.nsPrefix.resolve(context, objectModel)
- );
+ ContentAggregator aggregator = (ContentAggregator) processingPipeline.getGenerator();
+ aggregator.setRootElement(this.element.resolve(context, objectModel),
+ this.nsURI.resolve(context, objectModel),
+ this.nsPrefix.resolve(context, objectModel));
// Get actual parts, potentially filtered by the view
Part[] actualParts;
@@ -129,7 +125,7 @@
}
}
- // Bug #7196 : Some parts matched the view : jump to that view
+ // Bug #7196 : Some parts matched the view: jump to that view
if (actualParts != this.allParts) {
ProcessingNode viewNode = (ProcessingNode)this.viewNodes.get(cocoonView);
if (viewNode != null) {
@@ -156,25 +152,22 @@
}
public static class Part {
- public Part(
- VariableResolver source,
- VariableResolver element,
- VariableResolver nsURI,
- VariableResolver nsPrefix,
- VariableResolver stripRoot)
- throws PatternException {
+ protected VariableResolver source;
+ protected VariableResolver element;
+ protected VariableResolver nsURI;
+ protected VariableResolver nsPrefix;
+ protected VariableResolver stripRoot;
+
+ public Part(VariableResolver source,
+ VariableResolver element,
+ VariableResolver nsURI,
+ VariableResolver nsPrefix,
+ VariableResolver stripRoot) {
this.source = source;
this.element = element;
this.nsURI = nsURI;
this.nsPrefix = nsPrefix;
this.stripRoot = stripRoot;
}
-
- protected VariableResolver source;
- protected VariableResolver element;
- protected VariableResolver nsURI;
- protected VariableResolver nsPrefix;
- protected VariableResolver stripRoot;
-
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNodeBuilder.java?view=diff&r1=157145&r2=157146
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNodeBuilder.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNodeBuilder.java Fri Mar 11 12:15:51 2005
@@ -1,12 +1,12 @@
/*
- * 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,13 +31,11 @@
import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
/**
- *
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: AggregateNodeBuilder.java,v 1.3 2004/03/05 13:02:51 bdelacretaz Exp $
+ * @version $Id$
*/
-
public class AggregateNodeBuilder extends AbstractProcessingNodeBuilder
- implements LinkedProcessingNodeBuilder {
+ implements LinkedProcessingNodeBuilder {
/** The views for the aggregate element */
private Collection views;
@@ -56,21 +54,21 @@
this.treeBuilder.setupNode(this.node, config);
this.views = ((SitemapLanguage)this.treeBuilder).getViewsForStatement("", "", config);
-
+
// Bug #7196 : ensure this.views is never null (see continuation of fix below)
if (this.views == null) {
this.views = new HashSet();
}
-
+
// The sitemap builder
SitemapLanguage sitemap = (SitemapLanguage)this.treeBuilder;
// All parts of the aggregate
List allParts = new ArrayList();
-
+
// For each view that a part matches, the list of all parts that match it
Map viewParts = new HashMap();
-
+
Configuration[] childConfigs = config.getChildren();
for (int i = 0; i < childConfigs.length; i++) {
Configuration childConfig = childConfigs[i];
@@ -90,22 +88,22 @@
VariableResolverFactory.getResolver(childConfig.getAttribute("prefix", ""), this.manager),
VariableResolverFactory.getResolver(childConfig.getAttribute("strip-root", "false"), this.manager)
);
-
+
allParts.add(currentPart);
-
+
// Get the views for this part
Collection viewsForPart = sitemap.getViewsForStatement("", "", childConfig);
-
+
// Associate this part to all the views it belongs to
if (viewsForPart != null) {
-
+
// Bug #7196 : add part view to aggregate views
this.views.addAll(viewsForPart);
-
+
Iterator iter = viewsForPart.iterator();
while(iter.hasNext()) {
String currentView = (String)iter.next();
-
+
// Get collection of parts for current view
Collection currentViewParts = (Collection)viewParts.get(currentView);
if (currentViewParts == null) {
@@ -113,7 +111,7 @@
currentViewParts = new ArrayList();
viewParts.put(currentView, currentViewParts);
}
-
+
// Add the current part to the parts list of the view
currentViewParts.add(currentPart);
}
@@ -128,11 +126,11 @@
// Now convert all Collections to Array for faster traversal
AggregateNode.Part[] allPartsArray = (AggregateNode.Part[])allParts.toArray(
new AggregateNode.Part[allParts.size()]);
-
+
Iterator iter = viewParts.entrySet().iterator();
while(iter.hasNext()) {
Map.Entry entry = (Map.Entry)iter.next();
-
+
// Get collection of parts for this entry
Collection coll = (Collection)entry.getValue();
@@ -152,7 +150,7 @@
// Give the AggregateNode a Node for each view
SitemapLanguage sitemap = (SitemapLanguage)this.treeBuilder;
-
+
this.node.setViewNodes(sitemap.getViewNodes(this.views));
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java?view=diff&r1=157145&r2=157146
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java Fri Mar 11 12:15:51 2005
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,7 +30,7 @@
* Builds a <map:pipeline>
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
* @author <a href="mailto:gianugo@apache.org">Gianugo Rabellino</a>
- * @version CVS $Id: PipelineNodeBuilder.java,v 1.6 2004/07/15 12:49:50 sylvain Exp $
+ * @version CVS $Id$
*/
public class PipelineNodeBuilder
@@ -44,20 +44,21 @@
public ProcessingNode buildNode(Configuration config)
throws Exception {
-
+
String type = this.treeBuilder.getTypeForStatement(config, ProcessingPipeline.ROLE);
PipelineNode node = new PipelineNode(type);
this.treeBuilder.setupNode(node, config);
node.setInternalOnly(config.getAttributeAsBoolean("internal-only", false));
-
+ node.setInternalErrorHandler(config.getAttributeAsBoolean("internal-error-handling", false));
+
// Main (with no "type" attribute) error handler : new in Cocoon 2.1, must have a generator
ProcessingNode mainHandler = null;
-
+
// 404 & 500 error handlers as in Cocoon 2.0.x, have an implicit generator
ProcessingNode error404Handler = null;
ProcessingNode error500Handler = null;
-
+
Configuration[] childConfigs = config.getChildren();
List children = new ArrayList();
for (int i = 0; i < childConfigs.length; i++) {
@@ -82,7 +83,7 @@
mainHandler = handler;
}
break;
-
+
case 404:
if (error404Handler != null) {
throw new ConfigurationException("Duplicate <handle-errors type='404' at " + handler.getLocation());
@@ -93,7 +94,7 @@
error404Handler = handler;
}
break;
-
+
case 500:
if (error500Handler != null) {
throw new ConfigurationException("Duplicate <handle-errors type='500' at " + handler.getLocation());
@@ -104,7 +105,7 @@
error500Handler = handler;
}
break;
-
+
default:
throw new ConfigurationException("Unknown handle-errors type (" + type + ") at " + handler.getLocation());
}