Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

54
LINES

< > BotCompany Repo | #1012306 // WebNode with SmallestList<S> labels, no visInfo

JavaX fragment (include)

1  
sclass WebNode implements _SetField {
2  
  Web web;
3  
  O labels;
4  
5  
  public void _setField(S f, O x) {
6  
    if (f.equals('web)) web = (Web) x;
7  
    else if (f.equals('labels)) labels = (L) x;
8  
  }
9  
  
10  
  void _doneLoading {
11  
    if (labels instanceof L) labels = smallestList_fromList(map_lispHead((L) labels));
12  
  }
13  
  
14  
  *() {}
15  
  *(Web *web) { web.fireNewNode(this); }
16  
  
17  
  final O rawLabels() {
18  
    ret labels;
19  
  }
20  
  
21  
  void addLabel(S label) {
22  
    labels = smallestList_add(rawLabels(), label);
23  
  }
24  
  
25  
  void addLabel(Lisp label) {
26  
    addLabel(web.unparseLabel(label));
27  
  }
28  
  
29  
  void addLabels(Collection<Lisp> l) { for (Lisp lbl : l) addLabel(lbl); }
30  
  void addStrings(Collection<S> l) { for (S lbl : l) addLabel(lbl); }
31  
  
32  
  bool hasLabel(Lisp label) { ret hasLabel(web.unparseLabel(label)); }
33  
  bool hasLabel(S label) { ret smallestList_contains(rawLabels(), label); }
34  
  
35  
  toString { ret smallestList_l(rawLabels()) == 1 ? str(smallestList_first(rawLabels())) : str(smallestList_toList(rawLabels())); }
36  
  
37  
  int count() { ret 1 + smallestList_l(rawLabels()); }
38  
  final S text() { ret (S) smallestList_first(rawLabels()); }
39  
  final L<S> texts() { ret smallestList_toList(rawLabels()); }
40  
  
41  
  void relation(S arrow, S b) {
42  
    web.getRelation(this, web.node(b)).addLabel(arrow);
43  
  }
44  
  
45  
  Lisp parseLabel(S l) { ret web.parseLabel(l); }
46  
  S unparseLabel(Lisp l) { ret web.unparseLabel(l); }
47  
  
48  
  L<Lisp> labels() { ret web.parseLabels(texts()); }
49  
  bool hasLabels() { ret smallestList_nempty(rawLabels()); }
50  
  void setLabel(int i, Lisp l) { labels = smallestList_set(rawLabels(), i, web.unparseLabel(l)); }
51  
  
52  
  O visInfo() { ret null; }
53  
  void visInfo(O o) {}
54  
}

Author comment

Began life as a copy of #1012305

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1012306
Snippet name: WebNode with SmallestList<S> labels, no visInfo
Eternal ID of this version: #1012306/9
Text MD5: dfe7ffea09a9f0d2b07309943811a475
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-27 22:58:56
Source code size: 1710 bytes / 54 lines
Pitched / IR pitched: No / No
Views / Downloads: 470 / 492
Version history: 8 change(s)
Referenced in: [show references]