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/04/29 11:24:30 UTC
svn commit: r165284 - in /cocoon:
blocks/supported/portal/trunk/java/org/apache/cocoon/environment/portlet/
blocks/unsupported/taglib/trunk/java/org/apache/cocoon/jxpath/
trunk/src/java/org/apache/cocoon/components/source/impl/
trunk/src/java/org/apache/cocoon/components/treeprocessor/
trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/
trunk/src/java/org/apache/cocoon/environment/
trunk/src/java/org/apache/cocoon/environment/commandline/
trunk/src/java/org/apache/cocoon/environment/http/
trunk/src/java/org/apache/cocoon/environment/wrapper/
trunk/src/test/org/apache/cocoon/environment/mock/
Author: cziegeler
Date: Fri Apr 29 02:24:28 2005
New Revision: 165284
URL: http://svn.apache.org/viewcvs?rev=165284&view=rev
Log:
Mostly code formatting
Added searchAttribute method to Request
Removed:
cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/SourceDeferredValidity.java
Modified:
cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/environment/portlet/PortletRequest.java
cocoon/blocks/unsupported/taglib/trunk/java/org/apache/cocoon/jxpath/JXPathCocoonContexts.java
cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNodeBuilder.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/SimpleSelectorProcessingNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActNodeBuilder.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PreparableMatchNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/RedirectToNodeBuilder.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SelectNodeBuilder.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
cocoon/trunk/src/java/org/apache/cocoon/environment/AbstractEnvironment.java
cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java
cocoon/trunk/src/java/org/apache/cocoon/environment/SourceResolver.java
cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java
cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java
cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java
cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java
cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockEnvironment.java
cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java
Modified: cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/environment/portlet/PortletRequest.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/environment/portlet/PortletRequest.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/environment/portlet/PortletRequest.java (original)
+++ cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/environment/portlet/PortletRequest.java Fri Apr 29 02:24:28 2005
@@ -93,23 +93,22 @@
// if the request has been wrapped then access its method
if (request instanceof MultipartActionRequest) {
return ((MultipartActionRequest) request).get(name);
- } else {
- String[] values = request.getParameterValues(name);
- if (values == null) {
- return null;
- }
- if (values.length == 1) {
- return values[0];
- }
- if (values.length > 1) {
- Vector vect = new Vector(values.length);
- for (int i = 0; i < values.length; i++) {
- vect.add(values[i]);
- }
- return vect;
- }
+ }
+ String[] values = request.getParameterValues(name);
+ if (values == null) {
return null;
}
+ if (values.length == 1) {
+ return values[0];
+ }
+ if (values.length > 1) {
+ Vector vect = new Vector(values.length);
+ for (int i = 0; i < values.length; i++) {
+ vect.add(values[i]);
+ }
+ return vect;
+ }
+ return null;
}
/* The Request interface methods */
@@ -529,9 +528,8 @@
public Object getAttribute(String name, int scope) {
if ( scope == Request.REQUEST_SCOPE ) {
return this.attributes.get(name);
- } else {
- return this.request.getAttribute(name);
}
+ return this.request.getAttribute(name);
}
/* (non-Javadoc)
@@ -540,9 +538,8 @@
public Enumeration getAttributeNames(int scope) {
if ( scope == Request.REQUEST_SCOPE ) {
return IteratorUtils.asEnumeration(this.attributes.keySet().iterator());
- } else {
- return this.request.getAttributeNames();
}
+ return this.request.getAttributeNames();
}
/* (non-Javadoc)
@@ -565,6 +562,17 @@
} else {
this.request.removeAttribute(name);
}
+ }
+
+ /**
+ * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
+ */
+ public Object searchAttribute(String name) {
+ Object result = this.getAttribute(name, REQUEST_SCOPE);
+ if ( result == null ) {
+ result = this.getAttribute(name, GLOBAL_SCOPE);
+ }
+ return result;
}
}
Modified: cocoon/blocks/unsupported/taglib/trunk/java/org/apache/cocoon/jxpath/JXPathCocoonContexts.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/taglib/trunk/java/org/apache/cocoon/jxpath/JXPathCocoonContexts.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/blocks/unsupported/taglib/trunk/java/org/apache/cocoon/jxpath/JXPathCocoonContexts.java (original)
+++ cocoon/blocks/unsupported/taglib/trunk/java/org/apache/cocoon/jxpath/JXPathCocoonContexts.java Fri Apr 29 02:24:28 2005
@@ -391,6 +391,13 @@
public void setAttribute(String name, Object o, int scope) {
this.delegate.setAttribute(name, o, scope);
}
+
+ /**
+ * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
+ */
+ public Object searchAttribute(String name) {
+ return this.delegate.searchAttribute(name);
+ }
}
public class SessionProxy implements Session {
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java Fri Apr 29 02:24:28 2005
@@ -432,11 +432,11 @@
private SourceValidity validity;
- private SitemapSourceValidity() {
+ protected SitemapSourceValidity() {
super();
}
- private void set(SourceValidity validity) {
+ protected void set(SourceValidity validity) {
this.validity = validity;
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNode.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNode.java Fri Apr 29 02:24:28 2005
@@ -31,6 +31,7 @@
}
public AbstractParentProcessingNode() {
+ this(null);
}
/**
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNodeBuilder.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNodeBuilder.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNodeBuilder.java Fri Apr 29 02:24:28 2005
@@ -94,10 +94,9 @@
if (name.equals("parameter")) {
if (this.hasParameters()) {
return true;
- } else {
- String msg = "Element '" + name + "' has no parameters at " + config.getLocation();
- throw new ConfigurationException(msg);
}
+ String msg = "Element '" + name + "' has no parameters at " + config.getLocation();
+ throw new ConfigurationException(msg);
}
return false;
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNode.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNode.java Fri Apr 29 02:24:28 2005
@@ -22,7 +22,7 @@
/**
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: AbstractProcessingNode.java,v 1.5 2004/06/09 11:59:23 cziegeler Exp $
+ * @version CVS $Id$
*/
public abstract class AbstractProcessingNode
@@ -42,6 +42,7 @@
}
public AbstractProcessingNode() {
+ this(null);
}
/**
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java Fri Apr 29 02:24:28 2005
@@ -144,9 +144,16 @@
}
}
+ /**
+ * @see org.apache.commons.jci.monitor.FilesystemAlterationListener#onStart()
+ */
public void onStart() {
+ // nothing to do
}
+ /**
+ * @see org.apache.commons.jci.monitor.FilesystemAlterationListener#onStop()
+ */
public void onStop() {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Now tracking classpath changes");
@@ -279,9 +286,8 @@
try {
if (process(environment, context)) {
return context.getInternalPipelineDescription(environment);
- } else {
- return null;
}
+ return null;
} finally {
context.dispose();
}
@@ -308,7 +314,8 @@
try {
// invoke listeners
- if ( this.enterSitemapEventListeners.size() > 0 ) {
+ // only invoke if pipeline is not internally
+ if ( !context.isBuildingPipelineOnly() && this.enterSitemapEventListeners.size() > 0 ) {
final EnterSitemapEvent enterEvent = new EnterSitemapEvent(this, environment);
final Iterator enterSEI = this.enterSitemapEventListeners.iterator();
while ( enterSEI.hasNext() ) {
@@ -339,7 +346,8 @@
} finally {
// invoke listeners
- if ( this.leaveSitemapEventListeners.size() > 0 ) {
+ // only invoke if pipeline is not internally
+ if ( !context.isBuildingPipelineOnly() && this.leaveSitemapEventListeners.size() > 0 ) {
final LeaveSitemapEvent leaveEvent = new LeaveSitemapEvent(this, environment);
final Iterator leaveSEI = this.leaveSitemapEventListeners.iterator();
while ( leaveSEI.hasNext() ) {
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java Fri Apr 29 02:24:28 2005
@@ -291,9 +291,8 @@
public ProcessingNode getRegisteredNode(String name) {
if (this.canGetNode) {
return (ProcessingNode)this.registeredNodes.get(name);
- } else {
- throw new IllegalArgumentException("Categories are only available during buildNode()");
}
+ throw new IllegalArgumentException("Categories are only available during buildNode()");
}
public ProcessingNodeBuilder createNodeBuilder(Configuration config) throws Exception {
@@ -312,11 +311,10 @@
if (this.itsBuilders.isSelectable(nodeName)) {
// No : rethrow
throw ce;
- } else {
- // Throw a more meaningful exception
- String msg = "Unknown element '" + nodeName + "' at " + config.getLocation();
- throw new ConfigurationException(msg);
}
+ // Throw a more meaningful exception
+ String msg = "Unknown element '" + nodeName + "' at " + config.getLocation();
+ throw new ConfigurationException(msg);
}
builder.setBuilder(this);
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/SimpleSelectorProcessingNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/SimpleSelectorProcessingNode.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/SimpleSelectorProcessingNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/SimpleSelectorProcessingNode.java Fri Apr 29 02:24:28 2005
@@ -26,7 +26,7 @@
* Base class for processing nodes that are based on a component in a Selector (act, match, select, etc).
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: SimpleSelectorProcessingNode.java,v 1.6 2004/07/16 12:36:45 sylvain Exp $
+ * @version CVS $Id$
*/
public abstract class SimpleSelectorProcessingNode extends SimpleParentProcessingNode
@@ -72,9 +72,8 @@
protected Object getComponent() throws ServiceException {
if (this.threadSafeComponent != null) {
return this.threadSafeComponent;
- } else {
- return this.selector.select(this.componentName);
}
+ return this.selector.select(this.componentName);
}
/**
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActNodeBuilder.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActNodeBuilder.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActNodeBuilder.java Fri Apr 29 02:24:28 2005
@@ -28,7 +28,7 @@
/**
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: ActNodeBuilder.java,v 1.6 2004/07/15 12:49:50 sylvain Exp $
+ * @version CVS $Id$
*/
public class ActNodeBuilder extends AbstractParentProcessingNodeBuilder
implements LinkedProcessingNodeBuilder {
@@ -72,23 +72,22 @@
return actTypeNode;
- } else {
+ }
- if (inActionSet) {
- throw new ConfigurationException("Cannot call an action set from an action set at " + config.getLocation());
- }
+ if (inActionSet) {
+ throw new ConfigurationException("Cannot call an action set from an action set at " + config.getLocation());
+ }
- // Action set call
- if (config.getAttribute("src", null) != null) {
- getLogger().warn("The 'src' attribute is ignored for action-set call at " + config.getLocation());
- }
- this.actSetNode = new ActSetNode();
- this.treeBuilder.setupNode(this.actSetNode, config);
+ // Action set call
+ if (config.getAttribute("src", null) != null) {
+ getLogger().warn("The 'src' attribute is ignored for action-set call at " + config.getLocation());
+ }
+ this.actSetNode = new ActSetNode();
+ this.treeBuilder.setupNode(this.actSetNode, config);
- this.actSetNode.setChildren(buildChildNodes(config));
+ this.actSetNode.setChildren(buildChildNodes(config));
- return this.actSetNode;
- }
+ return this.actSetNode;
}
public void linkNode() throws Exception {
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java Fri Apr 29 02:24:28 2005
@@ -102,25 +102,24 @@
throw e;
}
- } else {
- // A 'type' attribute is present : add the implicit generator
- context.getProcessingPipeline().setGenerator("<notifier>", "", Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
+ }
+ // A 'type' attribute is present : add the implicit generator
+ context.getProcessingPipeline().setGenerator("<notifier>", "", Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
- try {
- return invokeNodes(this.children, env, context);
- } catch (ProcessingException e) {
- if (e.getMessage().indexOf("Generator already set") != -1){
+ try {
+ return invokeNodes(this.children, env, context);
+ } catch (ProcessingException e) {
+ if (e.getMessage().indexOf("Generator already set") != -1){
- env.getObjectModel().remove(Constants.NOTIFYING_OBJECT);
- throw new ProcessingException(
- "Error: 'handle-error' with a 'type' attribute has an implicit generator, at " +
- getLocation() + System.getProperty("line.separator") +
- "Please remove the 'type' attribute on 'handle-error'");
- }
-
- // Rethrow the exception
- throw e;
+ env.getObjectModel().remove(Constants.NOTIFYING_OBJECT);
+ throw new ProcessingException(
+ "Error: 'handle-error' with a 'type' attribute has an implicit generator, at " +
+ getLocation() + System.getProperty("line.separator") +
+ "Please remove the 'type' attribute on 'handle-error'");
}
+
+ // Rethrow the exception
+ throw e;
}
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java Fri Apr 29 02:24:28 2005
@@ -29,7 +29,7 @@
/**
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: MatchNode.java,v 1.6 2004/07/16 12:36:45 sylvain Exp $
+ * @version CVS $Id$
*/
public class MatchNode extends SimpleSelectorProcessingNode
@@ -85,9 +85,8 @@
// Invoke children with the matcher results
return this.invokeNodes(children, env, context, name, result);
- } else {
- // Matcher failed
- return false;
}
+ // Matcher failed
+ return false;
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java Fri Apr 29 02:24:28 2005
@@ -104,13 +104,11 @@
if (pp != null) {
context.setInternalPipelineDescription(pp);
return true;
- } else {
- return false;
}
- } else {
- // Processor will create its own pipelines
- return processor.process(env);
+ return false;
}
+ // Processor will create its own pipelines
+ return processor.process(env);
} finally {
// Restore context
env.setURI(oldPrefix, oldURI);
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PreparableMatchNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PreparableMatchNode.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PreparableMatchNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PreparableMatchNode.java Fri Apr 29 02:24:28 2005
@@ -111,9 +111,8 @@
// Invoke children with the matcher results
return this.invokeNodes(children, env, context, name, result);
- } else {
- // Matcher failed
- return false;
}
+ // Matcher failed
+ return false;
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNode.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNode.java Fri Apr 29 02:24:28 2005
@@ -28,7 +28,7 @@
/**
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: ReadNode.java,v 1.4 2004/07/14 13:17:45 cziegeler Exp $
+ * @version CVS $Id$
*/
public class ReadNode extends AbstractProcessingNode implements ParameterizableProcessingNode {
@@ -95,9 +95,8 @@
// Process pipeline
return pipeline.process(env);
- } else {
- // Return true : pipeline is finished.
- return true;
}
+ // Return true : pipeline is finished.
+ return true;
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/RedirectToNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/RedirectToNodeBuilder.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/RedirectToNodeBuilder.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/RedirectToNodeBuilder.java Fri Apr 29 02:24:28 2005
@@ -30,7 +30,7 @@
/**
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: RedirectToNodeBuilder.java,v 1.7 2004/07/15 12:49:50 sylvain Exp $
+ * @version CVS $Id$
*/
public class RedirectToNodeBuilder extends AbstractProcessingNodeBuilder
@@ -69,16 +69,14 @@
}
return this.callNode;
- } else {
- ProcessingNode URINode = new RedirectToURINode(
- VariableResolverFactory.getResolver(config.getAttribute("uri"), this.manager),
- config.getAttributeAsBoolean("session", false),
- config.getAttributeAsBoolean("global", false),
- config.getAttributeAsBoolean("permanent", false)
- );
- return this.treeBuilder.setupNode(URINode, config);
-
}
+ ProcessingNode URINode = new RedirectToURINode(
+ VariableResolverFactory.getResolver(config.getAttribute("uri"), this.manager),
+ config.getAttributeAsBoolean("session", false),
+ config.getAttributeAsBoolean("global", false),
+ config.getAttributeAsBoolean("permanent", false)
+ );
+ return this.treeBuilder.setupNode(URINode, config);
}
public void linkNode() throws Exception {
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SelectNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SelectNodeBuilder.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SelectNodeBuilder.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SelectNodeBuilder.java Fri Apr 29 02:24:28 2005
@@ -31,7 +31,7 @@
/**
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: SelectNodeBuilder.java,v 1.4 2004/07/16 12:36:45 sylvain Exp $
+ * @version CVS $Id$
*/
public class SelectNodeBuilder extends AbstractParentProcessingNodeBuilder {
@@ -106,11 +106,10 @@
this.treeBuilder.setupNode(node, config);
node.setCases(whenChildrenNodes, whenResolvers, otherwiseNodes);
return node;
- } else {
- SelectNode node = new SelectNode(type);
- this.treeBuilder.setupNode(node, config);
- node.setCases(whenChildrenNodes, whenResolvers, otherwiseNodes);
- return node;
}
+ SelectNode node = new SelectNode(type);
+ this.treeBuilder.setupNode(node, config);
+ node.setCases(whenChildrenNodes, whenResolvers, otherwiseNodes);
+ return node;
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java Fri Apr 29 02:24:28 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.
@@ -32,7 +32,7 @@
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
* @author <a href="mailto:uv@upaya.co.uk">Upayavira</a>
- * @version CVS $Id: SerializeNode.java,v 1.9 2004/07/14 13:17:45 cziegeler Exp $
+ * @version CVS $Id$
*/
public class SerializeNode extends PipelineEventComponentProcessingNode implements ParameterizableProcessingNode {
@@ -133,9 +133,8 @@
// Process pipeline
return pipeline.process(env);
- } else {
- // Return true : pipeline is finished.
- return true;
}
+ // Return true : pipeline is finished.
+ return true;
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java Fri Apr 29 02:24:28 2005
@@ -173,14 +173,13 @@
final String role = config.getAttribute("role", null);
if ( role != null ) {
return new TreeBuilder.EventComponent(manager.lookup(role), true);
- } else {
- final String className = config.getAttribute("class");
- final Object component = ClassUtils.newInstance(className);
+ }
+ final String className = config.getAttribute("class");
+ final Object component = ClassUtils.newInstance(className);
- LifecycleHelper.setupComponent(component, this.getLogger(), context, manager, config);
+ LifecycleHelper.setupComponent(component, this.getLogger(), context, manager, config);
- return new TreeBuilder.EventComponent(component, false);
- }
+ return new TreeBuilder.EventComponent(component, false);
}
/**
Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/AbstractEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/AbstractEnvironment.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/AbstractEnvironment.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/AbstractEnvironment.java Fri Apr 29 02:24:28 2005
@@ -32,7 +32,7 @@
* @author <a href="mailto:bluetkemeier@s-und-n.de">Björn Lütkemeier</a>
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: AbstractEnvironment.java,v 1.24 2004/06/25 15:36:38 cziegeler Exp $
+ * @version CVS $Id$
*/
public abstract class AbstractEnvironment
extends AbstractLogEnabled
@@ -115,19 +115,17 @@
if (action != null) {
/* TC: still support the deprecated syntax */
return action;
- } else {
- for(Enumeration e = req.getParameterNames(); e.hasMoreElements(); ) {
- String name = (String)e.nextElement();
- if (name.startsWith(Constants.ACTION_PARAM_PREFIX)) {
- if (name.endsWith(".x") || name.endsWith(".y")) {
- return name.substring(Constants.ACTION_PARAM_PREFIX.length(),name.length()-2);
- } else {
- return name.substring(Constants.ACTION_PARAM_PREFIX.length());
- }
+ }
+ for(Enumeration e = req.getParameterNames(); e.hasMoreElements(); ) {
+ String name = (String)e.nextElement();
+ if (name.startsWith(Constants.ACTION_PARAM_PREFIX)) {
+ if (name.endsWith(".x") || name.endsWith(".y")) {
+ return name.substring(Constants.ACTION_PARAM_PREFIX.length(),name.length()-2);
}
+ return name.substring(Constants.ACTION_PARAM_PREFIX.length());
}
- return null;
}
+ return null;
}
/* (non-Javadoc)
Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java Fri Apr 29 02:24:28 2005
@@ -167,6 +167,23 @@
Object getAttribute(String name, int scope);
/**
+ * Returns the value of the named attribute searching both scopes
+ * as an <code>Object</code>, or <code>null</code> if no attribute
+ * of the given name exists. This method first searches in the
+ * request scope and then, if no object is found, in the global scope.
+ *
+ * @param name a <code>String</code> specifying the name of
+ * the attribute
+ *
+ * @return an <code>Object</code> containing the value
+ * of the attribute, or <code>null</code> if
+ * the attribute does not exist
+ *
+ * @since 2.2
+ */
+ Object searchAttribute(String name);
+
+ /**
* Returns an <code>Enumeration</code> containing the
* names of the attributes available to this request in the scope.
* This method returns an empty <code>Enumeration</code>
Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/SourceResolver.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/SourceResolver.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/SourceResolver.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/SourceResolver.java Fri Apr 29 02:24:28 2005
@@ -22,11 +22,12 @@
* used for Cocoon sitemap components.
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: SourceResolver.java,v 1.4 2004/05/24 11:26:39 cziegeler Exp $
+ * @version CVS $Id$
*/
public interface SourceResolver
extends org.apache.excalibur.source.SourceResolver {
+ // no methods to add
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java Fri Apr 29 02:24:28 2005
@@ -183,9 +183,8 @@
public OutputStream getOutputStream(int bufferSize) throws IOException {
if (this.outputStream == null) {
return null;
- } else {
- return super.getOutputStream(bufferSize);
}
+ return super.getOutputStream(bufferSize);
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java Fri Apr 29 02:24:28 2005
@@ -182,9 +182,8 @@
public Object getAttribute(String name, int scope) {
if ( scope == Request.REQUEST_SCOPE ) {
return this.attributes.get(name);
- } else {
- return this.globalAttributes.get(name);
}
+ return this.globalAttributes.get(name);
}
/* (non-Javadoc)
@@ -193,9 +192,8 @@
public Enumeration getAttributeNames(int scope) {
if ( scope == Request.REQUEST_SCOPE ) {
return IteratorUtils.asEnumeration(this.attributes.keySet().iterator());
- } else {
- return IteratorUtils.asEnumeration(this.globalAttributes.keySet().iterator());
}
+ return IteratorUtils.asEnumeration(this.globalAttributes.keySet().iterator());
}
/* (non-Javadoc)
@@ -247,9 +245,8 @@
final Object value = this.parameters.get(name);
if (value instanceof String) {
return new String[] { (String)value };
- } else {
- return (String[]) value;
}
+ return (String[]) value;
}
public String getHeader(String name) {
@@ -275,9 +272,8 @@
public Enumeration getHeaderNames() {
if (headers != null) {
return IteratorUtils.asEnumeration(headers.keySet().iterator());
- } else {
- return new EmptyEnumeration();
}
+ return new EmptyEnumeration();
}
public String getCharacterEncoding() { return characterEncoding; }
@@ -426,5 +422,16 @@
public InputStream getInputStream() throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
+
+ /**
+ * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
+ */
+ public Object searchAttribute(String name) {
+ Object result = this.getAttribute(name, REQUEST_SCOPE);
+ if ( result == null ) {
+ result = this.getAttribute(name, GLOBAL_SCOPE);
+ }
+ return result;
+ }
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java Fri Apr 29 02:24:28 2005
@@ -56,12 +56,12 @@
/** The default form encoding of the servlet container */
private String container_encoding;
-
+
/** The current session */
private HttpSession session;
-
+
private final Map attributes = new HashMap();
-
+
/**
* Creates a HttpRequest based on a real HttpServletRequest object
*/
@@ -78,21 +78,20 @@
// if the request has been wrapped then access its method
if (req instanceof MultipartHttpServletRequest) {
return ((MultipartHttpServletRequest) req).get(name);
- } else {
- String[] values = req.getParameterValues(name);
- if (values == null) {
- return null;
- }
- if (values.length == 1) {
- return values[0];
- }
- if (values.length > 1) {
- Vector vect = new Vector(values.length);
- for (int i = 0; i < values.length; i++) {
- vect.add(values[i]);
- }
- return vect;
+ }
+ String[] values = req.getParameterValues(name);
+ if (values == null) {
+ return null;
+ }
+ if (values.length == 1) {
+ return values[0];
+ }
+ if (values.length > 1) {
+ Vector vect = new Vector(values.length);
+ for (int i = 0; i < values.length; i++) {
+ vect.add(values[i]);
}
+ return vect;
}
return null;
}
@@ -282,7 +281,7 @@
public Object getAttribute(String name) {
return this.getAttribute(name, Request.GLOBAL_SCOPE);
}
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.environment.Request#getAttributeNames()
*/
@@ -296,7 +295,7 @@
public void setAttribute(String name, Object value) {
this.setAttribute(name, value, Request.GLOBAL_SCOPE);
}
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String)
*/
@@ -310,22 +309,20 @@
public Object getAttribute(String name, int scope) {
if ( scope == Request.REQUEST_SCOPE ) {
return this.attributes.get(name);
- } else {
- return this.req.getAttribute(name);
}
+ return this.req.getAttribute(name);
}
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.environment.Request#getAttributeNames(int)
*/
public Enumeration getAttributeNames(int scope) {
if ( scope == Request.REQUEST_SCOPE ) {
return IteratorUtils.asEnumeration(this.attributes.keySet().iterator());
- } else {
- return this.req.getAttributeNames();
}
+ return this.req.getAttributeNames();
}
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object, int)
*/
@@ -336,7 +333,7 @@
this.req.setAttribute(name, value);
}
}
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String, int)
*/
@@ -351,9 +348,8 @@
public String getCharacterEncoding() {
if (this.form_encoding == null) {
return this.req.getCharacterEncoding();
- } else {
- return this.form_encoding;
}
+ return this.form_encoding;
}
public void setCharacterEncoding(String form_encoding)
@@ -467,5 +463,16 @@
*/
public String getRealPath(String path) {
return this.req.getRealPath(path);
+ }
+
+ /**
+ * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
+ */
+ public Object searchAttribute(String name) {
+ Object result = this.getAttribute(name, REQUEST_SCOPE);
+ if ( result == null ) {
+ result = this.getAttribute(name, GLOBAL_SCOPE);
+ }
+ return result;
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java Fri Apr 29 02:24:28 2005
@@ -157,9 +157,8 @@
&& os instanceof BufferedOutputStream) {
((BufferedOutputStream)os).clearBuffer();
return true;
- } else {
- return super.tryResetResponse();
}
+ return super.tryResetResponse();
}
/* (non-Javadoc)
Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java Fri Apr 29 02:24:28 2005
@@ -93,9 +93,8 @@
String value = this.parameters.getParameter(name);
if (value == null && !this.rawMode) {
return this.req.getParameter(name);
- } else {
- return value;
}
+ return value;
}
/* (non-Javadoc)
@@ -114,9 +113,8 @@
parameterNames.add(names.nextElement());
}
return new EnumerationFromIterator(parameterNames.iterator());
- } else {
- return this.parameters.getParameterNames();
}
+ return this.parameters.getParameterNames();
}
final class EnumerationFromIterator implements Enumeration {
@@ -144,9 +142,8 @@
System.arraycopy(values, 0, allValues, 0, values.length);
System.arraycopy(inherited, 0, allValues, values.length, inherited.length);
return allValues;
- } else {
- return this.parameters.getParameterValues(name);
}
+ return this.parameters.getParameterValues(name);
}
/* (non-Javadoc)
@@ -191,9 +188,8 @@
public Object getAttribute(String name, int scope) {
if ( scope == Request.GLOBAL_SCOPE ) {
return super.getAttribute(name, scope);
- } else {
- return this.requestAttributes.get( name );
}
+ return this.requestAttributes.get( name );
}
/* (non-Javadoc)
@@ -202,9 +198,8 @@
public Enumeration getAttributeNames(int scope) {
if ( scope == Request.GLOBAL_SCOPE ) {
return super.getAttributeNames(scope);
- } else {
- return IteratorUtils.asEnumeration(this.requestAttributes.keySet().iterator());
}
+ return IteratorUtils.asEnumeration(this.requestAttributes.keySet().iterator());
}
/* (non-Javadoc)
@@ -229,4 +224,17 @@
}
}
+ /**
+ * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
+ */
+ public Object searchAttribute(String name) {
+ Object result = this.getAttribute(name, REQUEST_SCOPE);
+ if ( result == null ) {
+ result = this.getAttribute(name, GLOBAL_SCOPE);
+ if ( result == null ) {
+ result = this.req.getAttribute(name, REQUEST_SCOPE);
+ }
+ }
+ return result;
+ }
}
Modified: cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockEnvironment.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockEnvironment.java (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockEnvironment.java Fri Apr 29 02:24:28 2005
@@ -38,6 +38,7 @@
private Hashtable attributes = new Hashtable();
public MockEnvironment() {
+ // empty constructor
}
public String getURI() {
@@ -111,6 +112,7 @@
}
public void setResponseIsNotModified() {
+ // nothing to do
}
public void setAttribute(String name, Object value) {
Modified: cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java?rev=165284&r1=165283&r2=165284&view=diff
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java Fri Apr 29 02:24:28 2005
@@ -102,56 +102,54 @@
public String getCharacterEncoding() {
return charEncoding;
}
-
+
public void setCharacterEncoding(String enc) throws java.io.UnsupportedEncodingException {
charEncoding = enc;
}
-
+
public int getContentLength() {
return -1;
}
-
+
public String getContentType() {
return contentType;
}
-
+
public String getParameter(String name) {
return (String)parameters.get(name);
}
-
+
public Enumeration getParameterNames() {
return parameters.keys();
}
-
+
public String[] getParameterValues(String name) {
Object param = parameters.get(name);
- if( null == param )
+ if ( null == param ) {
return null;
- else {
- if (param.getClass().isArray()) {
- return (String[]) param;
- } else {
- return new String[] {(String) param};
- }
}
+ if (param.getClass().isArray()) {
+ return (String[]) param;
+ }
+ return new String[] {(String) param};
}
-
+
public void addParameter(String name, String value) {
parameters.put(name, value);
}
-
+
public String getProtocol() {
return protocol;
}
-
+
public String getScheme() {
return scheme;
}
-
+
public String getServerName() {
return serverName;
}
-
+
public int getServerPort() {
return port;
}
@@ -173,26 +171,24 @@
}
public boolean isSecure() {
- if(scheme==null){
+ if (scheme==null) {
return false;
- } else{
- return scheme.equalsIgnoreCase("HTTPS");
}
+ return scheme.equalsIgnoreCase("HTTPS");
}
public Cookie[] getCookies() {
- if (cookies.isEmpty())
+ if (cookies.isEmpty()) {
return null;
- else {
- Cookie[] cookieArray = new Cookie[cookies.size()];
- return (Cookie []) cookies.values().toArray(cookieArray);
}
+ Cookie[] cookieArray = new Cookie[cookies.size()];
+ return (Cookie []) cookies.values().toArray(cookieArray);
}
-
+
public Map getCookieMap() {
return cookies;
}
-
+
public long getDateHeader(String name) {
String s1 = getHeader(name);
if (s1 == null) {
@@ -206,11 +202,11 @@
throw new IllegalArgumentException("Cannot parse date: " + s1);
}
}
-
+
public String getHeader(String name) {
return (String) headers.get(name);
}
-
+
public Enumeration getHeaders(String name) {
throw new AssertionFailedError("Not implemented");
}
@@ -264,10 +260,10 @@
}
public String getRequestURI() {
- if (this.environment == null)
+ if (this.environment == null) {
return requestURI;
- else
- return this.environment.getURI();
+ }
+ return this.environment.getURI();
}
public void setRequestURI(String uri) {
@@ -275,23 +271,23 @@
}
public String getSitemapURI() {
- if (this.environment == null)
+ if (this.environment == null) {
return requestURI;
- else
- return this.environment.getURI();
+ }
+ return this.environment.getURI();
}
public String getSitemapPath() {
- if (this.environment == null)
+ if (this.environment == null) {
return "";
- else
- return this.environment.getURIPrefix();
+ }
+ return this.environment.getURIPrefix();
}
public String getServletPath() {
return servletPath;
}
-
+
public Session getSession(boolean create) {
if ((session == null) && (create)) {
this.session = new MockSession();
@@ -300,15 +296,14 @@
}
if ((session != null) && ((session).isValid())) {
return this.session;
- } else {
- return null;
}
+ return null;
}
-
+
public Session getSession() {
return getSession(true);
}
-
+
public boolean isRequestedSessionIdValid() {
if (session != null) {
try {
@@ -317,16 +312,18 @@
} catch (IllegalStateException e) {
return false;
}
- } else
- return false;
+ }
+ return false;
}
-
+
public boolean isRequestedSessionIdFromCookie() {
return isRequestedSessionIdFromCookie;
}
+
public boolean isRequestedSessionIdFromURL() {
return isRequestedSessionIdFromURL;
}
+
public void reset() {
attributes.clear();
globalAttributes.clear();
@@ -409,9 +406,8 @@
public Object getAttribute(String name, int scope) {
if ( scope == Request.REQUEST_SCOPE ) {
return this.attributes.get(name);
- } else {
- return this.globalAttributes.get(name);
}
+ return this.globalAttributes.get(name);
}
/* (non-Javadoc)
@@ -420,9 +416,8 @@
public Enumeration getAttributeNames(int scope) {
if ( scope == Request.REQUEST_SCOPE ) {
return this.attributes.keys();
- } else {
- return this.globalAttributes.keys();
}
+ return this.globalAttributes.keys();
}
/* (non-Javadoc)
@@ -447,14 +442,26 @@
}
}
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#getInputStream()
- */
- public InputStream getInputStream() throws IOException, UnsupportedOperationException {
- return this.inputStream;
- }
+ /* (non-Javadoc)
+ * @see org.apache.cocoon.environment.Request#getInputStream()
+ */
+ public InputStream getInputStream() throws IOException, UnsupportedOperationException {
+ return this.inputStream;
+ }
public void setInputStream(InputStream is) {
- this.inputStream = is;
+ this.inputStream = is;
}
+
+ /**
+ * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
+ */
+ public Object searchAttribute(String name) {
+ Object result = this.getAttribute(name, REQUEST_SCOPE);
+ if ( result == null ) {
+ result = this.getAttribute(name, GLOBAL_SCOPE);
+ }
+ return result;
+ }
+
}