public static String checkURI(final String uri) {
		// URIs can be null or empty
		if ((uri == null) || (uri.equals(""))) {
			return null;
		}

		for (int i = 0; i < uri.length(); i++) {
			final char test = uri.charAt(i);
			if (!isURICharacter(test)) {
				String msgNumber = "0x" + Integer.toHexString(test);
				if (test <= 0x09) msgNumber = "0x0" + Integer.toHexString(test);
				return "URIs cannot contain " + msgNumber;
			} // end if
			if (test == '%') { // must be followed by two hexadecimal digits
				try {
					final char firstDigit = uri.charAt(i+1);
					final char secondDigit = uri.charAt(i+2);
					if (!isHexDigit(firstDigit) ||
							!isHexDigit(secondDigit)) {
						return "Percent signs in URIs must be followed by "
								+ "exactly two hexadecimal digits.";
					}

				}
				catch (final StringIndexOutOfBoundsException e) {
					return "Percent signs in URIs must be followed by "
							+ "exactly two hexadecimal digits.";
				}
			}
		} // end for

		// If we got here, everything is OK
		return null;
	}