Adopted convention name and value or values for WSF_VALUE and descendant (WSF_STRING ...)

kept `key' as redirection, and also string as obsolete redirection.
Router: provide a way to pass the request methods without using manifest string, thanks to WSF_ROUTER_METHODS
  so instead of using manifest array or manifest strings, just create an instance of WSF_ROUTER_METHODS
  for convenience, WSF_ROUTER provides a few `methods_...' returning prebuilt WSF_ROUTER_METHODS objects
Improved code related to unicode handling in URL, and parameters (before the framework was doing too much)
This commit is contained in:
Jocelyn Fiat
2012-06-11 14:58:13 +02:00
parent 36ed6f525c
commit 8a58d62a7e
29 changed files with 790 additions and 198 deletions

View File

@@ -1,6 +1,7 @@
note
description: "Summary description for {WSF_ANY}."
author: ""
description: "[
{WSF_ANY} represents a parameter holding any object.
]"
date: "$Date$"
revision: "$Revision$"
@@ -15,11 +16,11 @@ create
feature {NONE} -- Initialization
make (a_name: READABLE_STRING_8; a_value: like item)
make (a_name: READABLE_STRING_8; a_value: like value)
do
name := url_decoded_string (a_name)
url_encoded_name := a_name
item := a_value
value := a_value
end
feature -- Access
@@ -28,7 +29,7 @@ feature -- Access
url_encoded_name: READABLE_STRING_8
item: detachable ANY
value: detachable ANY
feature -- Element change
@@ -50,8 +51,8 @@ feature -- Query
-- String representation of Current
-- if possible
do
if attached item as i then
Result := i.generating_type
if attached value as v then
Result := v.generating_type
else
Result := "Void"
end

View File

@@ -1,6 +1,7 @@
note
description: "Summary description for {WSF_MULTIPLE_STRING}."
author: ""
description: "[
{WSF_MULTIPLE_STRING} represents a sequence of name=value parameters
]"
date: "$Date$"
revision: "$Revision$"
@@ -25,7 +26,7 @@ feature {NONE} -- Initialization
make_with_value (a_value: WSF_VALUE)
do
name := a_value.name
create {LINKED_LIST [WSF_STRING]} string_values.make
create {LINKED_LIST [WSF_STRING]} values.make
add_value (a_value)
end
@@ -58,11 +59,25 @@ feature -- Access
name: READABLE_STRING_32
string_values: LIST [WSF_STRING]
values: LIST [WSF_STRING]
first_string_value: WSF_STRING
frozen string_values: like values
obsolete
"Use `values' [2012-May-31]"
do
Result := string_values.first
Result := values
end
first_value: WSF_STRING
do
Result := values.first
end
frozen first_string_value: WSF_STRING
obsolete
"Use `first_value' [2012-May-31]"
do
Result := first_value
end
feature -- Element change
@@ -79,15 +94,15 @@ feature -- Status report
is_string: BOOLEAN
-- Is Current as a WSF_STRING representation?
do
Result := string_values.count = 1
Result := values.count = 1
end
feature -- Conversion
as_string: WSF_STRING
do
if string_values.count = 1 then
Result := first_string_value
if values.count = 1 then
Result := first_value
else
Result := Precursor
end
@@ -97,19 +112,19 @@ feature -- Traversing
new_cursor: ITERATION_CURSOR [WSF_STRING]
do
Result := string_values.new_cursor
Result := values.new_cursor
end
feature -- Helper
string_representation: STRING_32
do
if string_values.count = 1 then
create Result.make_from_string (first_string_value)
if values.count = 1 then
create Result.make_from_string (first_value)
else
create Result.make_from_string ("[")
across
string_values as c
values as c
loop
if Result.count > 1 then
Result.append_character (',')
@@ -139,7 +154,7 @@ feature -- Element change
add_string_value (s: WSF_STRING)
do
string_values.extend (s)
values.extend (s)
end
feature -- Visitor
@@ -150,7 +165,7 @@ feature -- Visitor
end
invariant
string_values_not_empty: string_values.count >= 1
string_values_not_empty: values.count >= 1
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"

View File

