@Test public void normalizeFormNameTest() { assertThat(normalizeFormName(null, false), is(nullValue())); assertThat(normalizeFormName("Lorem", false), is("Lorem")); assertThat(normalizeFormName("Lorem ipsum", false), is("Lorem ipsum")); assertThat(normalizeFormName("Lorem\nipsum", false), is("Lorem ipsum")); assertThat(normalizeFormName("Lorem\n\nipsum", false), is("Lorem ipsum")); assertThat(normalizeFormName("\nLorem\nipsum\n", false), is(" Lorem ipsum ")); assertThat(normalizeFormName(null, true), is(nullValue())); assertThat(normalizeFormName("Lorem", true), is(nullValue())); assertThat(normalizeFormName("Lorem ipsum", true), is(nullValue())); assertThat(normalizeFormName("Lorem\nipsum", true), is("Lorem ipsum")); assertThat(normalizeFormName("Lorem\n\nipsum", true), is("Lorem ipsum")); assertThat(normalizeFormName("\nLorem\nipsum\n", true), is(" Lorem ipsum ")); }
public static String normalizeFormName(String formName, boolean returnNullIfNothingChanged) { if (formName == null) { return null; } Matcher matcher = CONTROL_CHAR_PATTERN.matcher(formName); return matcher.find() ? matcher.replaceAll(" ") : (returnNullIfNothingChanged ? null : formName); }
FormNameUtils { public static String normalizeFormName(String formName, boolean returnNullIfNothingChanged) { if (formName == null) { return null; } Matcher matcher = CONTROL_CHAR_PATTERN.matcher(formName); return matcher.find() ? matcher.replaceAll(" ") : (returnNullIfNothingChanged ? null : formName); } }
FormNameUtils { public static String normalizeFormName(String formName, boolean returnNullIfNothingChanged) { if (formName == null) { return null; } Matcher matcher = CONTROL_CHAR_PATTERN.matcher(formName); return matcher.find() ? matcher.replaceAll(" ") : (returnNullIfNothingChanged ? null : formName); } private  FormNameUtils(); }
FormNameUtils { public static String normalizeFormName(String formName, boolean returnNullIfNothingChanged) { if (formName == null) { return null; } Matcher matcher = CONTROL_CHAR_PATTERN.matcher(formName); return matcher.find() ? matcher.replaceAll(" ") : (returnNullIfNothingChanged ? null : formName); } private  FormNameUtils(); static String normalizeFormName(String formName, boolean returnNullIfNothingChanged); static String formatFilenameFromFormName(String formName); }
FormNameUtils { public static String normalizeFormName(String formName, boolean returnNullIfNothingChanged) { if (formName == null) { return null; } Matcher matcher = CONTROL_CHAR_PATTERN.matcher(formName); return matcher.find() ? matcher.replaceAll(" ") : (returnNullIfNothingChanged ? null : formName); } private  FormNameUtils(); static String normalizeFormName(String formName, boolean returnNullIfNothingChanged); static String formatFilenameFromFormName(String formName);  }