public static Host parseHost(final String input) throws GalimatiasParseException {
    """
	Parses a host as found in URLs. IPv6 literals are expected
	enclosed in square brackets (i.e. [ipv6-literal]).
	
	@param input
	@return
	@throws GalimatiasParseException
    """
        if (input == null) {
            throw new NullPointerException("null host");
        }
        if (input.isEmpty()) {
            throw new GalimatiasParseException("empty host", -1);
        }
        if (input.charAt(0) == '[') {
            if (input.charAt(input.length() - 1) != ']') {
                throw new GalimatiasParseException("Unmatched '['", -1);
            }
            return IPv6Address.parseIPv6Address(input.substring(1, input.length() - 1));
        }
        final Domain domain = Domain.parseDomain(input);
        try {
            return IPv4Address.parseIPv4Address(domain.toString());
        } catch (GalimatiasParseException e) {
            return domain;
        }
    }
public static Host parseHost(final String input) throws GalimatiasParseException {
        if (input == null) {
            throw new NullPointerException("null host");
        }
        if (input.isEmpty()) {
            throw new GalimatiasParseException("empty host", -1);
        }
        if (input.charAt(0) == '[') {
            if (input.charAt(input.length() - 1) != ']') {
                throw new GalimatiasParseException("Unmatched '['", -1);
            }
            return IPv6Address.parseIPv6Address(input.substring(1, input.length() - 1));
        }
        final Domain domain = Domain.parseDomain(input);
        try {
            return IPv4Address.parseIPv4Address(domain.toString());
        } catch (GalimatiasParseException e) {
            return domain;
        }
    }
public static Host parseHost ( final String input ) throws GalimatiasParseException { if ( input == null ) { throw new NullPointerException ( "null host" ) ; } if ( input . isEmpty ( ) ) { throw new GalimatiasParseException ( "empty host" , - 1 ) ; } if ( input . charAt ( 0 ) == ' ' ) { if ( input . charAt ( input . length ( ) - 1 ) != ' ' ) { throw new GalimatiasParseException ( "Unmatched '['" , - 1 ) ; } return IPv6Address . parseIPv6Address ( input . substring ( 1 , input . length ( ) - 1 ) ) ; } final Domain domain = Domain . parseDomain ( input ) ; try { return IPv4Address . parseIPv4Address ( domain . toString ( ) ) ; } catch ( GalimatiasParseException e ) { return domain ; } }
Parses a host as found in URLs. IPv6 literals are expected
enclosed in square brackets (i.e. [ipv6-literal]).

@param input
@return
@throws GalimatiasParseException
Parses a host as found in URLs . IPv6 literals are expected enclosed in square brackets ( i . e . [ ipv6 - literal ] ) .