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

51
LINES

< > BotCompany Repo | #1010355 // RemoteLister - uses connection to another database [totally dev.]

JavaX fragment (include)

1  
concept RemoteLister implements ILister {
2  
  RemoteDB db;
3  
  new HashMap<S, L> lists;
4  
  new HashMap<S, Map> treeMaps;
5  
  new HashMap<S, Set> treeSets;
6  
  new HashMap<S, IVar> vars;
7  
  
8  
  public L getList(S name) {
9  
    ret getList(name, ll());
10  
  }
11  
  
12  
  public synchronized L getList(S name, L defaultList) {
13  
    L l = lists.get(name);
14  
    if (l == null) {
15  
      lists.put(name, l = listInConcept(this, cloneList(defaultList)));
16  
      change();
17  
    }
18  
    ret l;
19  
  }
20  
  
21  
  public synchronized IVar getVar(S name, O defaultValue) {
22  
    IVar v = vars.get(name);
23  
    if (v == null) {
24  
      vars.put(name, v = varInConcept(this, new Var));
25  
      change();
26  
    }
27  
    if (!v.has() && defaultValue != null)
28  
      v.set(defaultValue);
29  
    ret v;
30  
  }
31  
  
32  
  public synchronized Map getTreeMap(S name) {
33  
    Map m = treeMaps.get(name);
34  
    if (m == null) {
35  
      treeMaps.put(name, m = mapInConcept(this, new TreeMap));
36  
      change();
37  
    }
38  
    if (getOpt_raw(m, 'm) == null)
39  
     fail("map not sane: " + className(m) + " " + struct(m));
40  
    ret m;
41  
  }
42  
  
43  
  public synchronized Set getTreeSet(S name) {
44  
    Set m = treeSets.get(name);
45  
    if (m == null) {
46  
      treeSets.put(name, m = setInConcept(this, new TreeSet));
47  
      change();
48  
    }
49  
    ret m;
50  
  }  
51  
}

Author comment

Began life as a copy of #1009401

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: #1010355
Snippet name: RemoteLister - uses connection to another database [totally dev.]
Eternal ID of this version: #1010355/1
Text MD5: 19ed995f185a71dddbf6eb5e3777244d
Author: stefan
Category: javax / lists
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-12 15:57:39
Source code size: 1289 bytes / 51 lines
Pitched / IR pitched: No / No
Views / Downloads: 340 / 372
Referenced in: [show references]