1 |
/* |
2 |
* RdfNode.cs - Implementation of the "DotGNU.Rdf.RdfNode" class. |
3 |
* |
4 |
* Copyright (C) 2003 Adam Ballai, Cannibutter Software. |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU Lesser General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU Lesser General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
* |
20 |
* Original Author: Rahul Singh (kingtiny@cs.cmu.edu) |
21 |
* Thank you Rahul Singh. |
22 |
*/ |
23 |
|
24 |
namespace DotGNU.Rdf |
25 |
{ |
26 |
using System; |
27 |
using System.Xml; |
28 |
using System.Collections; |
29 |
|
30 |
public class RdfNode |
31 |
{ |
32 |
public String nodeID; |
33 |
public Hashtable edges; |
34 |
public String nameSpacePrefix; |
35 |
public String nameSpace; |
36 |
public bool isBlankNode; |
37 |
public String nodeData; |
38 |
public String langID; |
39 |
public String bagID; |
40 |
|
41 |
|
42 |
public RdfNode() |
43 |
{ |
44 |
nameSpace = ""; |
45 |
edges = new Hashtable(); |
46 |
isBlankNode = true; |
47 |
bagID = null; |
48 |
} |
49 |
|
50 |
public ArrayList GetEdges() |
51 |
{ |
52 |
try |
53 |
{ |
54 |
ArrayList edgeList = new ArrayList(); |
55 |
IDictionaryEnumerator enumerator = edges.GetEnumerator(); |
56 |
while(enumerator.MoveNext()) |
57 |
{ |
58 |
edgeList.Add(enumerator.Key); |
59 |
} |
60 |
return edgeList; |
61 |
} |
62 |
catch(NullReferenceException e) |
63 |
{ |
64 |
return null; |
65 |
} |
66 |
} |
67 |
|
68 |
public ArrayList GetIncomingEdges() |
69 |
{ |
70 |
try |
71 |
{ |
72 |
ArrayList edgeList = new ArrayList(); |
73 |
IDictionaryEnumerator enumerator = edges.GetEnumerator(); |
74 |
while(enumerator.MoveNext()) |
75 |
{ |
76 |
if((int)enumerator.Value == RdfEdge.EdgeTypeIncoming) |
77 |
edgeList.Add(enumerator.Key); |
78 |
} |
79 |
return edgeList; |
80 |
} |
81 |
catch(NullReferenceException e) |
82 |
{ |
83 |
return null; |
84 |
} |
85 |
} |
86 |
|
87 |
public ArrayList GetOutgoingEdges() |
88 |
{ |
89 |
try |
90 |
{ |
91 |
ArrayList edgeList = new ArrayList(); |
92 |
IDictionaryEnumerator enumerator = edges.GetEnumerator(); |
93 |
while(enumerator.MoveNext()) |
94 |
{ |
95 |
if((int)enumerator.Value == RdfEdge.EdgeTypeOutgoing) |
96 |
edgeList.Add(enumerator.Key); |
97 |
} |
98 |
//TODO: no conversion from `System.Collections.Hashtable' to `System.Collections.ArrayList' |
99 |
return edgeList; |
100 |
} |
101 |
catch(NullReferenceException e) |
102 |
{ |
103 |
return null; |
104 |
} |
105 |
} |
106 |
|
107 |
public bool IsEdge(RdfEdge rdfEdge) |
108 |
{ |
109 |
try |
110 |
{ |
111 |
if(edges.ContainsKey(rdfEdge)) |
112 |
{ |
113 |
return true; |
114 |
} |
115 |
else |
116 |
{ |
117 |
return false; |
118 |
} |
119 |
} |
120 |
catch(NullReferenceException e) |
121 |
{ |
122 |
return false; |
123 |
} |
124 |
catch(ArgumentNullException e) |
125 |
{ |
126 |
return false; |
127 |
} |
128 |
|
129 |
} |
130 |
|
131 |
public bool IsIncomingEdge(RdfEdge rdfEdge) |
132 |
{ |
133 |
try |
134 |
{ |
135 |
if((int)edges[rdfEdge] == RdfEdge.EdgeTypeIncoming) |
136 |
{ |
137 |
return true; |
138 |
} |
139 |
else |
140 |
{ |
141 |
return false; |
142 |
} |
143 |
|
144 |
} |
145 |
catch(NullReferenceException e) |
146 |
{ |
147 |
return false; |
148 |
} |
149 |
catch(ArgumentNullException e) |
150 |
{ |
151 |
return false; |
152 |
} |
153 |
|
154 |
} |
155 |
|
156 |
public bool IsOutgoingEdge(RdfEdge rdfEdge) |
157 |
{ |
158 |
try |
159 |
{ |
160 |
if((int)edges[rdfEdge] == RdfEdge.EdgeTypeOutgoing) |
161 |
{ |
162 |
return true; |
163 |
} |
164 |
else |
165 |
{ |
166 |
return false; |
167 |
} |
168 |
} |
169 |
catch(NullReferenceException e) |
170 |
{ |
171 |
return false; |
172 |
} |
173 |
catch(ArgumentNullException e) |
174 |
{ |
175 |
return false; |
176 |
|
177 |
} |
178 |
} |
179 |
|
180 |
public bool AddRdfEdge(RdfEdge rdfEdge, int edgeType) |
181 |
{ |
182 |
try |
183 |
{ |
184 |
edges.Add(rdfEdge, edgeType); |
185 |
return true; |
186 |
} |
187 |
catch(ArgumentException e) |
188 |
{ |
189 |
throw new ArgumentException( |
190 |
//TODO : implement S |
191 |
//S._("ArgumentException"), |
192 |
"ArgumentException", |
193 |
"RdfEdge"); |
194 |
return false; |
195 |
} |
196 |
} |
197 |
} |
198 |
|
199 |
} |