7 |
import java.util.Iterator; |
import java.util.Iterator; |
8 |
|
|
9 |
public class RDFUtil { |
public class RDFUtil { |
10 |
public static boolean dbg = true; |
public static boolean dbg = false; |
11 |
|
static private void p(String s) { if (dbg) pa(s); } |
12 |
static private void pa(String s) { System.out.println("RDFUtil: "+s); } |
static private void pa(String s) { System.out.println("RDFUtil: "+s); } |
13 |
|
|
14 |
/** Create a new resource with given type. |
/** Create a new resource with given type. |
17 |
Object obj = Nodes.N(); |
Object obj = Nodes.N(); |
18 |
fen.graph.set1_11X(obj, RDF.type, type); |
fen.graph.set1_11X(obj, RDF.type, type); |
19 |
|
|
20 |
if(dbg) pa("N: "+fen+" "+fen.graph+" "+fen.constgraph+ |
p("N: "+fen+" "+fen.graph+" "+fen.constgraph+ |
21 |
" "+obj+" "+type); |
" "+obj+" "+type); |
22 |
|
|
23 |
if (!isNodeType(fen, obj, type)) throw new Error("Impossible!"); |
if (!isNodeType(fen, obj, type)) throw new Error("Impossible!"); |
24 |
|
|
29 |
/** Check if node is the type which is asked. |
/** Check if node is the type which is asked. |
30 |
*/ |
*/ |
31 |
static public boolean isNodeType(Fen fen, Object node, Object type) { |
static public boolean isNodeType(Fen fen, Object node, Object type) { |
32 |
if(dbg) pa("Isnodetype: "+node+" "+type); |
p("Isnodetype: "+node+" "+type); |
33 |
Iterator it = fen.constgraph.findN_11X_Iter(node, RDF.type); |
Iterator it = fen.constgraph.findN_11X_Iter(node, RDF.type); |
34 |
while(it.hasNext()) { |
while(it.hasNext()) { |
35 |
Object obj = it.next(); |
Object obj = it.next(); |
36 |
pa(" entry: "+ obj); |
p(" entry: "+ obj); |
37 |
if ( obj.equals(type) ) return true; |
if ( obj.equals(type) ) return true; |
38 |
} |
} |
39 |
pa("None matched"); |
p("None matched"); |
40 |
return false; |
return false; |
41 |
} |
} |
42 |
|
|