class interface
	HTML_TABLE

create 

	make (nb_row, nb_col: INTEGER)
			-- Create a table

feature -- Initialization

	initialize (v: STRING)
			-- Make each entry have value v.
			-- (from ARRAY2)

	array2_make (nb_rows, nb_columns: INTEGER)
			-- Create a two dimensional array which has nb_rows
			-- rows and nb_columns columns,
			-- with lower bounds starting at 1.
			-- (from ARRAY2)
		require -- from ARRAY2
			not_flat: nb_rows > 0
			not_thin: nb_columns > 0
		ensure -- from ARRAY2
			new_count: count = height * width

	make_from_array (a: ARRAY [STRING])
			-- Initialize from the items of a.
			-- (Useful in proper descendants of class ARRAY,
			-- to initialize an array-like object from a manifest array.)
			-- (from ARRAY)
		require -- from ARRAY
			array_exists: a /= void
	
feature -- Access

	entry (i: INTEGER): STRING
			-- Entry at index i, if in index interval
			-- (from ARRAY)
		require -- from ARRAY
			valid_key: valid_index (i)

	has (v: STRING): BOOLEAN
			-- Does v appear in array?
			-- (Reference or object equality,
			-- based on object_comparison.)
			-- (from ARRAY)
		ensure -- from CONTAINER
			not_found_in_empty: Result implies not is_empty

	item (row, column: INTEGER): STRING
			-- Entry at coordinates (row, column)
			-- (from ARRAY2)
		require -- from ARRAY2
			valid_row: (1 <= row) and (row <= height)
			valid_column: (1 <= column) and (column <= width)

	infix "@" (i: INTEGER): STRING
			-- Entry at index i, if in index interval
			-- Was declared in ARRAY as synonym of item.
			-- (from ARRAY)
		require -- from TABLE
			valid_key: valid_index (k)
	
feature  -- Access

	area: SPECIAL [STRING]
			-- Special data zone
			-- (from TO_SPECIAL)
	
feature -- Measurement

	additional_space: INTEGER
			-- Proposed number of additional items
			-- (from RESIZABLE)
		ensure -- from RESIZABLE
			at_least_one: Result >= 1

	capacity: INTEGER
			-- Number of available indices
			-- Was declared in ARRAY as synonym of count.
			-- (from ARRAY)
		ensure then -- from ARRAY
			consistent_with_bounds: Result = upper - lower + 1

	count: INTEGER
			-- Number of available indices
			-- Was declared in ARRAY as synonym of capacity.
			-- (from ARRAY)
		ensure then -- from ARRAY
			consistent_with_bounds: Result = upper - lower + 1

	Growth_percentage: INTEGER is 50
			-- Percentage by which structure will grow automatically
			-- (from RESIZABLE)

	height: INTEGER
			-- Number of rows
			-- (from ARRAY2)

	index_set: INTEGER_INTERVAL
			-- Range of acceptable indexes
			-- (from ARRAY)
		ensure -- from INDEXABLE
			not_void: Result /= void
		ensure then -- from ARRAY
			same_count: Result.count = count
			same_bounds: ((Result.lower = lower) and (Result.upper = upper))

	lower: INTEGER
			-- Minimum index
			-- (from ARRAY)

	Minimal_increase: INTEGER is 5
			-- Minimal number of additional items
			-- (from RESIZABLE)

	occurrences (v: STRING): INTEGER
			-- Number of times v appears in structure
			-- (from ARRAY)
		ensure -- from BAG
			non_negative_occurrences: Result >= 0

	upper: INTEGER
			-- Maximum index
			-- (from ARRAY)

	width: INTEGER
			-- Number of columns
			-- (from ARRAY2)
	
