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/09/28 08:46:13 UTC
svn commit: r292136 -
/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java
Author: cziegeler
Date: Tue Sep 27 23:46:06 2005
New Revision: 292136
URL: http://svn.apache.org/viewcvs?rev=292136&view=rev
Log:
Just code formatting
Modified:
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java?rev=292136&r1=292135&r2=292136&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java Tue Sep 27 23:46:06 2005
@@ -1,19 +1,18 @@
/*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.cocoon.components.modules.input;
import org.apache.avalon.framework.configuration.Configurable;
@@ -64,77 +63,101 @@
* </p>
*
*/
-public class ProjectPathModule extends AbstractInputModule implements Configurable, ThreadSafe {
+public class ProjectPathModule
+ extends AbstractInputModule
+ implements Configurable, ThreadSafe {
- protected static String PROJECT_PARAM_NAME = "uri-prefix";
- protected static String PROJECT_PARAM_DEFAULT = "/";
+ protected static String PROJECT_PARAM_NAME = "uri-prefix";
+ protected static String PROJECT_PARAM_DEFAULT = "/";
+
+ protected String projectBase;
- protected String projectBase;
-
final static Vector returnNames;
static {
- Vector tmp = new Vector();
- tmp.add("relative");
- tmp.add("path");
- tmp.add("folder");
- returnNames = tmp;
+ Vector tmp = new Vector();
+ tmp.add("relative");
+ tmp.add("path");
+ tmp.add("folder");
+ returnNames = tmp;
}
+ /**
+ * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ */
public void configure(Configuration conf) throws ConfigurationException {
- this.projectBase = conf.getChild(PROJECT_PARAM_NAME).getValue();
- if (getLogger().isDebugEnabled()) getLogger().debug("Configuration supplied: " + this.projectBase);
- if (this.projectBase == null) {
- this.projectBase = PROJECT_PARAM_DEFAULT;
- if (getLogger().isWarnEnabled()) getLogger().warn("No configuration supplied, using default: " + PROJECT_PARAM_DEFAULT);
- }
- if (this.projectBase.equals("")) {
- this.projectBase = PROJECT_PARAM_DEFAULT;
- if (getLogger().isWarnEnabled()) getLogger().warn("Empty configuration supplied, using default: " + PROJECT_PARAM_DEFAULT);
- }
+ this.projectBase = conf.getChild(PROJECT_PARAM_NAME).getValue();
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Configuration supplied: " + this.projectBase);
+ }
+ if (this.projectBase == null) {
+ this.projectBase = PROJECT_PARAM_DEFAULT;
+ if (getLogger().isWarnEnabled()) {
+ getLogger().warn("No configuration supplied, using default: " + PROJECT_PARAM_DEFAULT);
+ }
+ }
+ if (this.projectBase.equals("")) {
+ this.projectBase = PROJECT_PARAM_DEFAULT;
+ if (getLogger().isWarnEnabled()) {
+ getLogger().warn("Empty configuration supplied, using default: " + PROJECT_PARAM_DEFAULT);
+ }
+ }
}
- public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
- String uri = ObjectModelHelper.getRequest(objectModel).getServletPath();
- StringBuffer result = new StringBuffer(uri.length());
- int baseIndex = uri.indexOf(this.projectBase);
- if (baseIndex != -1) {
- uri = uri.substring(baseIndex + this.projectBase.length());
- } else {
- throw new ConfigurationException( "No project-base path found in URI");
- }
- try {
- // provide a relative path back to the project
- if (name.startsWith("relative")) {
- int nextIndex = 0;
- while ((nextIndex = uri.indexOf('/', nextIndex) + 1) > 0) {
- result.append("../");
- }
- } else if (name.startsWith("path")) { // provide the full path from the project
- result.append("/");
- result.append(uri);
- } else if (name.startsWith("folder")) { // provide the folder path from the project
- result.append("/");
- result.append(uri.substring(0,uri.lastIndexOf("/") + 1));
- } else {
- if (getLogger().isWarnEnabled()) getLogger().warn("Invalid verb: " + name);
- }
- return result;
- } catch( final Exception mue ) {
- throw new ConfigurationException( "Problems resolving project path.", mue);
- }
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+ */
+ public Object getAttribute(String name, Configuration modeConf, Map objectModel)
+ throws ConfigurationException {
+ String uri = ObjectModelHelper.getRequest(objectModel).getServletPath();
+ StringBuffer result = new StringBuffer(uri.length());
+ int baseIndex = uri.indexOf(this.projectBase);
+ if (baseIndex != -1) {
+ uri = uri.substring(baseIndex + this.projectBase.length());
+ } else {
+ throw new ConfigurationException( "No project-base path found in URI");
+ }
+ try {
+ // provide a relative path back to the project
+ if (name.startsWith("relative")) {
+ int nextIndex = 0;
+ while ((nextIndex = uri.indexOf('/', nextIndex) + 1) > 0) {
+ result.append("../");
+ }
+ } else if (name.startsWith("path")) {
+ // provide the full path from the project
+ result.append("/");
+ result.append(uri);
+ } else if (name.startsWith("folder")) {
+ // provide the folder path from the project
+ result.append("/");
+ result.append(uri.substring(0,uri.lastIndexOf("/") + 1));
+ } else {
+ if (getLogger().isWarnEnabled()) {
+ getLogger().warn("Invalid verb: " + name);
+ }
+ }
+ return result;
+ } catch( final Exception mue ) {
+ throw new ConfigurationException( "Problems resolving project path.", mue);
+ }
}
- public Iterator getAttributeNames( Configuration modeConf, Map objectModel ) throws ConfigurationException {
- return ProjectPathModule.returnNames.iterator();
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+ */
+ public Iterator getAttributeNames( Configuration modeConf, Map objectModel )
+ throws ConfigurationException {
+ return ProjectPathModule.returnNames.iterator();
}
-
+ /**
+ * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+ */
public Object[] getAttributeValues( String name, Configuration modeConf, Map objectModel )
- throws ConfigurationException {
-
- List values = new LinkedList();
- values.add( this.getAttribute(name, modeConf, objectModel) );
-
- return values.toArray();
+ throws ConfigurationException {
+ List values = new LinkedList();
+ values.add( this.getAttribute(name, modeConf, objectModel) );
+
+ return values.toArray();
}
}