99 |
/** Special call for structure linked vocabulary to test if node is linked. |
/** Special call for structure linked vocabulary to test if node is linked. |
100 |
* @see STRUCTLINK |
* @see STRUCTLINK |
101 |
*/ |
*/ |
102 |
public boolean isLinked(Graph graph, Object node) { |
static public boolean isLinked(Graph graph, Object node) { |
103 |
Iterator it = graph.findN_11X_Iter(node, STRUCTLINK.linkedTo); |
Iterator it = graph.findN_11X_Iter(node, STRUCTLINK.linkedTo); |
104 |
if (it.hasNext()) return true; |
if (it.hasNext()) return true; |
105 |
it = graph.findN_X11_Iter(STRUCTLINK.linkedTo, node); |
it = graph.findN_X11_Iter(STRUCTLINK.linkedTo, node); |
107 |
return false; |
return false; |
108 |
} |
} |
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Split node to two nodes. Enfilade is splitted in ind, |
|
|
* i.e. (node, [foobar]) will be with ind 2 be splitted to |
|
|
* (node, [foo]) and (split, [bar]). All properties will |
|
|
* be copied to split. |
|
|
* |
|
|
* @return the new node |
|
|
* @deprecated |
|
|
*/ |
|
|
static public Object splitNode(Fen fen, Object node, int ind) { |
|
|
Object split = Nodes.N(); |
|
|
|
|
|
Enfilade1D enf = (Enfilade1D)fen.txtfunc.f(fen.constgraph, node); |
|
|
if (ind < 0 || ind >= enf.length()) |
|
|
throw new Error("Ind is too short or long! "+ind); |
|
|
|
|
|
Enfilade1D toEnf = enf.sub(ind, enf.length()); |
|
|
Enfilade1D fromEnf = enf.sub(0, ind); |
|
|
fen.txt.set(node, fromEnf); |
|
|
fen.txt.set(split, toEnf); |
|
|
|
|
|
Iterator iter = fen.graph.findN_1XA_Iter(node); |
|
|
while (iter.hasNext()) { |
|
|
Object predicate = iter.next(); |
|
|
if (predicate != FF.content) { |
|
|
Iterator it = fen.graph.findN_11X_Iter(node, predicate); |
|
|
while (it.hasNext()) { |
|
|
Object object = it.next(); |
|
|
if (dbg) p("Pred: " + predicate); |
|
|
if (dbg) p(" Obj: "+object); |
|
|
fen.graph.add(split, predicate, object); |
|
|
} |
|
|
} |
|
|
} |
|
|
return split; |
|
|
} |
|
110 |
} |
} |
111 |
|
|