}
/**
+ * Check for IRI(RFC 3987: Internationalized Resource Identifiers) string.
+ *
+ * @param value IRI string
+ *
+ * @return if value is valied IRI
+ *
+ * @link RFC 3987: http://www.ietf.org/rfc/rfc3987<br>
+ * Online validation: http://projects.scottsplayground.com/iri/demo/
+ */
+ public static boolean checkForIRI(String value) {
+ String regex = "([a-z]([a-z]|\\d|\\+|-|\\.)*):(\\/\\/(((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])" +
+ "|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:)*@)?((\\[(|(v[\\da-f]{1,}\\." +
+ "(([a-z]|\\d|-|\\.|_|~)|[!\\$&'\\(\\)\\*\\+,;=]|:)+))\\])|" +
+ "((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\." +
+ "(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]))|" +
+ "(([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=])*)(:\\d*)?)" +
+ "(\\/(([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)*)*|" +
+ "(\\/((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)+" +
+ "(\\/(([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)*)*)?)|" +
+ "((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)+" +
+ "(\\/(([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)*)*)|" +
+ "((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)){0})" +
+ "(\\?((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)|[\\uE000-\\uF8FF]|\\/|\\?)*)?" +
+ "(\\#((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)|\\/|\\?)*)?";
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(value);
+
+ return matcher.matches();
+ }
+
+ /**
* Check for URL string.
*
* @param value url string
}
/**
+ * Test {@link ValidationUtil#test_checkForIRI(String value)}
+ *
+ * @throws Exception in case of failure in test
+ *
+ * @see {@link ValidationUtil#test_checkForIRI(String value)}
+ */
+ @Test
+ public void test_checkForIRI() throws Exception {
+ final String[] validedIRIs = {"http://tizen.org",
+ "http://www.tizen.org",
+ "http://tizen.org/",
+ "http://tizen.org/id",
+ "http://myapp",
+ "http://myapp/",
+ "http://bonyong.lee:test@myapp:4000/test.dd/aaa#test",
+ "http://example.org/about/mother.fr",
+ "http://example.org/contact.nl",
+ "http://example.org/contact?lang=nl",
+ "http://example.org/nl/contact",
+ "cxd:dsf",
+ "ftp://fds",
+ "irc://fdf"
+ };
+ for (String url : validedIRIs) {
+ assertTrue(ValidationUtil.checkForIRI(url));
+ }
+ }
+
+ /**
* Test {@link ValidationUtil#checkForURL(String value)}
*
* @throws Exception in case of failure in test