Skip to content

Commit 9f95186

Browse files
committed
Merge branch 'review' of https://github.com/jocelyn/CJ
Conflicts: library/converter/cj_link_json_converter.e
2 parents 3b6ed68 + aa58fd2 commit 9f95186

28 files changed

+1208
-844
lines changed

library/EIFGENs/cj/COMP/S1/E1

72.1 KB
Binary file not shown.

library/cj_collection.e

+53-20
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,83 @@
11
note
22
description: "[
3-
The Collection Object contains all the records in the representations. This is a required object.
4-
Should have a version property. The value MUST be set to 1.0, if there is no version property present
5-
set it to 1.0.
3+
The Collection Object contains all the records in the representations.
4+
This is a required object.
5+
Should have a version property.:
6+
- value MUST be set to 1.0,
7+
- if there is no version property present, set it to 1.0.
68
Should have an href property, it should contain a valid URI
79
]"
8-
author: ""
910
date: "$Date$"
1011
revision: "$Revision$"
1112
example: "[
1213
{
1314
"collection":
1415
{
15-
"version":1.0,
16-
"href":URI,
16+
"version": 1.0,
17+
"href": URI,
1718
"links": [ARRAY],
1819
"items": [ARRAY],
19-
"queries":[ARRAY],
20-
"template":{OBJECT},
21-
"error":{OBJECT}
20+
"queries": [ARRAY],
21+
"template": {OBJECT},
22+
"error": {OBJECT}
2223
}
2324
}
2425
]"
26+
EIS: "name=Collection+JSON - Hypermedia Type", "protocol=URI", "src=http://www.amundsen.com/media-types/collection/", "tag=homepage, specification"
2527

2628
class
2729
CJ_COLLECTION
2830

2931
create
30-
make
32+
make_empty,
33+
make_with_href,
34+
make_with_version,
35+
make_with_href_and_version
3136

3237
feature {NONE} -- Initialization
3338

34-
make
39+
make_empty
3540
do
36-
version := ""
37-
href := ""
41+
make_with_version (default_version)
42+
end
43+
44+
make_with_href (a_href: like href)
45+
require
46+
valid_href: not a_href.is_empty
47+
do
48+
make_with_href_and_version (a_href, default_version)
49+
end
50+
51+
make_with_href_and_version (a_href: like href; a_version: like version)
52+
require
53+
valid_version: not a_version.is_empty
54+
do
55+
version := a_version
56+
href := a_href
57+
end
58+
59+
make_with_version (a_version: like version)
60+
require
61+
valid_version: not a_version.is_empty
62+
do
63+
make_with_href_and_version (create {like href}.make_empty, a_version)
3864
end
3965

4066
feature -- Access
4167

4268
version: STRING
43-
-- The value should be set to 1.0
69+
-- The value should be set to `default_version' i.e: "1.0"
4470

4571
href: STRING
4672
-- Must contain a valid URI
4773

48-
links: detachable LINKED_LIST [CJ_LINK]
74+
links: detachable ARRAYED_LIST [CJ_LINK]
4975
-- may have a links array
5076

51-
items: detachable LINKED_LIST [CJ_ITEM]
77+
items: detachable ARRAYED_LIST [CJ_ITEM]
5278
-- may have an items array
5379

54-
queries: detachable LINKED_LIST [CJ_QUERY]
80+
queries: detachable ARRAYED_LIST [CJ_QUERY]
5581
-- may have a queries array
5682

5783
template: detachable CJ_TEMPLATE
@@ -82,7 +108,7 @@ feature -- Element Change
82108
do
83109
l_links := links
84110
if l_links = Void then
85-
create l_links.make
111+
create l_links.make (1)
86112
links := l_links
87113
end
88114
l_links.force (a_link)
@@ -94,7 +120,7 @@ feature -- Element Change
94120
do
95121
l_items := items
96122
if l_items = Void then
97-
create l_items.make
123+
create l_items.make (1)
98124
items := l_items
99125
end
100126
l_items.force (a_item)
@@ -106,7 +132,7 @@ feature -- Element Change
106132
do
107133
l_queries := queries
108134
if l_queries = Void then
109-
create l_queries.make
135+
create l_queries.make (1)
110136
queries := l_queries
111137
end
112138
l_queries.force (a_query)
@@ -122,4 +148,11 @@ feature -- Element Change
122148
error := an_error
123149
end
124150

151+
feature -- Constants
152+
153+
default_version: STRING = "1.0"
154+
155+
note
156+
copyright: "2011-2012, Javier Velilla, Jocelyn Fiat and others"
157+
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
125158
end

library/cj_collection_factory.e

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
note
2+
description: "Summary description for {CJ_COLLECTION_FACTORY}."
3+
author: ""
4+
date: "$Date$"
5+
revision: "$Revision$"
6+
7+
class
8+
CJ_COLLECTION_FACTORY
9+
10+
inherit
11+
SHARED_EJSON
12+
13+
feature -- Access
14+
15+
collection (js: STRING): detachable CJ_COLLECTION
16+
local
17+
l_classname: STRING
18+
do
19+
l_classname := ({detachable CJ_COLLECTION}).name
20+
if l_classname.item (1) = '!' then
21+
l_classname := l_classname.substring (2, l_classname.count)
22+
end
23+
if attached {like collection} json.object_from_json (js, l_classname) as obj then
24+
Result := obj
25+
end
26+
end
27+
28+
note
29+
copyright: "2011-2012, Javier Velilla, Jocelyn Fiat and others"
30+
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
31+
end

library/cj_data.e

+28-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
note
2-
description: "Data objects may have three possible properties, name(REQUIRED), value(OPTIONAL), prompt(OPTIONAL)"
3-
author: ""
2+
description: "[
3+
Data objects may have three possible properties:
4+
- name (REQUIRED)
5+
- value (OPTIONAL)
6+
- prompt (OPTIONAL)
7+
]"
48
date: "$Date$"
59
revision: "$Revision$"
610
example: "[
711
{
8-
"prompt" : STRING,
9-
"name" : STRING,
10-
"value" : VALUE
12+
"prompt" : STRING_32,
13+
"name" : STRING_32,
14+
"value" : STRING_32
1115
1216
}
1317
]"
@@ -16,46 +20,57 @@ class
1620
CJ_DATA
1721

1822
create
19-
make
23+
make,
24+
make_with_name
2025

2126
feature {NONE} -- Initialization
2227

2328
make
2429
do
25-
name := ""
30+
make_with_name (create {like name}.make_empty)
31+
end
32+
33+
make_with_name (a_name: like name)
34+
do
35+
name := a_name
2636
end
2737

2838
feature -- Access
2939

30-
name: STRING
40+
name: STRING_32
3141

32-
prompt: detachable STRING
42+
prompt: detachable STRING_32
3343

34-
value: detachable STRING
44+
value: detachable STRING_32
3545
-- this propertie May contain
3646
-- one of the following data types, STRING, NUMBER, Boolean(true,false), null
3747

3848
feature -- Element Change
3949

40-
set_name (a_name: STRING)
50+
set_name (a_name: like name)
51+
-- Set `name' to `a_name'.
4152
do
4253
name := a_name
4354
ensure
4455
name_set: name ~ a_name
4556
end
4657

