Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0acb45b

Browse files
committed
Initial commit
0 parents  commit 0acb45b

File tree

8 files changed

+1389
-0
lines changed

8 files changed

+1389
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build/
2+
dist/
3+
nbproject/
4+
build.xml
5+
manifest.mf

src/javaxt/utils/src/Class.java

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
package javaxt.utils.src;
2+
import java.util.*;
3+
import javaxt.json.*;
4+
5+
6+
public class Class implements Member {
7+
private String name;
8+
private String description;
9+
private Class parent;
10+
private ArrayList<Member> members;
11+
private boolean isPublic = true;
12+
private String namespace;
13+
private ArrayList<String> extensions;
14+
private ArrayList<String> interfaces;
15+
16+
17+
public Class(String name){
18+
this.name = name;
19+
this.members = new ArrayList<>();
20+
this.extensions = new ArrayList<>();
21+
this.interfaces = new ArrayList<>();
22+
}
23+
24+
public String getName(){
25+
return name;
26+
}
27+
28+
public void setDescription(String description){
29+
this.description = description;
30+
}
31+
32+
public String getDescription(){
33+
return description;
34+
}
35+
36+
public boolean isPublic(){
37+
return isPublic;
38+
}
39+
40+
public void setPublic(boolean isPublic){
41+
this.isPublic = isPublic;
42+
}
43+
44+
public void setNamespace(String namespace){
45+
this.namespace = namespace;
46+
}
47+
48+
public String getNamespace(){
49+
return namespace;
50+
}
51+
52+
public void addSuper(String className){
53+
extensions.add(className);
54+
}
55+
56+
public ArrayList<String> getSuper(){
57+
return extensions;
58+
}
59+
60+
public void addInterface(String className){
61+
interfaces.add(className);
62+
}
63+
64+
public ArrayList<String> getInterfaces(){
65+
return interfaces;
66+
}
67+
68+
public void addMember(Member member){
69+
members.add(member);
70+
}
71+
72+
public ArrayList<Member> getMembers(){
73+
return members;
74+
}
75+
76+
public ArrayList<Class> getClasses(){
77+
ArrayList<Class> classes = new ArrayList<>();
78+
for (Member member : members){
79+
if (member instanceof Class) classes.add((Class) member);
80+
}
81+
return classes;
82+
}
83+
84+
public ArrayList<Constructor> getConstructors(){
85+
ArrayList<Constructor> constructors = new ArrayList<>();
86+
for (Member member : members){
87+
if (member instanceof Method){
88+
Method m = (Method) member;
89+
if (m instanceof Constructor){
90+
constructors.add((Constructor) m);
91+
}
92+
}
93+
}
94+
return constructors;
95+
}
96+
97+
public ArrayList<Method> getMethods(){
98+
ArrayList<Method> methods = new ArrayList<>();
99+
for (Member member : members){
100+
if (member instanceof Method){
101+
Method m = (Method) member;
102+
if (m instanceof Constructor){
103+
//System.out.println("-->" + m.getName());
104+
}
105+
else{
106+
methods.add(m);
107+
}
108+
}
109+
}
110+
return methods;
111+
}
112+
113+
public ArrayList<Property> getProperties(){
114+
ArrayList<Property> properties = new ArrayList<>();
115+
for (Member member : members){
116+
if (member instanceof Property) properties.add((Property) member);
117+
}
118+
return properties;
119+
}
120+
121+
public void setParent(Class parent){
122+
this.parent = parent;
123+
}
124+
125+
public Class getParent(){
126+
return parent;
127+
}
128+
129+
public JSONObject toJson(){
130+
JSONObject json = new JSONObject();
131+
json.set("name", name);
132+
json.set("description", description);
133+
JSONArray methods = new JSONArray();
134+
for (Method m : getMethods()){
135+
methods.add(m.toJson());
136+
}
137+
json.set("methods", methods);
138+
JSONArray properties = new JSONArray();
139+
for (Property p : getProperties()){
140+
properties.add(p.toJson());
141+
}
142+
json.set("properties", properties);
143+
JSONArray classes = new JSONArray();
144+
for (Class c : getClasses()){
145+
classes.add(c.toJson());
146+
}
147+
json.set("classes", classes);
148+
return json;
149+
}
150+
}

src/javaxt/utils/src/Constructor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package javaxt.utils.src;
2+
3+
public class Constructor extends Method {
4+
5+
public Constructor(String name){
6+
super(name);
7+
super.setStatic(false);
8+
}
9+
}

src/javaxt/utils/src/Member.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package javaxt.utils.src;
2+
3+
public interface Member {
4+
public String getName();
5+
}

src/javaxt/utils/src/Method.java

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package javaxt.utils.src;
2+
import java.util.*;
3+
import javaxt.json.*;
4+
5+
public class Method implements Member {
6+
private String name;
7+
private String description;
8+
private boolean isStatic;
9+
private String returnType;
10+
private ArrayList<Parameter> parameters;
11+
12+
public Method(String name){
13+
this.name = name;
14+
this.parameters = new ArrayList<>();
15+
}
16+
17+
public void setStatic(boolean isStatic){
18+
this.isStatic = isStatic;
19+
}
20+
21+
public boolean isStatic(){
22+
return isStatic;
23+
}
24+
25+
public void setReturnType(String returnType){
26+
this.returnType = returnType;
27+
}
28+
29+
public String getReturnType(){
30+
return returnType;
31+
}
32+
33+
public String getName(){
34+
return name;
35+
}
36+
37+
public void setDescription(String description){
38+
this.description = description;
39+
}
40+
41+
public String getDescription(){
42+
return description;
43+
}
44+
45+
public void addParameter(Parameter parameter){
46+
this.parameters.add(parameter);
47+
}
48+
49+
public ArrayList<Parameter> getParameters(){
50+
return parameters;
51+
}
52+
53+
public String toString(){
54+
return name;
55+
}
56+
57+
public JSONObject toJson(){
58+
JSONObject json = new JSONObject();
59+
json.set("name", name);
60+
json.set("description", description);
61+
JSONArray arr = new JSONArray();
62+
for (Parameter p : getParameters()){
63+
arr.add(p.toJson());
64+
}
65+
json.set("parameters", arr);
66+
return json;
67+
}
68+
}

src/javaxt/utils/src/Parameter.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package javaxt.utils.src;
2+
import javaxt.json.JSONObject;
3+
4+
public class Parameter {
5+
private String name;
6+
private String type;
7+
private String description;
8+
9+
public Parameter(String name){
10+
this.name = name;
11+
}
12+
13+
public String getName(){
14+
return name;
15+
}
16+
17+
public void setType(String type){
18+
this.type = type;
19+
}
20+
21+
public String getType(){
22+
return type;
23+
}
24+
25+
public void setDescription(String description){
26+
this.description = description;
27+
}
28+
29+
public String getDescription(){
30+
return description;
31+
}
32+
33+
public JSONObject toJson(){
34+
JSONObject json = new JSONObject();
35+
json.set("name", name);
36+
json.set("type", type);
37+
json.set("description", description);
38+
return json;
39+
}
40+
}

0 commit comments

Comments
 (0)