@Test public void testReplaceWildcardInStringWithString() throws Exception { assertEquals(null, stringUtils.replaceWildcardInStringWithString("*", null, "Entity")); assertEquals("*.java", stringUtils.replaceWildcardInStringWithString(null, "*.java", "Entity")); assertEquals("Entity.java", stringUtils.replaceWildcardInStringWithString("*", "*.java", "Entity")); assertEquals("java.Entity", stringUtils.replaceWildcardInStringWithString("*", "java.*", "Entity")); assertEquals("Entity.Entity", stringUtils.replaceWildcardInStringWithString("*", "*.*", "Entity")); assertEquals("EntityEntity", stringUtils.replaceWildcardInStringWithString("*", "**", "Entity")); assertEquals("EditEntityReport.vm", stringUtils.replaceWildcardInStringWithString("*", "Edit*Report.vm", "Entity")); assertEquals("Entity", stringUtils.replaceWildcardInStringWithString("*", "*", "Entity")); }
public String replaceWildcardInStringWithString(String wildcard, String pattern, String replacement) { if (pattern == null || wildcard == null) { return pattern; } StringBuilder buffer = new StringBuilder(); int lastPos = 0; int wildCardPos = pattern.indexOf(wildcard); while (wildCardPos != -1) { if (lastPos != wildCardPos) { buffer.append(pattern.substring(lastPos, wildCardPos)); } buffer.append(replacement); lastPos += wildCardPos + wildcard.length(); wildCardPos = pattern.indexOf(wildcard, lastPos); } if (lastPos < pattern.length()) { buffer.append(pattern.substring(lastPos)); } return buffer.toString(); }
StringUtils { public String replaceWildcardInStringWithString(String wildcard, String pattern, String replacement) { if (pattern == null || wildcard == null) { return pattern; } StringBuilder buffer = new StringBuilder(); int lastPos = 0; int wildCardPos = pattern.indexOf(wildcard); while (wildCardPos != -1) { if (lastPos != wildCardPos) { buffer.append(pattern.substring(lastPos, wildCardPos)); } buffer.append(replacement); lastPos += wildCardPos + wildcard.length(); wildCardPos = pattern.indexOf(wildcard, lastPos); } if (lastPos < pattern.length()) { buffer.append(pattern.substring(lastPos)); } return buffer.toString(); } }
StringUtils { public String replaceWildcardInStringWithString(String wildcard, String pattern, String replacement) { if (pattern == null || wildcard == null) { return pattern; } StringBuilder buffer = new StringBuilder(); int lastPos = 0; int wildCardPos = pattern.indexOf(wildcard); while (wildCardPos != -1) { if (lastPos != wildCardPos) { buffer.append(pattern.substring(lastPos, wildCardPos)); } buffer.append(replacement); lastPos += wildCardPos + wildcard.length(); wildCardPos = pattern.indexOf(wildcard, lastPos); } if (lastPos < pattern.length()) { buffer.append(pattern.substring(lastPos)); } return buffer.toString(); }  }
StringUtils { public String replaceWildcardInStringWithString(String wildcard, String pattern, String replacement) { if (pattern == null || wildcard == null) { return pattern; } StringBuilder buffer = new StringBuilder(); int lastPos = 0; int wildCardPos = pattern.indexOf(wildcard); while (wildCardPos != -1) { if (lastPos != wildCardPos) { buffer.append(pattern.substring(lastPos, wildCardPos)); } buffer.append(replacement); lastPos += wildCardPos + wildcard.length(); wildCardPos = pattern.indexOf(wildcard, lastPos); } if (lastPos < pattern.length()) { buffer.append(pattern.substring(lastPos)); } return buffer.toString(); }  static StringUtils getInstance(); String formatVariableName(String variableName); String stripPackageName(String fullyQualifiedClassName); String stripClass(String aString); String capitalized(String name); String uncapitalized(String aString); String capitalizedAsConstant(String name); String pluralize(String str); String stripGeneric(String str); String replaceWildcardInStringWithString(String wildcard, String pattern, String replacement); }
StringUtils { public String replaceWildcardInStringWithString(String wildcard, String pattern, String replacement) { if (pattern == null || wildcard == null) { return pattern; } StringBuilder buffer = new StringBuilder(); int lastPos = 0; int wildCardPos = pattern.indexOf(wildcard); while (wildCardPos != -1) { if (lastPos != wildCardPos) { buffer.append(pattern.substring(lastPos, wildCardPos)); } buffer.append(replacement); lastPos += wildCardPos + wildcard.length(); wildCardPos = pattern.indexOf(wildcard, lastPos); } if (lastPos < pattern.length()) { buffer.append(pattern.substring(lastPos)); } return buffer.toString(); }  static StringUtils getInstance(); String formatVariableName(String variableName); String stripPackageName(String fullyQualifiedClassName); String stripClass(String aString); String capitalized(String name); String uncapitalized(String aString); String capitalizedAsConstant(String name); String pluralize(String str); String stripGeneric(String str); String replaceWildcardInStringWithString(String wildcard, String pattern, String replacement);  }