Skip to content
This repository was archived by the owner on Aug 3, 2021. It is now read-only.

Commit 971148b

Browse files
committed
Upadting to eclipse project
apparently I don't know how to make a jar through the command line
1 parent db18754 commit 971148b

File tree

11 files changed

+293
-0
lines changed

11 files changed

+293
-0
lines changed

JSONJavaWrapper/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4+
<classpathentry kind="src" path="src"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

JSONJavaWrapper/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

JSONJavaWrapper/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>JSONJavaWrapper</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.xdestx.json;
2+
3+
class JArray implements JOk {
4+
5+
private final JOk[] jarr;
6+
7+
public JArray(JOk[] jarr) {
8+
this.jarr = jarr;
9+
}
10+
11+
public String toJSONString() {
12+
String jsonString = "";
13+
jsonString+='[';
14+
for(int i = 0; i < jarr.length-1; i++) {
15+
jsonString+=jarr[i].toJSONString() + ",";
16+
}
17+
jsonString+=jarr[jarr.length-1].toJSONString();
18+
jsonString+="]";
19+
return jsonString;
20+
}
21+
22+
public JOk[] getArray() {
23+
return this.jarr;
24+
}
25+
26+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.xdestx.json;
2+
3+
public class JBoolean implements JOk {
4+
5+
private final boolean b;
6+
public JBoolean(boolean b) {
7+
this.b = b;
8+
}
9+
10+
public String toJSONString() {
11+
return ""+this.b;
12+
}
13+
14+
public boolean getValue() {
15+
return this.b;
16+
}
17+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.xdestx.json;
2+
3+
public class JNumber implements JOk {
4+
5+
private final double d;
6+
7+
public JNumber(double d) {
8+
this.d = d;
9+
}
10+
11+
public JNumber(Number n) {
12+
this.d = n.doubleValue();
13+
}
14+
15+
public JNumber(int n) {
16+
this.d = (double)n;
17+
}
18+
19+
public JNumber(float n) {
20+
this.d = (double)n;
21+
}
22+
23+
public JNumber(short n) {
24+
this.d = (double)n;
25+
}
26+
27+
public JNumber(long n) {
28+
this.d = (double)n;
29+
}
30+
31+
public String toJSONString() {
32+
return ""+d;
33+
}
34+
35+
public double getValue() {
36+
return this.d;
37+
}
38+
39+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.xdestx.json;
2+
3+
public interface JOk {
4+
public String toJSONString();
5+
}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
package com.xdestx.json;
2+
3+
import java.util.Map;
4+
import java.util.HashMap;
5+
6+
public class JSONObject implements JOk {
7+
8+
private Map<String,JOk> jsonMap;
9+
10+
public JSONObject(Map<String,JOk> objectMap) {
11+
this.jsonMap = objectMap;
12+
}
13+
14+
public JSONObject() {
15+
this.jsonMap = new HashMap<String, JOk>();
16+
}
17+
18+
//These put methods are for ease of use
19+
20+
public void put(String s, int n) {
21+
put(s, new JNumber(n));
22+
}
23+
24+
public void put(String s, double n) {
25+
put(s, new JNumber(n));
26+
}
27+
28+
public void put(String s, float n) {
29+
put(s, new JNumber(n));
30+
}
31+
32+
public void put(String s, short n) {
33+
put(s, new JNumber(n));
34+
}
35+
36+
public void put(String s, long n) {
37+
put(s, new JNumber(n));
38+
}
39+
40+
public void put(String s, Number...n) {
41+
JOk[] numbers = new JOk[n.length];
42+
for(int i = 0; i < n.length; i++) {
43+
numbers[i] = new JNumber(n[i]);
44+
}
45+
put(s,numbers);
46+
}
47+
48+
public void put(String s, boolean...b) {
49+
JOk[] bools = new JOk[b.length];
50+
for(int i = 0; i < b.length; i++) {
51+
bools[i] = new JBoolean(b[i]);
52+
}
53+
put(s,bools);
54+
}
55+
56+
public void put(String s, String...strs) {
57+
JOk[] jstrings = new JOk[strs.length];
58+
for(int i = 0; i < jstrings.length; i++) {
59+
jstrings[i] = new JString(strs[i]);
60+
}
61+
put(s,jstrings);
62+
}
63+
64+
public void put(String s, JOk[] arr) {
65+
put(s, new JArray(arr));
66+
}
67+
68+
69+
public void put(String s, String str) {
70+
put(s,new JString(str));
71+
}
72+
73+
public void put(String s, JString str) {
74+
jsonMap.put(s,str);
75+
}
76+
77+
public void put(String s, JArray arr) {
78+
jsonMap.put(s, arr);
79+
}
80+
81+
public void put(String s, JBoolean b) {
82+
jsonMap.put(s,b);
83+
}
84+
85+
public void put(String s, JNumber n) {
86+
jsonMap.put(s,n);
87+
}
88+
89+
public void put(String s, JOk j) {
90+
jsonMap.put(s,j);
91+
}
92+
93+
94+
95+
public Number getNumber(String s) {
96+
return ((JNumber)jsonMap.get(s)).getValue();
97+
}
98+
99+
public String getString(String s) {
100+
return ((JString)jsonMap.get(s)).getValue();
101+
}
102+
103+
public JOk[] getArray(String s) {
104+
return ((JArray)jsonMap.get(s)).getArray();
105+
}
106+
107+
public boolean getBoolean(String s) {
108+
return ((JBoolean)jsonMap.get(s)).getValue();
109+
}
110+
111+
public JSONObject getObject(String s) {
112+
return (JSONObject)jsonMap.get(s);
113+
}
114+
115+
116+
public String toJSONString() {
117+
String finString = "";
118+
finString+="{";
119+
for(String s : jsonMap.keySet()) {
120+
finString+="\"" + s + "\":"+ jsonMap.get(s).toJSONString() +",";
121+
}
122+
finString = finString.substring(0,finString.length()-1);
123+
finString+="}";
124+
return finString;
125+
}
126+
127+
public String toString() {
128+
return this.toJSONString();
129+
}
130+
131+
132+
133+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.xdestx.json;
2+
3+
public class JString implements JOk {
4+
private final String jstr;
5+
public JString(String s) {
6+
this.jstr = s;
7+
}
8+
public String toJSONString() {
9+
return "\""+jstr+"\"";
10+
}
11+
12+
public String getValue() {
13+
return this.jstr;
14+
}
15+
}

0 commit comments

Comments
 (0)