47-
set_prompt (a_prompt: STRING)
58+
set_prompt (a_prompt: like prompt)
59+
-- Set `prompt' to `a_prompt'.
4860
do
4961
prompt := a_prompt
5062
ensure
5163
prompt_set: prompt ~ a_prompt
5264
end
5365

54-
set_value (a_value: STRING)
66+
set_value (a_value: like value)
5567
do
5668
value := a_value
5769
ensure
5870
value_set: value ~ a_value
5971
end
6072

73+
note
74+
copyright: "2011-2012, Javier Velilla, Jocelyn Fiat and others"
75+
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
6176
end

library/cj_document.e

-24
This file was deleted.

library/cj_error.e

+34-19
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,75 @@
11
note
22
description: "[
33
The Error object, contains aditional information on the latest error reported by the SERVER.
4-
It's an optional object, if it exist, there is only one object of this type.
4+
It's an optional object, if it exist, there is only one object of this type.
55
]"
66
author: ""
77
date: "$Date$"
88
revision: "$Revision$"
9-
example :"[
9+
example: "[
1010
{
11-
"error":
12-
{
11+
"error": {
1312
"title" : STRING,
1413
"code" : STRING,
1514
"message" : STRING
16-
}
15+
}
1716
}
1817
]"
1918

2019
class
2120
CJ_ERROR
21+
2222
create
23-
make
23+
make,
24+
make_empty
2425

2526
feature {NONE} -- Initialization
26-
make
27+
28+
make_empty
2729
do
28-
title := ""
29-
code := ""
30-
message := ""
30+
make ("", "", "")
31+
end
3132

33+
make (a_title: like title; a_code: like code; a_message: like message)
34+
do
35+
title := a_title
36+
code := a_code
37+
message := a_message
3238
end
3339

3440
feature -- Access
35-
title : STRING
36-
code : STRING
37-
message : STRING
41+
42+
title: STRING_32
43+
44+
code: STRING_32
45+
46+
message: STRING_32
3847

3948
feature -- Element Change
40-
set_title (a_title : STRING)
49+
50+
set_title (a_title: like title)
4151
do
4252
title := a_title
4353
ensure
44-
title_set : title ~ a_title
54+
title_set: title ~ a_title
4555
end
4656

47-
set_code (a_code : STRING)
57+
set_code (a_code: like code)
4858
do
4959
code := a_code
5060
ensure
51-
code_set : code ~ a_code
61+
code_set: code ~ a_code
5262
end
5363

54-
set_message (a_message : STRING)
64+
set_message (a_message: like message)
5565
do
5666
message := a_message
5767
ensure
58-
message_set : message ~ a_message
68+
message_set: message ~ a_message
5969
end
70+
71+
note
72+
copyright: "2011-2012, Javier Velilla, Jocelyn Fiat and others"
73+
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
74+
6075
end

0 commit comments

Comments
 (0)