@Test(expected=URISyntaxException.class) public void getPackageNameBadCharacter() throws Exception { StringUtil.getPackageName("|"); }
public static String getPackageName(String baseUrl) throws URISyntaxException { if (baseUrl == null) { return null; } URI uri = new URI(baseUrl); String domain = uri.getHost(); if (domain == null) { return null; } String[] parts = domain.split("\\."); StringBuffer buf = new StringBuffer(); for (int i = parts.length - 1; i >= 0; --i) { String part = parts[i].replace('-', '_'); if (part.charAt(0) >= '0' && part.charAt(0) <= '9') { buf.append('_'); } buf.append(part); if (i != 0) { buf.append('.'); } } return buf.toString(); }
StringUtil { public static String getPackageName(String baseUrl) throws URISyntaxException { if (baseUrl == null) { return null; } URI uri = new URI(baseUrl); String domain = uri.getHost(); if (domain == null) { return null; } String[] parts = domain.split("\\."); StringBuffer buf = new StringBuffer(); for (int i = parts.length - 1; i >= 0; --i) { String part = parts[i].replace('-', '_'); if (part.charAt(0) >= '0' && part.charAt(0) <= '9') { buf.append('_'); } buf.append(part); if (i != 0) { buf.append('.'); } } return buf.toString(); } }
StringUtil { public static String getPackageName(String baseUrl) throws URISyntaxException { if (baseUrl == null) { return null; } URI uri = new URI(baseUrl); String domain = uri.getHost(); if (domain == null) { return null; } String[] parts = domain.split("\\."); StringBuffer buf = new StringBuffer(); for (int i = parts.length - 1; i >= 0; --i) { String part = parts[i].replace('-', '_'); if (part.charAt(0) >= '0' && part.charAt(0) <= '9') { buf.append('_'); } buf.append(part); if (i != 0) { buf.append('.'); } } return buf.toString(); }  }
StringUtil { public static String getPackageName(String baseUrl) throws URISyntaxException { if (baseUrl == null) { return null; } URI uri = new URI(baseUrl); String domain = uri.getHost(); if (domain == null) { return null; } String[] parts = domain.split("\\."); StringBuffer buf = new StringBuffer(); for (int i = parts.length - 1; i >= 0; --i) { String part = parts[i].replace('-', '_'); if (part.charAt(0) >= '0' && part.charAt(0) <= '9') { buf.append('_'); } buf.append(part); if (i != 0) { buf.append('.'); } } return buf.toString(); }  static String primitiveToObject(String type); static String getPackageName(String baseUrl); static String getPath(String packageName, String fileName); static boolean isReservedWord(String name); }
StringUtil { public static String getPackageName(String baseUrl) throws URISyntaxException { if (baseUrl == null) { return null; } URI uri = new URI(baseUrl); String domain = uri.getHost(); if (domain == null) { return null; } String[] parts = domain.split("\\."); StringBuffer buf = new StringBuffer(); for (int i = parts.length - 1; i >= 0; --i) { String part = parts[i].replace('-', '_'); if (part.charAt(0) >= '0' && part.charAt(0) <= '9') { buf.append('_'); } buf.append(part); if (i != 0) { buf.append('.'); } } return buf.toString(); }  static String primitiveToObject(String type); static String getPackageName(String baseUrl); static String getPath(String packageName, String fileName); static boolean isReservedWord(String name);  }