1 15 package org.apache.hivemind.util; 16 17 import org.apache.hivemind.HiveMind; 18 19 24 public class IdUtils 25 { 26 27 31 public static String qualify(String moduleId, String id) 32 { 33 if (id.indexOf('.') > 0) 34 return id; 35 36 return moduleId + "." + id; 37 } 38 39 43 public static String qualifyList(String sourceModuleId, String list) 44 { 45 if (HiveMind.isBlank(list) || list.equals("*")) 46 return list; 47 48 String [] items = StringUtils.split(list); 49 50 for (int i = 0; i < items.length; i++) 51 items[i] = qualify(sourceModuleId, items[i]); 52 53 return StringUtils.join(items, ','); 54 } 55 56 59 public static String stripModule(String id) 60 { 61 int lastPoint = id.lastIndexOf('.'); 62 if (lastPoint > 0) 63 return id.substring(lastPoint + 1, id.length()); 64 65 return id; 66 } 67 68 71 public static String extractModule(String id) 72 { 73 int lastPoint = id.lastIndexOf('.'); 74 if (lastPoint > 0) 75 return id.substring(0, lastPoint); 76 77 return null; 78 } 79 80 } 81 | Popular Tags |