feature -- Comparison

	is_equal (other: like Current): BOOLEAN
			-- Is array made of the same items as other?
			-- (from ARRAY)
		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

	all_default: BOOLEAN
			-- Are all items set to default values?
			-- (from ARRAY)
		ensure -- from ARRAY
			definition: Result = (count = 0 or else ((array_item (upper) = void or else array_item (upper) = array_item (upper).default) and subarray (lower, upper - 1).all_default))

	changeable_comparison_criterion: BOOLEAN
			-- May object_comparison be changed?
			-- (Answer: yes by default.)
			-- (from CONTAINER)

	extendible: BOOLEAN
			-- May items be added?
			-- (Answer: no, although array may be resized.)
			-- (from ARRAY)

	full: BOOLEAN
			-- Is structure filled to capacity? (Answer: yes)
			-- (from ARRAY)

	is_empty: BOOLEAN
			-- Is structure empty?
			-- (from FINITE)

	is_inserted (v: STRING): BOOLEAN
			-- Has v been inserted by the most recent insertion?
			-- (By default, the value returned is equivalent to calling
			-- `has (v)'. However, descendants might be able to provide more
			-- efficient implementations.)
			-- (from COLLECTION)

	object_comparison: BOOLEAN
			-- Must search operations use equal rather than =
			-- for comparing references? (Default: no, use =.)
			-- (from CONTAINER)

	prunable: BOOLEAN
			-- May items be removed? (Answer: no.)
			-- (from ARRAY)

	resizable: BOOLEAN
			-- May capacity be changed? (Answer: yes.)
			-- (from RESIZABLE)

	same_items (other: like Current): BOOLEAN
			-- Do other and Current have same items?
			-- (from ARRAY)
		require -- from ARRAY
			other_not_void: other /= void
		ensure -- from ARRAY
			definition: Result = ((count = other.count) and then (count = 0 or else (array_item (upper) = other.array_item (other.upper) and subarray (lower, upper - 1).same_items (other.subarray (other.lower, other.upper - 1)))))

	valid_index (i: INTEGER): BOOLEAN
			-- Is i within the bounds of the array?
			-- (from ARRAY)
		ensure then -- from INDEXABLE
			only_if_in_index_set: Result implies ((i >= index_set.lower) and (i <= index_set.upper))

	valid_index_set: BOOLEAN
			-- (from ARRAY)
	
feature -- Status setting

	compare_objects
			-- Ensure that future search operations will use equal
			-- rather than = for comparing references.
			-- (from CONTAINER)
		require -- from CONTAINER
			changeable_comparison_criterion
		ensure -- from CONTAINER
			object_comparison

	compare_references
			-- Ensure that future search operations will use =
			-- rather than equal for comparing references.
			-- (from CONTAINER)
		require -- from CONTAINER
			changeable_comparison_criterion
		ensure -- from CONTAINER
			reference_comparison: not object_comparison
	
feature -- Element change

	enter (v: like array_item; i: INTEGER)
			-- Replace i-th entry, if in index interval, by v.
			-- (from ARRAY)
		require -- from ARRAY
			valid_key: valid_index (i)

	fill (other: CONTAINER [STRING])
			-- Fill with as many items of other as possible.
			-- The representations of other and current structure
			-- need not be the same.
			-- (from COLLECTION)
		require -- from COLLECTION
			other_not_void: other /= void
			extendible

	force (v: like item; row, column: INTEGER)
			-- Assign item v at coordinates (row, column).
			-- Resize if necessary.
			-- (from ARRAY2)
		require -- from ARRAY2
			row_large_enough: 1 <= row
			column_large_enough: 1 <= column

	put (v: like item; row, column: INTEGER)
			-- Assign item v at coordinates (row, column).
			-- (from ARRAY2)
		require -- from ARRAY2
			valid_row: 1 <= row and row <= height
			valid_column: 1 <= column and column <= width

	subcopy (other: like Current; start_pos, end_pos, index_pos: INTEGER)
			-- Copy items of other within bounds start_pos and end_pos
			-- to current array starting at index index_pos.
			-- (from ARRAY)
		require -- from ARRAY
			other_not_void: other /= void
			valid_start_pos: other.valid_index (start_pos)
			valid_end_pos: other.valid_index (end_pos)
			valid_bounds: (start_pos <= end_pos) or (start_pos = end_pos + 1)
			valid_index_pos: valid_index (index_pos)
			enough_space: (upper - index_pos) >= (end_pos - start_pos)
	
feature -- Removal

	clear_all
			-- Reset all items to default values.
			-- (from ARRAY)
		ensure -- from ARRAY
			stable_lower: lower = old lower
			stable_upper: upper = old upper
			default_items: all_default

	discard_items
			-- Reset all items to default values with reallocation.
			-- (from ARRAY)
		ensure -- from ARRAY
			default_items: all_default

	prune_all (v: STRING)
			-- Remove all occurrences of v.
			-- (Reference or object equality,
			-- based on object_comparison.)
			-- (from COLLECTION)
		require -- from COLLECTION
			prunable
		ensure -- from COLLECTION
			no_more_occurrences: not has (v)

	wipe_out
			-- Remove all items.
			-- (from ARRAY2)
	
feature -- Resizing

	automatic_grow
			-- Change the capacity to accommodate at least
			-- Growth_percentage more items.
			-- (from RESIZABLE)
		ensure -- from RESIZABLE
			increased_capacity: capacity >= old capacity + old capacity * growth_percentage // 100

	grow (i: INTEGER)
			-- Change the capacity to at least i.
			-- (from ARRAY)
		ensure -- from RESIZABLE
			new_capacity: capacity >= i

	resize (nb_rows, nb_columns: INTEGER)
			-- Rearrange array so that it can accommodate
			-- nb_rows rows and nb_columns columns,
			-- without losing any previously
			-- entered items, nor changing their coordinates;
			-- do nothing if not possible.
			-- (from ARRAY2)
		require -- from ARRAY2
			valid_row: nb_rows >= 1
			valid_column: nb_columns >= 1
	
feature  -- Conversion

	to_c: ANY
			-- Address of actual sequence of values,
			-- for passing to external (non-Eiffel) routines.
			-- (from ARRAY)
	
feature -- Conversion

	linear_representation: LINEAR [STRING]
			-- Representation as a linear structure
			-- (from ARRAY)
	
feature -- Duplication

	copy (other: like Current)
			-- Reinitialize by copying all the items of other.
			-- (This is also used by clone.)
			-- (from ARRAY)
		require -- from ANY
			other_not_void: other /= void
			type_identity: same_type (other)
		ensure -- from ANY
			is_equal: is_equal (other)
		ensure then -- from ARRAY
			equal_areas: area.is_equal (other.area)

	subarray (start_pos, end_pos: INTEGER): like Current
			-- Array made of items of current array within
			-- bounds start_pos and end_pos.
			-- (from ARRAY)
		require -- from ARRAY
			valid_start_pos: valid_index (start_pos)
			valid_end_pos: valid_index (end_pos)
			valid_bounds: (start_pos <= end_pos) or (start_pos = end_pos + 1)
		ensure -- from ARRAY
			lower: Result.lower = start_pos
			upper: Result.upper = end_pos
	
feature 

	Align: STRING is " ALIGN="
			-- (from HTML_TABLE_CONSTANTS)

	Background: STRING is " BACKGROUND="
			-- (from HTML_TABLE_CONSTANTS)

	Bgcolor: STRING is " BGCOLOR="
			-- (from HTML_TABLE_CONSTANTS)

	Border: STRING is " BORDER="
			-- (from HTML_TABLE_CONSTANTS)

	Bordercolor: STRING is " BORDERCOLOR="
			-- (from HTML_TABLE_CONSTANTS)

	Bordercolordark: STRING is " BORDERCOLORDARK="
			-- (from HTML_TABLE_CONSTANTS)

	Bordercolorlight: STRING is " BORDERCOLORLIGHT="
			-- (from HTML_TABLE_CONSTANTS)

	Bottom: STRING is "BOTTOM"
			-- (from HTML_TABLE_CONSTANTS)

	Caption_end: STRING is "</CAPTION>"
			-- (from HTML_TABLE_CONSTANTS)

	Caption_start: STRING is "<CAPTION"
			-- (from HTML_TABLE_CONSTANTS)

	Center: STRING is "CENTER"
			-- (from HTML_TABLE_CONSTANTS)

	Col_end: STRING is "</TD>"
			-- (from HTML_TABLE_CONSTANTS)

	Col_start: STRING is "<TD"
			-- (from HTML_TABLE_CONSTANTS)

	Colspan: STRING is " COLSPAN="
			-- (from HTML_TABLE_CONSTANTS)

	Left: STRING is "LEFT"
			-- (from HTML_TABLE_CONSTANTS)

	make (nb_row, nb_col: INTEGER)
			-- Create a table

	Newline: STRING is ""
			-- (from HTML_TABLE_CONSTANTS)

	Nowrap: STRING is " NOWRAP"
			-- (from HTML_TABLE_CONSTANTS)

	Right: STRING is "RIGHT"
			-- (from HTML_TABLE_CONSTANTS)

	Row_end: STRING is "</TR>"
			-- (from HTML_TABLE_CONSTANTS)

	Row_start: STRING is "<TR"
			-- (from HTML_TABLE_CONSTANTS)

	Rowspan: STRING is " ROWSPAN="
			-- (from HTML_TABLE_CONSTANTS)

	Table_end: STRING is "</TABLE>"
			-- (from HTML_TABLE_CONSTANTS)

	Table_start: STRING is "<TABLE"
			-- (from HTML_TABLE_CONSTANTS)

	Tag_end: STRING is ">"
			-- (from HTML_TABLE_CONSTANTS)

	Tag_start: STRING is "<"
			-- (from HTML_TABLE_CONSTANTS)

	Top: STRING is "TOP"
			-- (from HTML_TABLE_CONSTANTS)

	Valign: STRING is " VALIGN="
			-- (from HTML_TABLE_CONSTANTS)

	Table_width: STRING is " WIDTH="
			-- (from HTML_TABLE_CONSTANTS)
	
feature -- Attributes

	border_value: INTEGER

	caption: STRING

	col_value: INTEGER

	row_value: INTEGER
	
feature -- Inputs in the table

	add_col (a_row: ARRAY [STRING])
			-- Add a col in the table and update the current col
		require
			a_row /= void
			col_value <= width

	add_row (a_row: ARRAY [STRING])
			-- Add a row in the table and update the current row
		require
			a_row /= void
			row_value <= height

	put_col (a_row: ARRAY [STRING])
			-- Put a col (of STRING) in the table in the current col
		require
			a_row /= void
			col_value <= width

	put_row (a_row: ARRAY [STRING])
			-- Put a row (of STRING) in the table in the current row
		require
			a_row /= void
			row_value <= height
	
feature -- Routines out: provide STRING representations

	attribute_out (an_attribute, its_value: STRING): STRING
			-- String representation for the pair 'an_attribute' and 'its_value'

	attributes_out: STRING
			-- String representation for the attributes
			-- of the table

	body_out: STRING

	caption_attributes_out: STRING
			-- String representation for the attributes
			-- of the caption

	caption_out: STRING
			-- String representation for the caption

	col_attributes_out (row, col: INTEGER): STRING
			-- String representation for the attributes
			-- of the cell '(row, col)'
			-- Modify 'col_value'
		require
			row <= height
			col <= width

	out: STRING
			-- Provide a STRING representation for the current table

	row_attributes_out (row, col: INTEGER): STRING
			-- String representation for the attributes
			-- of the row 'row'
			-- Modify 'row_value'
		require
			row <= height
	
feature -- Set attributes

	set_border (n: INTEGER)
			-- Set the attribute 'BORDER' of the table to 'n'

	set_caption (s: STRING)
			-- Set the caption element

	set_caption_to_bottom
			-- Set the caption to be displayed on the bottom of the table

	set_caption_to_top
			-- Set the caption to be displayed on the top of the table

	set_col (n: INTEGER)
			-- Set the current working value for col to 'n'

	set_row (n: INTEGER)
			-- Set the current working value for row to 'n'
	
invariant

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)
		-- from ARRAY2
	items_number: count = width * height
		-- from ARRAY
	area_exists: area /= void
	consistent_size: capacity = upper - lower + 1
	non_negative_count: count >= 0
	index_set_has_same_count: valid_index_set
		-- from RESIZABLE
	increase_by_at_least_one: minimal_increase >= 1
		-- from BOUNDED
	valid_count: count <= capacity
	full_definition: full = (count = capacity)
		-- from FINITE
	empty_definition: is_empty = (count = 0)
	non_negative_count: count >= 0
		-- from INDEXABLE
	index_set_not_void: index_set /= void

end -- class HTML_TABLE