@Test public void testFullyValidName() { String name = "SomeValidNameForTheПроцесс"; assertEquals(name, createValidId(name)); }
public static String createValidId(String value) { if (isEmpty(value)) { return "_"; } StringBuilder resultId = new StringBuilder(); for (int i = 0; i < value.length(); i++) { if (isNcNameCharacter(value.charAt(i))) { resultId.append(value.charAt(i)); } } String result = resultId.toString(); if (isEmpty(result)) { return "_"; } if (isNcNameStartCharacter(result.charAt(0))) { return result; } return "_" + result; }
XmlUtils { public static String createValidId(String value) { if (isEmpty(value)) { return "_"; } StringBuilder resultId = new StringBuilder(); for (int i = 0; i < value.length(); i++) { if (isNcNameCharacter(value.charAt(i))) { resultId.append(value.charAt(i)); } } String result = resultId.toString(); if (isEmpty(result)) { return "_"; } if (isNcNameStartCharacter(result.charAt(0))) { return result; } return "_" + result; } }
XmlUtils { public static String createValidId(String value) { if (isEmpty(value)) { return "_"; } StringBuilder resultId = new StringBuilder(); for (int i = 0; i < value.length(); i++) { if (isNcNameCharacter(value.charAt(i))) { resultId.append(value.charAt(i)); } } String result = resultId.toString(); if (isEmpty(result)) { return "_"; } if (isNcNameStartCharacter(result.charAt(0))) { return result; } return "_" + result; } private  XmlUtils(); }
XmlUtils { public static String createValidId(String value) { if (isEmpty(value)) { return "_"; } StringBuilder resultId = new StringBuilder(); for (int i = 0; i < value.length(); i++) { if (isNcNameCharacter(value.charAt(i))) { resultId.append(value.charAt(i)); } } String result = resultId.toString(); if (isEmpty(result)) { return "_"; } if (isNcNameStartCharacter(result.charAt(0))) { return result; } return "_" + result; } private  XmlUtils(); static boolean isNcNameStartCharacter(char ch); static boolean isNcNameCharacter(char ch); static String createValidId(String value); }
XmlUtils { public static String createValidId(String value) { if (isEmpty(value)) { return "_"; } StringBuilder resultId = new StringBuilder(); for (int i = 0; i < value.length(); i++) { if (isNcNameCharacter(value.charAt(i))) { resultId.append(value.charAt(i)); } } String result = resultId.toString(); if (isEmpty(result)) { return "_"; } if (isNcNameStartCharacter(result.charAt(0))) { return result; } return "_" + result; } private  XmlUtils(); static boolean isNcNameStartCharacter(char ch); static boolean isNcNameCharacter(char ch); static String createValidId(String value);  }