xitiomet / placebohttp (http://openstatic.org/)
Embeded Http server for gcj/java applications. PlaceboHttp uses an automatic session management system, Treating each session as a HttpRequest queue.
| commit 25: | 964b652115d9 |
| parent 24: | d850df8938b6 |
| branch: | default |
Fixed json stuff again
Changed (Δ1.4 KB):
raw changeset »
Makefile (29 lines added, 2 lines removed)
src/org/openstatic/util/JSONUtil.java (24 lines added, 16 lines removed)
| … | … | @@ -14,7 +14,7 @@ all: placebohttp |
14 |
14 |
# Alternate build using the java vm |
15 |
15 |
jvm: |
16 |
16 |
mkdir jvm-build |
17 |
$(JAVAC) src/*.java src/org/ |
|
17 |
$(JAVAC) src/*.java src/org/json/*.java src/org/openstatic/http/*.java src/org/openstatic/util/*.java src/org/openstatic/placebo/*.java -d jvm-build |
|
18 |
18 |
$(JAR) -cvmf manifest.mf placebohttp.jar -C jvm-build org -C jvm-build PlaceboBase.class www |
19 |
19 |
|
20 |
20 |
# Executable Rule for GCJ |
| … | … | @@ -53,10 +53,37 @@ build/org/openstatic/placebo/CoreServer. |
53 |
53 |
build/org/openstatic/util/JTextAreaOutputStream.class: src/org/openstatic/util/JTextAreaOutputStream.java |
54 |
54 |
$(JC) $(JC_FLAGS) --classpath=$(CLASS_PATH) -C $< |
55 |
55 |
|
56 |
build/org/openstatic/util/JSONUtil.class: src/org/openstatic/util/JSONUtil.java build/org/json/JSONObject.class build/org/json/JSONArray.class |
|
57 |
$(JC) $(JC_FLAGS) --classpath=$(CLASS_PATH) -C $< |
|
58 |
||
59 |
# Org.JSON |
|
60 |
||
61 |
build/org/json/JSONArray.class: src/org/json/JSONArray.java build/org/json/JSONObject.class |
|
62 |
$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $< |
|
63 |
||
64 |
build/org/json/JSONException.class: src/org/json/JSONException.java |
|
65 |
$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $< |
|
66 |
||
67 |
build/org/json/JSONObject.class: src/org/json/JSONObject.java build/org/json/JSONException.class build/org/json/JSONTokener.class build/org/json/JSONString.class |
|
68 |
$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $< |
|
69 |
||
70 |
build/org/json/JSONString.class: src/org/json/JSONString.java |
|
71 |
$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $< |
|
72 |
||
73 |
build/org/json/JSONStringer.class: src/org/json/JSONStringer.java |
|
74 |
$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $< |
|
75 |
||
76 |
build/org/json/JSONTokener.class: src/org/json/JSONTokener.java build/org/json/JSONException.class |
|
77 |
$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $< |
|
78 |
||
79 |
build/org/json/JSONWriter.class: src/org/json/JSONWriter.java build/org/json/JSONObject.class |
|
80 |
$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $< |
|
81 |
||
82 |
||
56 |
83 |
# Main Builds |
57 |
84 |
# ------------------------------------------------------------------------------- |
58 |
85 |
|
59 |
placebohttp.jar: build/org/openstatic/http/PlaceboHttpServer.class build/org/openstatic/http/PlaceboSession.class build/org/openstatic/http/HttpRequest.class build/org/openstatic/http/HttpRequestThread.class build/org/openstatic/http/HttpResponse.class build/PlaceboBase.class build/org/openstatic/placebo/ControlPanel.class build/org/openstatic/placebo/CoreServer.class build/org/openstatic/util/JTextAreaOutputStream.class |
|
86 |
placebohttp.jar: build/org/openstatic/http/PlaceboHttpServer.class build/org/openstatic/http/PlaceboSession.class build/org/openstatic/http/HttpRequest.class build/org/openstatic/http/HttpRequestThread.class build/org/openstatic/http/HttpResponse.class build/PlaceboBase.class build/org/openstatic/placebo/ControlPanel.class build/org/openstatic/placebo/CoreServer.class build/org/openstatic/util/JTextAreaOutputStream.class build/org/openstatic/util/JSONUtil.class |
|
60 |
87 |
$(JAR) -cvmf manifest.mf $@ -C build org -C build PlaceboBase.class www |
61 |
88 |
|
62 |
89 |
clean: |
Up to file-list src/org/openstatic/util/JSONUtil.java:
| … | … | @@ -22,10 +22,32 @@ public class JSONUtil |
22 |
22 |
} |
23 |
23 |
return buf.toString(); |
24 |
24 |
} |
25 |
||
26 |
public static String json2table(JSONArray jarray) throws Exception |
|
27 |
{ |
|
28 |
String return_string = "<table>"; |
|
29 |
for (int m = 0; m < jarray.length(); m++) |
|
30 |
{ |
|
31 |
return_string += "<tr><td>"; |
|
32 |
Object value = jarray.get(m); |
|
33 |
if (value instanceof JSONObject) |
|
34 |
{ |
|
35 |
return_string += json2table((JSONObject) value); |
|
36 |
} else if (value instanceof JSONArray) { |
|
37 |
return_string += json2table((JSONArray) value); |
|
38 |
} else { |
|
39 |
return_string += jarray.getString(m); |
|
40 |
} |
|
41 |
return_string += "</td></tr>"; |
|
42 |
} |
|
43 |
return_string += "</table>"; |
|
44 |
return return_string; |
|
45 |
} |
|
25 |
46 |
|
26 |
47 |
public static String json2table(JSONObject jobject) throws Exception |
27 |
48 |
{ |
28 |
String return_string = "<table border=\1\" cellspacing=\"0\" cellpadding=\"4\" style=\"border-color: #000000; border-style: solid; border-width: 1px; background-color: #FFFFFF; color: #000000;\"> |
|
49 |
String return_string = "<table border=\1\" cellspacing=\"0\" cellpadding=\"4\" style=\"border-color: #000000; border-style: solid; border-width: 1px; background-color: #FFFFFF; color: #000000;\">"; |
|
50 |
return_string += "<tr style=\"background-color: #AAAAAA; color: #000000;\"><th>KEY</th><th>VALUE</th></tr>"; |
|
29 |
51 |
String[] fnames = JSONObject.getNames(jobject); |
30 |
52 |
for (int i = 0; i < fnames.length; i++) |
31 |
53 |
{ |
| … | … | @@ -35,21 +57,7 @@ public class JSONUtil |
35 |
57 |
string_value = json2table((JSONObject) value); |
36 |
58 |
else if (value instanceof JSONArray) |
37 |
59 |
{ |
38 |
JSONArray ary = (JSONArray) value; |
|
39 |
string_value = "<table border=\"1\">"; |
|
40 |
for (int m = 0; m < ary.length(); m++) |
|
41 |
{ |
|
42 |
string_value += "<tr><td>"; |
|
43 |
Object value2 = ary.get(m); |
|
44 |
if (value2 instanceof JSONObject) |
|
45 |
{ |
|
46 |
string_value += json2table((JSONObject) value2); |
|
47 |
} else { |
|
48 |
string_value += ary.getString(m); |
|
49 |
} |
|
50 |
string_value += "</td></tr>"; |
|
51 |
} |
|
52 |
string_value |
|
60 |
string_value = json2table((JSONArray) value); |
|
53 |
61 |
} else { |
54 |
62 |
string_value = jobject.getString(fnames[i]); |
55 |
63 |
} |
