Skip to content

Commit 7bcdb4f

Browse files
committed
Initial CJ Hypermedia library commit
0 parents  commit 7bcdb4f

35 files changed

+2301
-0
lines changed

README

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Eiffel CJ is a library to work with Collection+JSON - Hypermedia Type, http://www.amundsen.com/media-types/collection/
2+

doc/collectionjson.png

33.2 KB
Loading

library/CollectionJSON.ecf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="ISO-8859-1"?>
2+
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="CollectionJSON" uuid="94C384A6-8CAD-48C2-B448-EFA81264AFFD" library_target="CollectionJSON">
3+
<target name="CollectionJSON">
4+
<root all_classes="true"/>
5+
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
6+
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
7+
</option>
8+
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
9+
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf"/>
10+
<cluster name="CollectionJSON" location=".\" recursive="true">
11+
<file_rule>
12+
<exclude>/EIFGENs$</exclude>
13+
<exclude>/CVS$</exclude>
14+
<exclude>/.svn$</exclude>
15+
</file_rule>
16+
</cluster>
17+
</target>
18+
</system>

library/cj-safe.ecf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="ISO-8859-1"?>
2+
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="CJ" uuid="94C384A6-8CAD-48C2-B448-EFA81264AFFD" library_target="CJ">
3+
<target name="CJ">
4+
<root all_classes="true"/>
5+
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
6+
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
7+
</option>
8+
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
9+
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf"/>
10+
<cluster name="CJ" location=".\" recursive="true">
11+
<file_rule>
12+
<exclude>/EIFGENs$</exclude>
13+
<exclude>/CVS$</exclude>
14+
<exclude>/.svn$</exclude>
15+
</file_rule>
16+
</cluster>
17+
</target>
18+
</system>

library/cj_collection.e

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
note
2+
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.
6+
Should have an href property, it should contain a valid URI
7+
]"
8+
author: ""
9+
date: "$Date$"
10+
revision: "$Revision$"
11+
example: "[
12+
{
13+
"collection":
14+
{
15+
"version":1.0,
16+
"href":URI,
17+
"links": [ARRAY],
18+
"items": [ARRAY],
19+
"queries":[ARRAY],
20+
"template":{OBJECT},
21+
"error":{OBJECT}
22+
}
23+
}
24+
]"
25+
26+
class
27+
CJ_COLLECTION
28+
29+
create
30+
make
31+
32+
feature {NONE} -- Initialization
33+
34+
make
35+
do
36+
version := ""
37+
href := ""
38+
end
39+
40+
feature -- Access
41+
42+
version: STRING
43+
-- The value should be set to 1.0
44+
45+
href: STRING
46+
-- Must contain a valid URI
47+
48+
links: detachable LINKED_LIST [CJ_LINK]
49+
-- may have a links array
50+
51+
items: detachable LINKED_LIST [CJ_ITEM]
52+
-- may have an items array
53+
54+
queries: detachable LINKED_LIST [CJ_QUERY]
55+
-- may have a queries array
56+
57+
template: detachable CJ_TEMPLATE
58+
-- may have a template object
59+
60+
error: detachable CJ_ERROR
61+
-- may have an error object
62+
63+
feature -- Element Change
64+
65+
set_version (a_version: STRING)
66+
do
67+
version := a_version
68+
ensure
69+
version_set: version ~ a_version
70+
end
71+
72+
set_href (a_href: STRING)
73+
do
74+
href := a_href
75+
ensure
76+
href_set: href ~ a_href
77+
end
78+
79+
add_link (a_link: CJ_LINK)
80+
local
81+
l_links: like links
82+
do
83+
l_links := links
84+
if l_links = Void then
85+
create l_links.make
86+
links := l_links
87+
end
88+
l_links.force (a_link)
89+
end
90+
91+
add_item (a_item: CJ_ITEM)
92+
local
93+
l_items: like items
94+
do
95+
l_items := items
96+
if l_items = Void then
97+
create l_items.make
98+
items := l_items
99+
end
100+
l_items.force (a_item)
101+
end
102+
103+
add_query (a_query: CJ_QUERY)
104+
local
105+
l_queries: like queries
106+
do
107+
l_queries := queries
108+
if l_queries = Void then
109+
create l_queries.make
110+
queries := l_queries
111+
end
112+
l_queries.force (a_query)
113+
end
114+
115+
set_template (a_template: CJ_TEMPLATE)
116+
do
117+
template := a_template
118+
end
119+
120+
set_error (an_error: CJ_ERROR)
121+
do
122+
error := an_error
123+
end
124+
125+
end

