@Test public void getEncoding() { Assert.assertNull(AppSchemaValidator.getEncoding("")); Assert.assertNull(AppSchemaValidator.getEncoding("<?xml version=\"1.0\"?>")); Assert.assertNull(AppSchemaValidator.getEncoding("<?xml version=\"1.0\"? >")); Assert.assertNull(AppSchemaValidator.getEncoding("<?xml version=\"1.0\"?><root/>")); Assert.assertEquals("UTF-8", AppSchemaValidator.getEncoding("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")); Assert.assertEquals("UTF-8", AppSchemaValidator.getEncoding("<?xml version='1.0' encoding='UTF-8'?>")); Assert.assertEquals("UTF-8", AppSchemaValidator.getEncoding("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")); Assert.assertEquals("UTF-8", AppSchemaValidator .getEncoding("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>")); Assert.assertEquals("UTF-8", AppSchemaValidator.getEncoding("<?xml version=\"1.0\" encoding=\"UTF-8\"?><root/>")); }
static String getEncoding(String xml) { Matcher m = XML_ENCODING_PATTERN.matcher(xml); if (m.matches()) { return m.group(1); } else { return null; } }
AppSchemaValidator { static String getEncoding(String xml) { Matcher m = XML_ENCODING_PATTERN.matcher(xml); if (m.matches()) { return m.group(1); } else { return null; } } }
AppSchemaValidator { static String getEncoding(String xml) { Matcher m = XML_ENCODING_PATTERN.matcher(xml); if (m.matches()) { return m.group(1); } else { return null; } } private  AppSchemaValidator(); private  AppSchemaValidator(AppSchemaResolver resolver); }
AppSchemaValidator { static String getEncoding(String xml) { Matcher m = XML_ENCODING_PATTERN.matcher(xml); if (m.matches()) { return m.group(1); } else { return null; } } private  AppSchemaValidator(); private  AppSchemaValidator(AppSchemaResolver resolver); List<String> getFailures(); boolean isFailOnWarning(); void setFailOnWarning(boolean failOnWarning); void parse(InputStream input); void checkForFailures(); static AppSchemaValidator buildValidator(); static AppSchemaValidator buildValidator(AppSchemaResolver resolver); static void validateResource(String name); static void validate(String xml); static void validate(InputStream input); }
AppSchemaValidator { static String getEncoding(String xml) { Matcher m = XML_ENCODING_PATTERN.matcher(xml); if (m.matches()) { return m.group(1); } else { return null; } } private  AppSchemaValidator(); private  AppSchemaValidator(AppSchemaResolver resolver); List<String> getFailures(); boolean isFailOnWarning(); void setFailOnWarning(boolean failOnWarning); void parse(InputStream input); void checkForFailures(); static AppSchemaValidator buildValidator(); static AppSchemaValidator buildValidator(AppSchemaResolver resolver); static void validateResource(String name); static void validate(String xml); static void validate(InputStream input);  }