indexing
	description: "URLs for FTP resources"
	status: "See note at end of class"
	date: "$Date$"
	revision: "$Revision$"

class interface
	FTP_URL

create 

	make (a: STRING)
			-- Create address.
		require -- from URL
			address_specified: a /= void and then not a.is_empty
		ensure -- from URL
			address_set: address = a
			default_port_set: port = default_port
			no_proxy_set: proxy_information = void

feature -- Access

	hash_code: INTEGER
			-- Hash function
			-- (from NETWORK_RESOURCE_URL)
		ensure -- from HASHABLE
			good_hash_value: Result >= 0

	host: STRING
			-- Name or IP address of host
			-- (from NETWORK_RESOURCE_URL)

	location: STRING
			-- Full URL of resource
			-- (from NETWORK_RESOURCE_URL)

	password: STRING
			-- Optional password
			-- (from NETWORK_RESOURCE_URL)

	path: STRING
			-- Path of resource
			-- (from NETWORK_RESOURCE_URL)

	port: INTEGER
			-- Port used by service
			-- (from URL)

	proxy_host: STRING
			-- Name or address of proxy host
			-- (from URL)
		require -- from URL
			proxy_supported: is_proxy_supported
			has_proxy: is_proxy_used
		ensure -- from URL
			result_not_empty: Result /= void and then not Result.is_empty

	proxy_port: INTEGER
			-- Port of proxy
			-- (from URL)
		require -- from URL
			proxy_supported: is_proxy_supported
			has_proxy: is_proxy_used
		ensure -- from URL
			result_non_negative: Result >= 0

	Service: STRING is "ftp"
			-- Name of service (Answer: "ftp")

	username: STRING
			-- Optional username
			-- (from NETWORK_RESOURCE_URL)
	
feature -- Comparison

	is_equal (other: like Current): BOOLEAN
			-- Is equal to other?
			-- (from NETWORK_RESOURCE_URL)
		require -- from ANY
			other_not_void: other /= void
		ensure -- from ANY
			symmetric: Result implies other.is_equal (Current)
			consistent: standard_is_equal (other) implies Result
	
feature -- Status report

	Default_port: INTEGER is 21
			-- Number of default port for service (Answer: 21)

	Has_username: BOOLEAN is True
			-- Can address contain a username? (Answer: yes)

	proxy_host_ok (h: STRING): BOOLEAN
			-- Is h a valid host?
			-- (from HOST_VALIDITY_CHECKER)
		require -- from URL
			proxy_supported: is_proxy_supported

	is_correct: BOOLEAN
			-- Is address correct?
			-- (from NETWORK_RESOURCE_URL)

	is_hashable: BOOLEAN
			-- May current object be hashed?
			-- (True if it is not its type's default.)
			-- (from HASHABLE)
		ensure -- from HASHABLE
			ok_if_not_default: Result implies (Current /= default)

	is_host_correct (h: STRING): BOOLEAN
			-- Is host h name correct?
			-- (from NETWORK_RESOURCE_URL)

	is_password_accepted: BOOLEAN
			-- Can a password be set?
			-- (from NETWORK_RESOURCE_URL)

	is_path_correct (p: STRING): BOOLEAN
			-- Is path name correct?

	Is_proxy_supported: BOOLEAN is True
			-- Are proxy connections supported? (Answer: yes)

	is_proxy_used: BOOLEAN
			-- Is a proxy used?
			-- (from URL)
	
feature -- Status setting

	reset_proxy
			-- Reset proxy information.
			-- (from URL)
		require -- from URL
			proxy_supported: is_proxy_supported
		ensure -- from URL
			no_proxy_set: not is_proxy_used
			port_reset: proxy_port = 0

	set_password (pw: STRING)
			-- Set password.
			-- (from NETWORK_RESOURCE_URL)
		require -- from URL
			password_accepted: is_password_accepted
			non_empty_password: pw /= void and then not pw.is_empty
		ensure then -- from NETWORK_RESOURCE_URL
			password_set: password = pw

	set_port (port_no: INTEGER)
			-- Set port to port_no.
			-- (from URL)
		require -- from URL
			port_non_negative: port_no >= 0
		ensure -- from URL
			port_set: port = port_no

	set_proxy (host: STRING; port_no: INTEGER)
			-- Set proxy host to host and proxy port to port_no.
			-- (from URL)
		require -- from URL
			proxy_supported: is_proxy_supported
			non_empty_host: host /= void and then not host.is_empty
			host_valid: proxy_host_ok (host)
			non_negative_port: port_no >= 0
		ensure -- from URL
			host_set: proxy_host = host
			port_set: proxy_port = port_no

	set_proxy_information (pi: PROXY_INFORMATION)
			-- Set proxy information to pi.
			-- (from URL)
		require -- from URL
			proxy_supported: is_proxy_supported
		ensure -- from URL
			proxy_information_set: proxy_information = pi

	set_username (un: STRING)
			-- Set username.
			-- (from NETWORK_RESOURCE_URL)
		require -- from URL
			username_ok: has_username
			non_empty_username: un /= void and then not un.is_empty
		ensure then -- from NETWORK_RESOURCE_URL
			username_set: username = un
	
invariant

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)
		-- from NETWORK_RESOURCE_URL
	path_charset_defined: path_charset /= void and then not path_charset.is_empty
	username_exists: username /= void
	password_exists: password /= void
	password_constraint: not password.is_empty implies not username.is_empty
		-- from URL
	proxy_used_definition: is_proxy_used = (proxy_information /= void)
	proxy_usage_constraint: is_proxy_used implies is_proxy_supported

end -- class FTP_URL