1 | package org.biohackathon.SPARQLBuilder.OWL;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 |
|
---|
5 | import org.json.JSONArray;
|
---|
6 | import org.json.JSONException;
|
---|
7 | import org.json.JSONObject;
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * 襍キ轤ケ縺ィ縺ェ繧九Μ繧ス繝シ繧ケ縺九i騾先ャ。逧�↓隍�焚繝ェ繝ウ繧ッ縺ァ邨らせ繝ェ繧ス繝シ繧ケ縺セ縺ァ謗・邯壹&繧後k荳縺、縺ョ繝代せ繧定ィ倩ソー縺吶k
|
---|
11 | *
|
---|
12 | * @author Yamaguchi
|
---|
13 | * @since 28.01.2014
|
---|
14 | * @version 29.01.2014
|
---|
15 | */
|
---|
16 | public class Path implements Comparable<Path>{
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * 繝代せ縺ョ襍キ轤ケ縺ィ縺ェ繧九け繝ゥ繧ケ縺ョURI
|
---|
20 | */
|
---|
21 | private String startClass;
|
---|
22 | private int width;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * 繝代せ縺ョ襍キ轤ケ縺九i邨らせ縺ォ蜷代°縺」縺ヲ騾先ャ。逧�↓縺、縺ェ縺後k繧ッ繝ゥ繧ケ髢薙Μ繝ウ繧ッ縺ョ繝ェ繧ケ繝� |
---|
26 | */
|
---|
27 | private List<ClassLink> classLinks;
|
---|
28 |
|
---|
29 | public JSONObject toJSON() {
|
---|
30 | JSONObject obj = new JSONObject();
|
---|
31 | try {
|
---|
32 | obj.put("startClassURI", startClass);
|
---|
33 | obj.put("width", width);
|
---|
34 | if (classLinks != null && classLinks.size() != 0) {
|
---|
35 | JSONArray array = new JSONArray();
|
---|
36 | for (int i = 0; i < classLinks.size(); i++) {
|
---|
37 | array.put(classLinks.get(i).toJSON());
|
---|
38 | }
|
---|
39 | obj.put("classLinks", array);
|
---|
40 | }
|
---|
41 | } catch (JSONException e) {
|
---|
42 | // TODO Auto-generated catch block
|
---|
43 | e.printStackTrace();
|
---|
44 | System.out.println(e.toString());
|
---|
45 | }
|
---|
46 | return obj;
|
---|
47 | }
|
---|
48 |
|
---|
49 | public String toJSONString(){
|
---|
50 | return toJSON().toString();
|
---|
51 | }
|
---|
52 |
|
---|
53 | public String toJSONString2(){
|
---|
54 | String json_str="";
|
---|
55 | json_str+="{\"startClassURI\":\""+ startClass+"\",";
|
---|
56 | //json_str+="\"width\":"+width+",";
|
---|
57 |
|
---|
58 | if (classLinks != null && classLinks.size() != 0) {
|
---|
59 | json_str+="\"classLinks\":[";
|
---|
60 |
|
---|
61 | JSONObject[] classLinkObjs = new JSONObject[classLinks.size()];
|
---|
62 | for (int i = 0; i < classLinks.size(); i++) {
|
---|
63 | if(i>0){json_str += "," ;}
|
---|
64 | json_str+= classLinks.get(i).toJSONString2();
|
---|
65 | }
|
---|
66 | json_str+="]";
|
---|
67 | }
|
---|
68 | json_str+="}";
|
---|
69 |
|
---|
70 | return json_str;
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | public String getStartClass() {
|
---|
75 | return startClass;
|
---|
76 | }
|
---|
77 |
|
---|
78 | /*
|
---|
79 | * public String[] getProperties(){ return properties; }
|
---|
80 | *
|
---|
81 | * public String[] getObjectClasses(){ return objectClasses; }
|
---|
82 | *
|
---|
83 | * public Direction[] getDirections(){ return directions; }
|
---|
84 | */
|
---|
85 | public List<ClassLink> getClassLinks() {
|
---|
86 | return classLinks;
|
---|
87 | }
|
---|
88 |
|
---|
89 | public int getWidth() {
|
---|
90 | return width;
|
---|
91 | }
|
---|
92 |
|
---|
93 | public Path() {
|
---|
94 | }
|
---|
95 |
|
---|
96 | public Path(String startClass, List<ClassLink> classLinks, int width) {
|
---|
97 | this.startClass = startClass;
|
---|
98 | this.classLinks = classLinks;
|
---|
99 | this.width = width;
|
---|
100 | }
|
---|
101 |
|
---|
102 | public void setStartClass(String startClass) {
|
---|
103 | this.startClass = startClass;
|
---|
104 | }
|
---|
105 |
|
---|
106 | public void setClassLinks(List<ClassLink> classLinks) {
|
---|
107 | this.classLinks = classLinks;
|
---|
108 | }
|
---|
109 |
|
---|
110 | public void setWidth(int width) {
|
---|
111 | this.width = width;
|
---|
112 | }
|
---|
113 |
|
---|
114 | @Override
|
---|
115 | public int compareTo(Path path) {
|
---|
116 | return this.width - path.getWidth();
|
---|
117 | //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
---|
118 | }
|
---|
119 |
|
---|
120 | } |
---|