public ResourceBase addNodeResource(String path) {
Scanner scanner = new Scanner(path);
scanner.useDelimiter("/");
String next = "";
boolean resourceExist = false;
Resource resource = this; // It's the resource that represents the endpoint
ResourceBase subResource = null;
while (scanner.hasNext()) {
resourceExist = false;
next = scanner.next();
for (Resource res : resource.getChildren()) {
if (res.getName().equals(next)) {
subResource = (ResourceBase) res;
resourceExist = true;
}
}
if (!resourceExist) {
subResource = new RDTagResource(next,true, this);
resource.add(subResource);
}
resource = subResource;
}
subResource.setPath(resource.getPath());
subResource.setName(next);
scanner.close();
return subResource;
}