@Test public void testEmptyContent() { final String content = ""; final String packageName = PackageNameParser.parsePackageName( content ); assertNotNull( packageName ); assertEquals( "", packageName ); }
public static String parsePackageName(final String content) { String packageName = ""; if (content == null || content.trim().equals("")) { return packageName; } else { final String[] lines = content.split("\\n"); for (String line1 : lines) { String line = line1.trim(); if (line.startsWith(KEYWORD)) { line = line.substring(KEYWORD.length()).trim(); if (line.endsWith(";")) { line = line.substring(0, line.length() - 1); } return line; } } return packageName; } }
PackageNameParser { public static String parsePackageName(final String content) { String packageName = ""; if (content == null || content.trim().equals("")) { return packageName; } else { final String[] lines = content.split("\\n"); for (String line1 : lines) { String line = line1.trim(); if (line.startsWith(KEYWORD)) { line = line.substring(KEYWORD.length()).trim(); if (line.endsWith(";")) { line = line.substring(0, line.length() - 1); } return line; } } return packageName; } } }
PackageNameParser { public static String parsePackageName(final String content) { String packageName = ""; if (content == null || content.trim().equals("")) { return packageName; } else { final String[] lines = content.split("\\n"); for (String line1 : lines) { String line = line1.trim(); if (line.startsWith(KEYWORD)) { line = line.substring(KEYWORD.length()).trim(); if (line.endsWith(";")) { line = line.substring(0, line.length() - 1); } return line; } } return packageName; } } private  PackageNameParser(); }
PackageNameParser { public static String parsePackageName(final String content) { String packageName = ""; if (content == null || content.trim().equals("")) { return packageName; } else { final String[] lines = content.split("\\n"); for (String line1 : lines) { String line = line1.trim(); if (line.startsWith(KEYWORD)) { line = line.substring(KEYWORD.length()).trim(); if (line.endsWith(";")) { line = line.substring(0, line.length() - 1); } return line; } } return packageName; } } private  PackageNameParser(); static String parsePackageName(final String content); }
PackageNameParser { public static String parsePackageName(final String content) { String packageName = ""; if (content == null || content.trim().equals("")) { return packageName; } else { final String[] lines = content.split("\\n"); for (String line1 : lines) { String line = line1.trim(); if (line.startsWith(KEYWORD)) { line = line.substring(KEYWORD.length()).trim(); if (line.endsWith(";")) { line = line.substring(0, line.length() - 1); } return line; } } return packageName; } } private  PackageNameParser(); static String parsePackageName(final String content);  }