Coverage Report - org.mule.util.properties.Dom4jPropertyExtractor
 
Classes in this File Line Coverage Branch Coverage Complexity
Dom4jPropertyExtractor
0%
0/20
0%
0/10
10
 
 1  
 /*
 2  
  * $Id: Dom4jPropertyExtractor.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.util.properties;
 12  
 
 13  
 import org.mule.umo.UMOMessage;
 14  
 
 15  
 import org.dom4j.Node;
 16  
 
 17  
 /**
 18  
  * Will select the text of a single node based on the property name
 19  
  */
 20  0
 public class Dom4jPropertyExtractor implements PropertyExtractor
 21  
 {
 22  
     public Object getProperty(String name, Object message)
 23  
     {
 24  0
         Object payload = message;
 25  0
         if (message instanceof UMOMessage)
 26  
         {
 27  0
             payload = ((UMOMessage)message).getPayload();
 28  
         }
 29  0
         if (payload instanceof org.dom4j.Document)
 30  
         {
 31  0
             org.dom4j.Document dom4jDoc = (org.dom4j.Document)payload;
 32  
             try
 33  
             {
 34  0
                 Node node = dom4jDoc.selectSingleNode(name);
 35  0
                 if (node != null)
 36  
                 {
 37  0
                     return node.getText();
 38  
                 }
 39  
             }
 40  0
             catch (Exception ignored)
 41  
             {
 42  
                 // ignore
 43  0
             }
 44  0
         }
 45  0
         else if (payload instanceof org.dom4j.Node)
 46  
         {
 47  0
             org.dom4j.Node dom4jNode = (org.dom4j.Node)payload;
 48  
             try
 49  
             {
 50  0
                 Node node = dom4jNode.selectSingleNode(name);
 51  0
                 if (node != null)
 52  
                 {
 53  0
                     return node.getText();
 54  
                 }
 55  
             }
 56  0
             catch (Exception ignored)
 57  
             {
 58  
                 // ignore
 59  0
             }
 60  
         }
 61  0
         return null;
 62  
     }
 63  
 }