MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / loaded

Method loaded

src/main/java/fielded/boxbrowser/BoxBrowser.java:51–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49 public BoxBrowser(Box root) {
50 this.root = root;
51 }
52
53 public void loaded() {
54
55 this.s = root.find(ServerSupport.server, this.both())
56 .findFirst()
57 .orElseThrow(() -> new IllegalArgumentException("need server for boxbrowser"));
58
59 s.addDocumentRoot(fieldagent.Main.app + "/fieldbox/resources/");
60 s.addURIHandler((uri, method, headers, params, files) -> {
61 if (uri.startsWith(NAMED)) {
62 uri = uri.substring(NAMED.length());
63 String[] pieces = uri.split("/");
64 return handleBy(x -> x.properties.has(Box.name) && x.properties.get(Box.name)
65 .equals(pieces[0]), pieces.length > 1 ? pieces[1] : null);
66 } else if (uri.startsWith(ID)) {
67 uri = uri.substring(ID.length());
68 String[] pieces = uri.split("/");
69 return handleBy(x -> x.properties.has(IO.id) && x.properties.get(IO.id)
70 .equals(pieces[0]), pieces.length > 1 ? pieces[1] : null);
71 } else if (uri.startsWith(DOCUMENTATION)) {
72 uri = uri.substring(DOCUMENTATION.length());
73 String[] pieces = uri.split("/");
74 Object object = knownObjects.get(pieces[0]);
75 if (object != null) {
76 return handleObject(object, pieces.length > 1 ? pieces[1] : null);
77 }
78 }
79 return null;
80 });
81 }
82

Callers

nothing calls this directly

Calls 11

handleByMethod · 0.95
handleObjectMethod · 0.95
addURIHandlerMethod · 0.80
getMethod · 0.65
findMethod · 0.45
bothMethod · 0.45
addDocumentRootMethod · 0.45
lengthMethod · 0.45
splitMethod · 0.45
hasMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected