Coverage Report - org.mule.impl.endpoint.ResourceNameEndpointBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
ResourceNameEndpointBuilder
0%
0/20
0%
0/6
7
 
 1  
 /*
 2  
  * $Id: ResourceNameEndpointBuilder.java 7976 2007-08-21 14:26:13Z 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.impl.endpoint;
 12  
 
 13  
 import org.mule.umo.endpoint.MalformedEndpointException;
 14  
 import org.mule.util.StringUtils;
 15  
 
 16  
 import java.net.URI;
 17  
 import java.util.Properties;
 18  
 
 19  
 /**
 20  
  * <code>ResourceNameEndpointBuilder</code> extracts a resource name from a uri
 21  
  * endpointUri
 22  
  * 
 23  
  */
 24  0
 public class ResourceNameEndpointBuilder extends AbstractEndpointBuilder
 25  
 {
 26  
     public static final String RESOURCE_INFO_PROPERTY = "resourceInfo";
 27  
 
 28  
     protected void setEndpoint(URI uri, Properties props) throws MalformedEndpointException
 29  
     {
 30  0
         address = StringUtils.EMPTY;
 31  0
         if (uri.getHost() != null && !"localhost".equals(uri.getHost()))
 32  
         {
 33  0
             address = uri.getHost();
 34  
         }
 35  
 
 36  0
         if (uri.getPath() != null && uri.getPath().length() != 0)
 37  
         {
 38  0
             if (address.length() > 0)
 39  
             {
 40  0
                 address += "/";
 41  
             }
 42  0
             address += uri.getPath().substring(1);
 43  
         }
 44  0
         else if (uri.getAuthority() != null && !uri.getAuthority().equals(address))
 45  
         {
 46  0
             address += uri.getAuthority();
 47  
         }
 48  
         // is user info specified?
 49  0
         int y = address.indexOf("@");
 50  0
         if (y > -1)
 51  
         {
 52  0
             this.userInfo = address.substring(0, y);
 53  
         }
 54  
         // increment to 0 or one char past the @
 55  0
         y++;
 56  
 
 57  0
         int x = address.indexOf(":", y);
 58  0
         if (x > -1)
 59  
         {
 60  0
             String resourceInfo = address.substring(y, x);
 61  0
             props.setProperty("resourceInfo", resourceInfo);
 62  0
             address = address.substring(x + 1);
 63  
         }
 64  0
     }
 65  
 }