1 package org.apache.axis2.wsdl.util; 2 3 import java.util.regex.Matcher ; 4 import java.util.regex.Pattern ; 5 6 23 public class URLProcessor { 24 public static final String DEFAULT_PACKAGE = "axis2"; 25 26 33 public static String getNameSpaceFromURL(String url){ 34 String returnPackageName = ""; 35 String regularExpression = "//[\\w\\.]*"; 36 Pattern urlBreaker =Pattern.compile(regularExpression); 37 Matcher matcher = urlBreaker.matcher(url); 38 if (matcher.find()) { 39 String s = matcher.group(); 40 s = s.replaceAll("//",""); 41 String [] arrayOfItems = s.split("\\."); 42 int length = arrayOfItems.length; 43 for (int i = length; i > 0; i--) { 44 returnPackageName = returnPackageName.concat((i==length?"":".") + arrayOfItems[i-1]); 45 } 46 }else{ 47 returnPackageName = DEFAULT_PACKAGE; 48 } 49 50 return returnPackageName; 51 } 52 53 } 54 | Popular Tags |