library/cj_collection.e.pretty

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
note
2+
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.
6+
Should have an href property, it should contain a valid URI
7+
]"
8+
author: ""
9+
date: "$Date$"
10+
revision: "$Revision$"
11+
example: "[
12+
{
13+
"collection":
14+
{
15+
"version":1.0,
16+
"href":URI,
17+
"links": [ARRAY],
18+
"items": [ARRAY],
19+
"queries":[ARRAY],
20+
"template":{OBJECT},
21+
"error":{OBJECT}
22+
}
23+
}
24+
]"
25+
26+
class
27+
CJ_COLLECTION
28+
29+
create
30+
make
31+
32+
feature {NONE} -- Initialization
33+
34+
make
35+
do
36+
version := ""
37+
href := ""
38+
end
39+
40+
feature -- Access
41+
42+
version: STRING
43+
-- The value should be set to 1.0
44+
45+
href: STRING
46+
-- Must contain a valid URI
47+
48+
links: detachable LINKED_LIST [CJ_LINK]
49+
-- may have a links array
50+
51+
items: detachable LINKED_LIST [CJ_ITEM]
52+
-- may have an items array
53+
54+
queries: detachable LINKED_LIST [CJ_QUERY]
55+
-- may have a queries array
56+
57+
template: detachable CJ_TEMPLATE
58+
-- may have a template object
59+
60+
error: detachable CJ_ERROR
61+
-- may have an error object
62+
63+
feature -- Element Change
64+
65+
set_version (a_version: STRING)
66+
do
67+
version := a_version
68+
ensure
69+
version_set: version ~ a_version
70+
end
71+
72+
set_href (a_href: STRING)
73+
do
74+
href := a_href
75+
ensure
76+
href_set: href ~ a_href
77+
end
78+
79+
add_link (a_link: CJ_LINK)
80+
local
81+
l_links: like links
82+
do
83+
l_links := links
84+
if l_links = Void then
85+
create l_links.make
86+
links := l_links
87+
end
88+
l_links.force (a_link)
89+
end
90+
91+
add_item (a_item: CJ_ITEM)
92+
local
93+
l_items: like items
94+
do
95+
l_items := items
96+
if l_items = Void then
97+
create l_items.make
98+
items := l_items
99+
end
100+
l_items.force (a_item)
101+
end
102+
103+
add_query (a_query: CJ_QUERY)
104+
local
105+
l_queries: like queries
106+
do
107+
l_queries := queries
108+
if l_queries = Void then
109+
create l_queries.make
110+
queries := l_queries
111+
end
112+
l_queries.force (a_query)
113+
end
114+
115+
set_template (a_template: CJ_TEMPLATE)
116+
do
117+
template := a_template
118+
end
119+
120+
set_error (an_error: CJ_ERROR)
121+
do
122+
error := an_error
123+
end
124+
125+
end

library/cj_data.e

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
note
2+
description: "Data objects may have three possible properties, name(REQUIRED), value(OPTIONAL), prompt(OPTIONAL)"
3+
author: ""
4+
date: "$Date$"
5+
revision: "$Revision$"
6+
example: "[
7+
{
8+
"prompt" : STRING,
9+
"name" : STRING,
10+
"value" : VALUE
11+
12+
}
13+
]"
14+
15+
class
16+
CJ_DATA
17+
18+
create
19+
make
20+
21+
feature {NONE} -- Initialization
22+
23+
make
24+
do
25+
name := ""
26+
end
27+
28+
feature -- Access
29+
30+
name: STRING
31+
32+
prompt: detachable STRING
33+
34+
value: detachable STRING
35+
-- this propertie May contain
36+
-- one of the following data types, STRING, NUMBER, Boolean(true,false), null
37+
38+
feature -- Element Change
39+
40+
set_name (a_name: STRING)
41+
do
42+
name := a_name
43+
ensure
44+
name_set: name ~ a_name
45+
end
46+
47+
set_prompt (a_prompt: STRING)
48+
do
49+
prompt := a_prompt
50+
ensure
51+
prompt_set: prompt ~ a_prompt
52+
end
53+
54+
set_value (a_value: STRING)
55+
do
56+
value := a_value
57+
ensure
58+
value_set: value ~ a_value
59+
end
60+
61+
end

0 commit comments

Comments
 (0)