| 1 | 
    
            
    
     | 
    
           | 
  
            
  
    | 2 | 
    
            
    
     | 
    
           | 
  
            
  
    | 3 | 
    
            
    
     | 
    
           | 
  
            
  
    | 4 | 
    
            
    
     | 
    
           | 
  
            
  
    | 5 | 
    
            
    
     | 
    
           | 
  
            
  
    | 6 | 
    
            
    
     | 
    
           | 
  
            
  
    | 7 | 
    
            
    
     | 
    
           | 
  
            
  
    | 8 | 
    
            
    
     | 
    
           | 
  
            
  
    | 9 | 
    
            
    
     | 
    
           | 
  
            
  
    | 10 | 
    
            
    
     | 
    
           | 
  
            
  
    | 11 | 
    
            
    
     | 
    
           | 
  
            
  
    | 12 | 
    
            
    
     | 
    
           | 
  
            
  
    | 13 | 
    
            
    
     | 
    
           | 
  
            
  
    | 14 | 
    
            
    
     | 
    
           | 
  
            
  
    | 15 | 
    
            
    
     | 
    
           | 
  
            
  
    | 16 | 
    
            
    
     | 
    
           | 
  
            
  
    | 17 | 
    
            
    
     | 
    
      package org.kuali.rice.kew.xml.xstream;     | 
  
            
  
    | 18 | 
    
            
    
     | 
    
           | 
  
            
  
    | 19 | 
    
            
    
     | 
    
      import java.util.List;     | 
  
            
  
    | 20 | 
    
            
    
     | 
    
           | 
  
            
  
    | 21 | 
    
            
    
     | 
    
      import javax.xml.xpath.XPath;     | 
  
            
  
    | 22 | 
    
            
    
     | 
    
      import javax.xml.xpath.XPathExpressionException;     | 
  
            
  
    | 23 | 
    
            
    
     | 
    
      import javax.xml.xpath.XPathFunction;     | 
  
            
  
    | 24 | 
    
            
    
     | 
    
      import javax.xml.xpath.XPathFunctionException;     | 
  
            
  
    | 25 | 
    
            
    
     | 
    
           | 
  
            
  
    | 26 | 
    
            
    
     | 
    
      import org.w3c.dom.Node;     | 
  
            
  
    | 27 | 
    
            
    
     | 
    
           | 
  
            
  
    | 28 | 
    
            
    
     | 
    
           | 
  
            
  
    | 29 | 
    
            
    
     | 
    
           | 
  
            
  
    | 30 | 
    
            
    
     | 
    
           | 
  
            
  
    | 31 | 
    
            
    
     | 
    
      @see     | 
  
            
  
    | 32 | 
    
            
    
     | 
    
           | 
  
            
  
    | 33 | 
    
            
    
     | 
    
      @author     | 
  
            
  
    | 34 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 23 (23) | 
           Complexity: 8 | 
           Complexity Density: 0.57 | 
                        
            
        | 
    
  
  
    | 35 | 
    
            
    
     | 
    
      public class XStreamSafeSearchFunction implements XPathFunction {     | 
  
            
  
    | 36 | 
    
            
    
     | 
    
           | 
  
            
  
    | 37 | 
    
            
    
     | 
    
          private final Node rootNode;     | 
  
            
  
    | 38 | 
    
            
    
     | 
    
          private XPath xpath;     | 
  
            
  
    | 39 | 
    
            
    
     | 
    
          private static XStreamSafeEvaluator evaluator = new XStreamSafeEvaluator();     | 
  
            
  
    | 40 | 
    
            
    
     | 
    
               | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 2 (2) | 
           Complexity: 1 | 
           Complexity Density: 0.5 | 
                        
            
        | 
    
  
  
    | 41 | 
    
           0
    
     | 
    
           public XStreamSafeSearchFunction(Node rootNode, XPath xpath) {...     | 
  
            
  
    | 42 | 
    
           0
    
     | 
    
              this.rootNode = rootNode;     | 
  
            
  
    | 43 | 
    
           0
    
     | 
    
              this.xpath = xpath;     | 
  
            
  
    | 44 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 45 | 
    
            
    
     | 
    
               | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 5 (5) | 
           Complexity: 2 | 
           Complexity Density: 0.4 | 
                        
            
        | 
    
  
  
    | 46 | 
    
           0
    
     | 
    
           public Object evaluate(List parameters) throws XPathFunctionException {...     | 
  
            
  
    | 47 | 
    
           0
    
     | 
    
              String xPathExpression = getXPathExpressionParameter(parameters);     | 
  
            
  
    | 48 | 
    
           0
    
     | 
    
              evaluator.setXpath(xpath);     | 
  
            
  
    | 49 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 50 | 
    
           0
    
     | 
    
              try {     | 
  
            
  
    | 51 | 
    
           0
    
     | 
    
                  return evaluator.evaluate(xPathExpression, rootNode);     | 
  
            
  
    | 52 | 
    
            
    
     | 
    
              } catch (XPathExpressionException e) {     | 
  
            
  
    | 53 | 
    
           0
    
     | 
    
                  throw new XPathFunctionException(e);     | 
  
            
  
    | 54 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 55 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 56 | 
    
            
    
     | 
    
               | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 9 (9) | 
           Complexity: 3 | 
           Complexity Density: 0.6 | 
                        
            
        | 
    
  
  
    | 57 | 
    
           0
    
     | 
    
           private String getXPathExpressionParameter(List parameters) throws XPathFunctionException {...     | 
  
            
  
    | 58 | 
    
           0
    
     | 
    
              if (parameters.size() < 1) {     | 
  
            
  
    | 59 | 
    
           0
    
     | 
    
                  throw new XPathFunctionException("First parameter must be an XPath expression.");     | 
  
            
  
    | 60 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 61 | 
    
           0
    
     | 
    
              if (!(parameters.get(0) instanceof String)) {     | 
  
            
  
    | 62 | 
    
           0
    
     | 
    
                  throw new XPathFunctionException("First parameter must be an XPath expression String");     | 
  
            
  
    | 63 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 64 | 
    
           0
    
     | 
    
              return (String)parameters.get(0);     | 
  
            
  
    | 65 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 66 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 67 | 
    
           0
    
     | 
    
           public XPath getXpath() {...     | 
  
            
  
    | 68 | 
    
           0
    
     | 
    
              return xpath;     | 
  
            
  
    | 69 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 70 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 71 | 
    
           0
    
     | 
    
           public void setXpath(XPath xpath) {...     | 
  
            
  
    | 72 | 
    
           0
    
     | 
    
              this.xpath = xpath;     | 
  
            
  
    | 73 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 74 | 
    
            
    
     | 
    
               | 
  
            
  
    | 75 | 
    
            
    
     | 
    
               | 
  
            
  
    | 76 | 
    
            
    
     | 
    
           | 
  
            
  
    | 77 | 
    
            
    
     | 
    
           | 
  
            
  
    | 78 | 
    
            
    
     | 
    
           | 
  
            
  
    | 79 | 
    
            
    
     | 
    
           | 
  
            
  
    | 80 | 
    
            
    
     | 
    
           | 
  
            
  
    | 81 | 
    
            
    
     | 
    
           | 
  
            
  
    | 82 | 
    
            
    
     | 
    
           | 
  
            
  
    | 83 | 
    
            
    
     | 
    
           | 
  
            
  
    | 84 | 
    
            
    
     | 
    
           | 
  
            
  
    | 85 | 
    
            
    
     | 
    
           | 
  
            
  
    | 86 | 
    
            
    
     | 
    
      }     |