ConfigUtils { public static String stripSpaces(String str) { StringBuilder ret = new StringBuilder(); boolean inQuotes = false; boolean inSpaceSequence = false; for (char c : str.toCharArray()) { if (Character.isWhitespace(c)) { if (inQuotes) { ret.append(c); continue; } if (!inSpaceSequence) { inSpaceSequence = true; ret.append(" "); } } else { if (inSpaceSequence) { inSpaceSequence = false; } if (c == '\"') { inQuotes = !inQuotes; } ret.append(c); } } return ret.toString(); }  static String getMd5(ConfigPayload payload); static String getMd5(String input); static String getMd5(Utf8Array input); static String getMd5(byte[] input); static String stripSpaces(String str); static String getDefMd5(List<String> lines); static String getDefNamespace(Reader in); static Tuple2<String, String> getNameAndNamespaceFromString(String nameDotNamespace); static ConfigDefinitionKey createConfigDefinitionKeyFromZKString(String nodeName); static ConfigDefinitionKey createConfigDefinitionKeyFromDefFile(File file); static String escapeConfigFormatValue(String input); static String getDefMd5FromRequest(String defMd5, List<String> defContent); static String getCanonicalHostName(); static String getEnvValue(String defaultValue, String... envVars); static boolean isGenerationNewer(long newGen, long oldGen);  }
@Test public void testStripSpaces() { assertThat(ConfigUtils.stripSpaces("a b"), is("a b")); assertThat(ConfigUtils.stripSpaces("\"a b\""), is("\"a b\"")); assertThat(ConfigUtils.stripSpaces("a b \"a b\""), is("a b \"a b\"")); assertThat(ConfigUtils.stripSpaces("a b"), is("a b")); }