public ServerResource getResource(ServerResourcePath path) { if(null == path){ throw new NullPointerException(); } // If path points to the resource itself, returns this instance. if (!path.hasNextPath()) { return this; } return null; }
public ServerResource getResource(ServerResourcePath path) { if(null == path){ throw new NullPointerException(); } // If path points to the resource itself, returns this instance. if (!path.hasNextPath()) { return this; } return null; }
/** * Create next path of the path chain. * Path /foo/bar/baz should be converted to /bar/baz , /bar/baz -> /baz -> null * @return next subdirectory path or null. */ public ServerResourcePath getNextPath() { if (hasNextPath()) { return new ServerResourcePath(pathElements, pathIndex + 1); } else { return null; } }
/** * Create next path of the path chain. * Path /foo/bar/baz should be converted to /bar/baz , /bar/baz -> /baz -> null * @return next subdirectory path or null. */ public ServerResourcePath getNextPath() { if (hasNextPath()) { return new ServerResourcePath(pathElements, pathIndex + 1); } else { return null; } }
public Resource getResource(ServerResourcePath path) { if (null == path) { throw new NullPointerException(); } Resource resource = null; //children.get(path.getName()); String fileName = path.getFileName(); if (fileName == null) { // Path points to the resource itself. resource = this.directory; } else { resource = children.get(fileName); if (resource != null && path.hasNextPath()) { // Get next resource in the tree, if exists. resource = adapter.getResource(resource, path.getNextPath()); } } return resource; }
public Resource getResource(ServerResourcePath path) { if (null == path) { throw new NullPointerException(); } Resource resource = null; //children.get(path.getName()); String fileName = path.getFileName(); if (fileName == null) { // Path points to the resource itself. resource = this.directory; } else { resource = children.get(fileName); if (resource != null && path.hasNextPath()) { // Get next resource in the tree, if exists. resource = adapter.getResource(resource, path.getNextPath()); } } return resource; }
public void addResource(ServerResourcePath path, Resource resource) { if (null == path) { throw new IllegalArgumentException(); } String fileName = path.getFileName(); if (fileName == null) { throw new IllegalArgumentException(); } if (path.hasNextPath()) { Directory childResource = addDirectory(fileName); adapter.addResource(childResource, path.getNextPath(), resource); } else { putChild(fileName, resource); } }
public void addResource(ServerResourcePath path, Resource resource) { if (null == path) { throw new IllegalArgumentException(); } String fileName = path.getFileName(); if (fileName == null) { throw new IllegalArgumentException(); } if (path.hasNextPath()) { Directory childResource = addDirectory(fileName); adapter.addResource(childResource, path.getNextPath(), resource); } else { putChild(fileName, resource); } }