@@ -1,6 +1,7 @@
note
description: "Summary description for {WSF_STRING}."
author: ""
description: "[
{WSF_STRING} represents a String parameter
]"
date: "$Date$"
revision: "$Revision$"
@@ -25,21 +26,70 @@ feature {NONE} -- Initialization
make (a_name: READABLE_STRING_8; a_string: READABLE_STRING_8)
do
name := url_decoded_string (a_name)
string := url_decoded_string (a_string)
value := url_decoded_string (a_string)
url_encoded_name := a_name
url_encoded_string := a_string
url_encoded_value := a_string
end
feature -- Access
name: READABLE_STRING_32
-- <Precursor>
--| Note that the value might be html encoded as well
--| this is the application responsibility to html decode it
string: READABLE_STRING_32
value: READABLE_STRING_32
-- <Precursor>
--| Note that the value might be html encoded as well
--| this is the application responsibility to html decode it
url_encoded_name: READABLE_STRING_8
-- URL encoded string of `name'.
url_encoded_string: READABLE_STRING_8
url_encoded_value: READABLE_STRING_8
-- URL encoded string of `value'.
frozen string: like value
obsolete
"Use value [2012-May-31]"
do
Result := value
end
frozen url_encoded_string: like url_encoded_value
obsolete
"Use url_encoded_value [2012-May-31]"
do
Result := url_encoded_value
end
feature -- Conversion
integer_value: INTEGER
-- Integer value of `value'.
require
value_is_integer: is_integer
do
Result := value.to_integer
end
feature -- Status report
is_string: BOOLEAN = True
-- Is Current as a WSF_STRING representation?
is_empty: BOOLEAN
-- Is empty?
do
Result := value.is_empty
end
is_integer: BOOLEAN
-- Is `value' an integer?
do
Result := value.is_integer
end
feature -- Element change
@@ -51,31 +101,20 @@ feature -- Element change
a_name.same_string (url_encoded_name)
end
feature -- Status report
is_string: BOOLEAN = True
-- Is Current as a WSF_STRING representation?
is_empty: BOOLEAN
-- Is empty?
do
Result := string.is_empty
end
feature -- Helper
same_string (a_other: READABLE_STRING_GENERAL): BOOLEAN
-- Does `a_other' represent the same string as `Current'?
do
Result := string.same_string_general (a_other)
Result := value.same_string_general (a_other)
end
is_case_insensitive_equal (a_other: READABLE_STRING_8): BOOLEAN
-- Does `a_other' represent the same case insensitive string as `Current'?
local
v: like string
v: like value
do
v := string
v := value
if v = a_other then
Result := True
elseif v.is_valid_as_string_8 then
@@ -87,26 +126,7 @@ feature -- Conversion
string_representation: STRING_32
do
create Result.make_from_string (string)
end
html_encoded_name: READABLE_STRING_8
-- HTML encoded string `name'
do
Result := (create {HTML_ENCODER}).encoded_string (name)
end
html_encoded_string: READABLE_STRING_8
-- HTML encoded string `string'
do
Result := (create {HTML_ENCODER}).encoded_string (string)
end
feature {NONE} -- Conversion
html_decoded_string (s: READABLE_STRING_GENERAL): READABLE_STRING_32
do
Result := (create {HTML_ENCODER}).general_decoded_string (s)
create Result.make_from_string (value)
end
feature -- Visitor

View File

@@ -47,7 +47,7 @@ feature -- Access
end
end
first_key: detachable READABLE_STRING_32
first_name: detachable READABLE_STRING_32
do
across
values as c
@@ -70,6 +70,13 @@ feature -- Access
Result := values.count
end
frozen first_key: like first_name
obsolete
"Use first_name [2012-May-31]"
do
Result := first_name
end
feature -- Element change
change_name (a_name: like name)
@@ -122,7 +129,7 @@ feature -- Helper
string_representation: STRING_32
do
create Result.make_from_string ("{")
if values.count = 1 and then attached first_key as fk then
if values.count = 1 and then attached first_name as fk then
Result.append (fk + ": ")
if attached value (fk) as fv then
Result.append (fv.string_representation)

View File

@@ -1,6 +1,7 @@
note
description: "Summary description for {WSF_UPLOADED_FILE}."
author: ""
description: "[
{WSF_UPLOADED_FILE} represents an uploaded file from form parameters.
]"
date: "$Date$"
revision: "$Revision$"
@@ -40,13 +41,11 @@ feature -- Element change
a_name.same_string (url_encoded_name)
end
feature -- Status report
is_string: BOOLEAN = False
-- Is Current as a WSF_STRING representation?
feature -- Conversion
string_representation: STRING_32