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 2003/08/12 08:01:40 UTC

cvs commit: cocoon-2.1/src/java/org/apache/cocoon/selection XPathExceptionSelector.java

cziegeler    2003/08/11 23:01:40

  Modified:    src/java/org/apache/cocoon/selection
                        XPathExceptionSelector.java
  Log:
  Applying patch for reserving the order from Volker Schmitt.
  
  Revision  Changes    Path
  1.6       +13 -14    cocoon-2.1/src/java/org/apache/cocoon/selection/XPathExceptionSelector.java
  
  Index: XPathExceptionSelector.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/selection/XPathExceptionSelector.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XPathExceptionSelector.java	10 Jul 2003 13:16:55 -0000	1.5
  +++ XPathExceptionSelector.java	12 Aug 2003 06:01:40 -0000	1.6
  @@ -53,12 +53,12 @@
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Map;
  -import java.util.Map.Entry;
   
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.commons.collections.SequencedHashMap;
   import org.apache.commons.jxpath.CompiledExpression;
   import org.apache.commons.jxpath.JXPathContext;
   
  @@ -100,20 +100,20 @@
           Configuration[] children = conf.getChildren("exception");
           Configuration[] xPathChildren;
   
  -        for (int i = 0; i<children.length; i++) {
  +        for (int i = 0; i < children.length; i++) {
               // Check if there are XPath-Expressions configured
               xPathChildren = children[i].getChildren("xpath");
  -            Map xPathMap = new HashMap();
  +            Map xPathMap = new SequencedHashMap(11);
   
  -            for (int j = 0; j<xPathChildren.length; j++) {
  +            for (int j = 0; j < xPathChildren.length; j++) {
                   Configuration xPathChild = xPathChildren[j];
   
                   String xPathName = xPathChild.getAttribute("name");
                   CompiledExpression xPath = JXPathContext.compile(xPathChild.getAttribute("test"));
   
  -                xPathMap.put(xPath, xPathName);
  +                xPathMap.put(xPathName, xPath);
               }
  -            if (xPathMap.size()>0) {
  +            if (xPathMap.size() > 0) {
                   // store xpath - config if there is some
                   exception2XPath.put(children[i].getAttribute("name", null),
                                       xPathMap);
  @@ -130,23 +130,22 @@
           FindResult selectorContext = (FindResult) super.getSelectorContext(objectModel,
                                            parameters);
   
  -        if (selectorContext!=null) {
  +        if (selectorContext != null) {
               String exceptionName = selectorContext.getName();
               Throwable t = selectorContext.getThrowable();
   
               Map xPathMap = (Map) exception2XPath.get(exceptionName);
   
  -            if (xPathMap!=null) {
  +            if (xPathMap != null) {
                   // create a context for the thrown exception
                   JXPathContext context = JXPathContext.newContext(t);
   
  -                for (Iterator iterator = xPathMap.entrySet().iterator();
  -                    iterator.hasNext(); ) {
  -                    Entry entry = (Entry) iterator.next();
  +                for (Iterator iterator = xPathMap.entrySet().iterator(); iterator.hasNext(); ) {
  +                    Map.Entry entry = (Map.Entry) iterator.next();
   
  -                    if (((CompiledExpression) entry.getKey()).getValue(context).equals(Boolean.TRUE)) {
  +                    if (((CompiledExpression) entry.getValue()).getValue(context).equals(Boolean.TRUE)) {
                           // set the configured name if the expression is succesfull
  -                        selectorContext.setName((String) entry.getValue());
  +                        selectorContext.setName((String) entry.getKey());
                           return selectorContext;
                       }
                   }