Package com.wavemaker.commons.io
Interface Folder
-
- All Known Implementing Classes:
LocalFolder,StoredFolder,ZipArchive
public interface Folder extends Resource, java.lang.Iterable<Resource>
A folderResourcethat may be stored on a physical disk or using some other mechanism.- See Also:
File
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Resources<Resource>copyContentsTo(Folder folder)Convenience methods to move the contents of the folder.FoldercopyTo(Folder folder)Recursively copy this resource to the specified folder.Resources<Resource>find()Recursively find all immediate and nested children of this folder.<T extends Resource>
Tget(java.lang.String name, java.lang.Class<T> resourceType)Get a child file or folder of the current folder.ResourcegetExisting(java.lang.String name)FilegetFile(java.lang.String name)Get a child file of the current folder.FoldergetFolder(java.lang.String name)Get a child folder of the current folder.booleanhasExisting(java.lang.String name)Returns true if this folder already contains a resource with the specified name.Folderjail()Return a new folder that is jailed at the current location.Resources<Resource>list()List all immediate child resources of this folder.Resources<Resource>moveContentsTo(Folder folder)Convenience methods to move the contents of the folder.FoldermoveTo(Folder folder)Move this resource to the specified folder.Folderrename(java.lang.String name)Rename the current resource.-
Methods inherited from interface com.wavemaker.commons.io.Resource
createIfMissing, delete, equals, exists, getLastModified, getName, getParent, isModifiedAfter, isModifiedAfter, isModifiedBefore, isModifiedBefore, isRelativeTo, performOperation, toString, toString, toStringRelativeTo
-
-
-
-
Method Detail
-
moveTo
Folder moveTo(Folder folder)
Description copied from interface:ResourceMove this resource to the specified folder. Any duplicateFiles will be replaced (existingFolderresources will be merged). If the resource does not exist aResourceDoesNotExistExceptionis thrown.
-
moveContentsTo
Resources<Resource> moveContentsTo(Folder folder)
Convenience methods to move the contents of the folder. Equivalent tolist().moveTo(folder).- Parameters:
folder- the folder to move the resource to- Returns:
- a resource collection containing the new destination resources
- See Also:
Resources.moveTo(Folder)
-
copyTo
Folder copyTo(Folder folder)
Description copied from interface:ResourceRecursively copy this resource to the specified folder. Any duplicateFiles will be replaced (existingFolderresources will be merged). If the resource does not exist aResourceDoesNotExistExceptionis thrown.
-
copyContentsTo
Resources<Resource> copyContentsTo(Folder folder)
Convenience methods to move the contents of the folder. Equivalent tolist().copyTo(folder).- Parameters:
folder- the folder to copy the resource to- Returns:
- a resource collection containing the new destination resources
- See Also:
Resources.copyTo(Folder)
-
rename
Folder rename(java.lang.String name)
Description copied from interface:ResourceRename the current resource. The rename operation cannot be used not move the resource to a different folder, use theResource.moveTo(Folder)method to move the resource before renaming if required. Root folders cannot be renamed. If the resource does not exist aResourceDoesNotExistExceptionis thrown.
-
getExisting
Resource getExisting(java.lang.String name)
Return a child from the current folder that refers to an existingFileorFolder. If the name includes '/' characters then the file will be returned from nested folders. Paths are relative unless they begin with '/', in which case they are taken from the topmostparent. Use '..' to refer to a parent folder.- Parameters:
name- the name of the resource- Returns:
- a
FileorFolderresource - Throws:
ResourceDoesNotExistException- if the resource does not exist- See Also:
hasExisting(String)
-
hasExisting
boolean hasExisting(java.lang.String name)
Returns true if this folder already contains a resource with the specified name. This method supports the same naming rules asgetExisting(String).- Parameters:
name- the name of the resource- Returns:
- true if the resource is contained in the folder
- See Also:
getExisting(String)
-
getFolder
Folder getFolder(java.lang.String name)
Get a child folder of the current folder. This method supports the same naming rules asgetExisting(String).- Parameters:
name- the name of the folder to get- Returns:
- the
Folder - Throws:
ResourceTypeMismatchException- if the an existing resource exits that is not a folder
-
getFile
File getFile(java.lang.String name)
Get a child file of the current folder. This method supports the same naming rules asgetExisting(String).- Parameters:
name- the name of the file to get- Returns:
- the
File - Throws:
ResourceTypeMismatchException- if the an existing resource exits that is not a file
-
get
<T extends Resource> T get(java.lang.String name, java.lang.Class<T> resourceType)
Get a child file or folder of the current folder. Depending on the resourceTypegetFile(String),getFolder(String)orgetExisting(String)will be called. This method supports the same naming rules asgetExisting(String).- Parameters:
name- the name of the resource to getresourceType- the resource type- Returns:
- the resource.
- Throws:
ResourceTypeMismatchException- if the an existing resource exits that is of the wrong type
-
list
Resources<Resource> list()
List all immediate child resources of this folder. If this resource does not exist empty resources are returned.- Returns:
- a list of all immediate child resources
-
find
Resources<Resource> find()
Recursively find all immediate and nested children of this folder. If this resource does not exist empty resources are returned.- Returns:
- a list of all nested children
-
jail
Folder jail()
Return a new folder that is jailed at the current location. A jailed folder acts as a root folder at the current location.- Returns:
- a new jailed folder
-
-