/** * 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; } }
private static String[] splitPath(String path) { checkPath(path); return SLASH.split(path); }
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 Directory addDirectory(ServerResourcePath path) { if (null == path) { throw new IllegalArgumentException(); } Directory result = this.directory; ServerResourcePath subPath = path; String fileName; while (subPath != null && (fileName = subPath.getFileName()) != null) { result = adapter.addDirectory(result, fileName); subPath = subPath.getNextPath(); } return result; }
public void addResource(String string, Resource childResource) { directoryMap.addResource(new ServerResourcePath(string), childResource); }
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 path from string representation. Path must begin with '/' slash symbol, as required for * {@link ServletContext#getResource(String)} * @param path */ public ServerResourcePath(String path) { this(splitPath(path), 1); }
public void addResource(VirtualDirectoryResource resource, ServerResourcePath path, Resource childResource) { resource.addResource(path.toString(), childResource); }
@Override protected void addDirectory(String directoryPath) { serverRoot.createChildDirectory(new ServerResourcePath(directoryPath)); } }
public Directory addDirectory(ServerResourcePath path) { if (null == path) { throw new IllegalArgumentException(); } Directory result = this.directory; ServerResourcePath subPath = path; String fileName; while (subPath != null && (fileName = subPath.getFileName()) != null) { result = adapter.addDirectory(result, fileName); subPath = subPath.getNextPath(); } return result; }
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 path from string representation. Path must begin with '/' slash symbol, as required for * {@link ServletContext#getResource(String)} * @param path */ public ServerResourcePath(String path) { this(splitPath(path), 1); }
public Resource getResource(Resource resource, ServerResourcePath path) { try { return resource.addPath(path.toString()); } catch (MalformedURLException e) { throw new TestException(e.getMessage(), e); } catch (IOException e) { throw new TestException(e.getMessage(), e); } }
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; }
@Override protected void addDirectory(String directoryPath) { serverRoot.addDirectory(new ServerResourcePath(directoryPath)); }
/** * 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; } }
private static String[] splitPath(String path) { checkPath(path); return SLASH.split(path); }
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); } }
@Override protected void addDirectory(String directoryPath) { serverRoot.addDirectory(new ServerResourcePath(directoryPath)); }
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); } }