src/main/java/org/wymiwyg/commons/util/URI.java
public static boolean isWellFormedAddress(String p_address) {
		if (p_address == null) {
			return false;
		}

		String address = p_address;
		int addrLength = address.length();
		if (addrLength == 0 || addrLength > 255) {
			return false;
		}

		if (address.startsWith(".") || address.startsWith("-")) {
			return false;
		}

		// rightmost domain label starting with digit indicates IP address
		// since top level domain label can only start with an alpha
		// see RFC 2396 Section 3.2.2
		int index = address.lastIndexOf('.');
		if (address.endsWith(".")) {
			index = address.substring(0, index).lastIndexOf('.');
		}

		if (index + 1 < addrLength && isDigit(p_address.charAt(index + 1))) {
			char testChar;
			int numDots = 0;

			// make sure that 1) we see only digits and dot separators, 2) that
			// any dot separator is preceded and followed by a digit and
			// 3) that we find 3 dots
			for (int i = 0; i < addrLength; i++) {
				testChar = address.charAt(i);
				if (testChar == '.') {
					if (!isDigit(address.charAt(i - 1))
						|| (i + 1 < addrLength
							&& !isDigit(address.charAt(i + 1)))) {
						return false;
					}
					numDots++;
				} else if (!isDigit(testChar)) {
					return false;
				}
			}
			if (numDots != 3) {
				return false;
			}
		} else {
			// domain labels can contain alphanumerics and '-"
			// but must start and end with an alphanumeric
			char testChar;

			for (int i = 0; i < addrLength; i++) {
				testChar = address.charAt(i);
				if (testChar == '.') {
					if (!isAlphanum(address.charAt(i - 1))) {
						return false;
					}
					if (i + 1 < addrLength
						&& !isAlphanum(address.charAt(i + 1))) {
						return false;
					}
				} else if (!isAlphanum(testChar) && testChar != '-') {
					return false;
				}
			}
		}
		return true;
	}
public static boolean isWellFormedAddress(String p_address) {
		if (p_address == null) {
			return false;
		}

		String address = p_address;
		int addrLength = address.length();
		if (addrLength == 0 || addrLength > 255) {
			return false;
		}

		if (address.startsWith(".") || address.startsWith("-")) {
			return false;
		}

		// rightmost domain label starting with digit indicates IP address
		// since top level domain label can only start with an alpha
		// see RFC 2396 Section 3.2.2
		int index = address.lastIndexOf('.');
		if (address.endsWith(".")) {
			index = address.substring(0, index).lastIndexOf('.');
		}

		if (index + 1 < addrLength && isDigit(p_address.charAt(index + 1))) {
			char testChar;
			int numDots = 0;

			// make sure that 1) we see only digits and dot separators, 2) that
			// any dot separator is preceded and followed by a digit and
			// 3) that we find 3 dots
			for (int i = 0; i < addrLength; i++) {
				testChar = address.charAt(i);
				if (testChar == '.') {
					if (!isDigit(address.charAt(i - 1))
						|| (i + 1 < addrLength
							&& !isDigit(address.charAt(i + 1)))) {
						return false;
					}
					numDots++;
				} else if (!isDigit(testChar)) {
					return false;
				}
			}
			if (numDots != 3) {
				return false;
			}
		} else {
			// domain labels can contain alphanumerics and '-"
			// but must start and end with an alphanumeric
			char testChar;

			for (int i = 0; i < addrLength; i++) {
				testChar = address.charAt(i);
				if (testChar == '.') {
					if (!isAlphanum(address.charAt(i - 1))) {
						return false;
					}
					if (i + 1 < addrLength
						&& !isAlphanum(address.charAt(i + 1))) {
						return false;
					}
				} else if (!isAlphanum(testChar) && testChar != '-') {
					return false;
				}
			}
		}
		return true;
	}
Determine whether a string is syntactically capable of representing
a valid IPv4 address or the domain name of a network host. A valid
IPv4 address consists of four decimal digit groups separated by a
'.'. A hostname consists of domain labels (each of which must
begin and end with an alphanumeric but may contain '-') separated
& by a '.'. See RFC 2396 Section 3.2.2.

@return true if the string is a syntactically valid IPv4 address
or hostname