cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/matching WildcardParameterValueMatcherFactory.java
Date Tue, 18 Sep 2001 14:56:45 GMT
haul        01/09/18 07:56:45

  Modified:    src/org/apache/cocoon/matching Tag: cocoon_20_branch
                        WildcardParameterValueMatcherFactory.java
  Log:
  - changed *SessionState(Matcher|Selector)* to more general *SessionAttribute(Matcher|Selector)*
    updated docs + samples accordingly
  - make some SourceFactories fail in a friendlier way when parameters are missing
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +41 -13    xml-cocoon2/src/org/apache/cocoon/matching/WildcardParameterValueMatcherFactory.java
  
  Index: WildcardParameterValueMatcherFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/WildcardParameterValueMatcherFactory.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- WildcardParameterValueMatcherFactory.java	2001/08/20 14:07:32	1.1.2.3
  +++ WildcardParameterValueMatcherFactory.java	2001/09/18 14:56:45	1.1.2.4
  @@ -26,7 +26,7 @@
    * </table>
    *
    * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2001/08/20 14:07:32 $ */
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2001/09/18 14:56:45 $ */
   
   public class WildcardParameterValueMatcherFactory extends WildcardURIMatcherFactory {
   
  @@ -51,18 +51,46 @@
               }
           }
   
  -	return "HashMap map = new HashMap(1);" +
  -	    "String theParameter = null; " +
  -	    "if (parameters == null) {"+
  -	    "  theParameter = XSPRequestHelper.getParameter(objectModel, \""+parameterName+"\",null);"
+
  -	    " } else { " +
  -	    "  theParameter = XSPRequestHelper.getParameter(objectModel, parameters.getParameter(\"parameter-name\",\""+parameterName+"\"),null);"
+
  -	    " }; " +
  -	    "if (theParameter != null && org.apache.cocoon.matching.helpers.WildcardURIMatcher.match
(map, theParameter, pattern)) {" +
  -	    "map.put(\""+parameterName+"\", theParameter);"+
  -	    "return map;" +
  -	    "} else {" +
  -	    "return null;}";
  +        StringBuffer sb = new StringBuffer();
  +	sb
  +	    .append("HashMap map = new HashMap(1);")
  +	    .append("String parameterName = null;")
  +	    .append("String parameterValue = null;")
  +	    .append("if (parameters.getNames().length == 0) {");
  +	if ( parameterName == null ) {
  +	    sb
  +		.append("   getLogger().warn(\"No request parameter name and no default name given. FAILING\");")
  +		.append("} else { ")
  +		.append("  parameterName = parameters.getParameter(\"parameter-name\", null);")
  +		.append("  if ( parameterName == null ) {")
  +		.append("     getLogger().warn(\"No request parameter name and no default name given.
FAILING\");")
  +		.append("  } else {")
  +		.append("     parameterValue = XSPRequestHelper.getParameter(objectModel, parameterName,
null); ")
  +		.append("  }");
  +	} else {
  +	    sb
  +		.append("  parameterName = \""+parameterName+"\";")
  +		.append("  parameterValue = XSPRequestHelper.getParameter(objectModel, parameterName,
null);")
  +		.append("} else { ")
  +		.append("  parameterName = parameters.getParameter(\"parameter-name\", null);")
  +		.append("  if ( parameterName == null ) {")
  +		.append("     getLogger().warn(\"No request parameter name given, will use default\");")
  +		.append("     parameterName = \""+parameterName+"\";")
  +		.append("  }")
  +		.append("  parameterValue = XSPRequestHelper.getParameter(objectModel, parameterName,
null); ");
  +	}
  +	sb
  +	    .append("}")
  +	    .append("if ( parameterValue == null ) {")
  +	    .append("   getLogger().debug(\"Request parameter not set\");")
  +	    .append("} else {")
  +	    .append("   if (org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (map,
parameterValue, pattern)) {")
  +	    .append("      map.put(parameterName, parameterValue ); ")   
  +	    .append("      return map;")
  +	    .append("   }")
  +	    .append("}")
  +	    .append("return null;");
  +        return sb.toString();
       }
   
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message