Skip to content

Commit b0fa87d

Browse files
committed
Added subtree merged in lib/cj
2 parents 50a5e81 + be76a05 commit b0fa87d

34 files changed

+2553
-0
lines changed

lib/CJ/README

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Eiffel CJ is a library to work with Collection+JSON - Hypermedia Type, http://www.amundsen.com/media-types/collection/
2+
3+
The current CJ implementation does not implement the [extensions][1] proposals,
4+
The google group is here [discussion group][2]
5+
6+
[1]: https://github.com/mamund/collection-json/tree/master/extensions "extensions"
7+
[2]: https://groups.google.com/forum/?fromgroups#!forum/collectionjson "discussion group"

lib/CJ/doc/collectionjson.png

33.2 KB
Loading

lib/CJ/library/CollectionJSON.ecf

+18
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>

lib/CJ/library/cj-safe.ecf

+18
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>

lib/CJ/library/cj_collection.e

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
note
2+
description: "[
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.
8+
Should have an href property, it should contain a valid URI
9+
]"
10+
date: "$Date$"
11+
revision: "$Revision$"
12+
example: "[
13+
{
14+
"collection":
15+
{
16+
"version": 1.0,
17+
"href": URI,
18+
"links": [ARRAY],
19+
"items": [ARRAY],
20+
"queries": [ARRAY],
21+
"template": {OBJECT},
22+
"error": {OBJECT}
23+
}
24+
}
25+
]"
26+
EIS: "name=Collection+JSON - Hypermedia Type", "protocol=URI", "src=http://www.amundsen.com/media-types/collection/", "tag=homepage, specification"
27+
28+
class
29+
CJ_COLLECTION
30+
31+
create
32+
make_empty,
33+
make_with_href,
34+
make_with_version,
35+
make_with_href_and_version
36+
37+
feature {NONE} -- Initialization
38+
39+
make_empty
40+
do
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)
64+
end
65+
66+
feature -- Access
67+
68+
version: STRING
69+
-- The value should be set to `default_version' i.e: "1.0"
70+
71+
href: STRING
72+
-- Must contain a valid URI
73+
74+
links: detachable ARRAYED_LIST [CJ_LINK]
75+
-- may have a links array
76+
77+
items: detachable ARRAYED_LIST [CJ_ITEM]
78+
-- may have an items array
79+
80+
queries: detachable ARRAYED_LIST [CJ_QUERY]
81+
-- may have a queries array
82+
83+
template: detachable CJ_TEMPLATE
84+
-- may have a template object
85+
86+
error: detachable CJ_ERROR
87+
-- may have an error object
88+
89+
feature -- Element Change
90+
91+
set_version (a_version: STRING)
92+
do
93+
version := a_version
94+
ensure
95+
version_set: version ~ a_version
96+
end
97+
98+
set_href (a_href: STRING)
99+
do
100+
href := a_href
101+
ensure
102+
href_set: href ~ a_href
103+
end
104+
105+
add_link (a_link: CJ_LINK)
106+
local
107+
l_links: like links
108+
do
109+
l_links := links
110+
if l_links = Void then
111+
create l_links.make (1)
112+
links := l_links
113+
end
114+
l_links.force (a_link)
115+
end
116+
117+
add_item (a_item: CJ_ITEM)
118+
local
119+
l_items: like items
120+
do
121+
l_items := items
122+
if l_items = Void then
123+
create l_items.make (1)
124+
items := l_items
125+
end
126+
l_items.force (a_item)
127+
end
128+
129+
add_query (a_query: CJ_QUERY)
130+
local
131+
l_queries: like queries
132+
do
133+
l_queries := queries
134+
if l_queries = Void then
135+
create l_queries.make (1)
136+
queries := l_queries
137+
end
138+
l_queries.force (a_query)
139+
end
140+
141+
set_template (a_template: CJ_TEMPLATE)
142+
do
143+
template := a_template
144+
end
145+
146+
set_error (an_error: CJ_ERROR)
147+
do
148+
error := an_error
149+
end
150+
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)"
158+
end
+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

lib/CJ/library/cj_data.e

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
note
2+
description: "[
3+
Data objects may have three possible properties:
4+
- name (REQUIRED)
5+
- value (OPTIONAL)
6+
- prompt (OPTIONAL)
7+
]"
8+
date: "$Date$"
9+
revision: "$Revision$"
10+
example: "[
11+
{
12+
"prompt" : STRING_32,
13+
"name" : STRING_32,
14+
"value" : STRING_32
15+
16+
}
17+
]"
18+
19+
class
20+
CJ_DATA
21+
22+
create
23+
make,
24+
make_with_name
25+
26+
feature {NONE} -- Initialization
27+
28+
make
29+
do
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
36+
end
37+
38+
feature -- Access
39+
40+
name: STRING_32
41+
42+
prompt: detachable STRING_32
43+
44+
value: detachable STRING_32
45+
-- this propertie May contain
46+
-- one of the following data types, STRING, NUMBER, Boolean(true,false), null
47+
48+
feature -- Element Change
49+
50+
set_name (a_name: like name)
51+
-- Set `name' to `a_name'.
52+
do
53+
name := a_name
54+
ensure
55+
name_set: name ~ a_name
56+
end
57+
58+
set_prompt (a_prompt: like prompt)
59+
-- Set `prompt' to `a_prompt'.
60+
do
61+
prompt := a_prompt
62+
ensure
63+
prompt_set: prompt ~ a_prompt
64+
end
65+
66+
set_value (a_value: like value)
67+
do
68+
value := a_value
69+
ensure
70+
value_set: value ~ a_value
71+
end
72+
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)"
76+
end

lib/CJ/library/cj_error.e

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
note
2+
description: "[
3+
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.
5+
]"
6+
author: ""
7+
date: "$Date$"
8+
revision: "$Revision$"
9+
example: "[
10+
{
11+
"error": {
12+
"title" : STRING,
13+
"code" : STRING,
14+
"message" : STRING
15+
}
16+
}
17+
]"
18+
19+
class
20+
CJ_ERROR
21+
22+
create
23+
make,
24+
make_empty
25+
26+
feature {NONE} -- Initialization
27+
28+
make_empty
29+
do
30+
make ("", "", "")
31+
end
32+
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
38+
end
39+
40+
feature -- Access
41+
42+
title: STRING_32
43+
44+
code: STRING_32
45+
46+
message: STRING_32
47+
48+
feature -- Element Change
49+
50+
set_title (a_title: like title)
51+
do
52+
title := a_title
53+
ensure
54+
title_set: title ~ a_title
55+
end
56+
57+
set_code (a_code: like code)
58+
do
59+
code := a_code
60+
ensure
61+
code_set: code ~ a_code
62+
end
63+
64+
set_message (a_message: like message)
65+
do
66+
message := a_message
67+
ensure
68+
message_set: message ~ a_message
69+
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+
75+
end

0 commit comments

Comments
 (0)