Package com.wavemaker.commons.io.store
Class StoredFolder
- java.lang.Object
-
- com.wavemaker.commons.io.store.StoredResource
-
- com.wavemaker.commons.io.store.StoredFolder
-
- Direct Known Subclasses:
LocalFolder,ZipArchive
public abstract class StoredFolder extends StoredResource implements Folder
AFolderthat is backed by aFolderStore. Allows developers to use the simplerFolderStoreinterface to provide a fullFolderimplementation. Subclasses must provide a suitableFolderStoreimplementation via thegetStore()method.- See Also:
FolderStore,StoredFile
-
-
Constructor Summary
Constructors Constructor Description StoredFolder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete 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.voidcreateIfMissing()Recursively creates an empty representation of this resource and allparents.voiddelete()Delete the current resource (and any children).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.protected abstract FolderStoregetStore()booleanhasExisting(java.lang.String name)Returns true if this folder already contains a resource with the specified name.java.util.Iterator<Resource>iterator()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.java.lang.StringtoString(ResourceStringFormat format)Returns the name of the resource in the specified format.-
Methods inherited from class com.wavemaker.commons.io.store.StoredResource
createParentIfMissing, ensureExists, equals, exists, getLastModified, getName, getParent, getPath, hashCode, isModifiedAfter, isModifiedAfter, isModifiedBefore, isModifiedBefore, isRelativeTo, performOperation, toString, toStringRelativeTo
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.wavemaker.commons.io.Resource
equals, exists, getLastModified, getName, getParent, isModifiedAfter, isModifiedAfter, isModifiedBefore, isModifiedBefore, isRelativeTo, performOperation, toString, toStringRelativeTo
-
-
-
-
Method Detail
-
getStore
protected abstract FolderStore getStore()
- Specified by:
getStorein classStoredResource
-
getExisting
public Resource getExisting(java.lang.String name)
Description copied from interface:FolderReturn 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.- Specified by:
getExistingin interfaceFolder- Parameters:
name- the name of the resource- Returns:
- a
FileorFolderresource - See Also:
Folder.hasExisting(String)
-
hasExisting
public boolean hasExisting(java.lang.String name)
Description copied from interface:FolderReturns true if this folder already contains a resource with the specified name. This method supports the same naming rules asFolder.getExisting(String).- Specified by:
hasExistingin interfaceFolder- Parameters:
name- the name of the resource- Returns:
- true if the resource is contained in the folder
- See Also:
Folder.getExisting(String)
-
getFolder
public Folder getFolder(java.lang.String name)
Description copied from interface:FolderGet a child folder of the current folder. This method supports the same naming rules asFolder.getExisting(String).
-
getFile
public File getFile(java.lang.String name)
Description copied from interface:FolderGet a child file of the current folder. This method supports the same naming rules asFolder.getExisting(String).
-
get
public <T extends Resource> T get(java.lang.String name, java.lang.Class<T> resourceType)
Description copied from interface:FolderGet a child file or folder of the current folder. Depending on the resourceTypeFolder.getFile(String),Folder.getFolder(String)orFolder.getExisting(String)will be called. This method supports the same naming rules asFolder.getExisting(String).
-
iterator
public java.util.Iterator<Resource> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<Resource>
-
list
public Resources<Resource> list()
Description copied from interface:FolderList all immediate child resources of this folder. If this resource does not exist empty resources are returned.
-
find
public Resources<Resource> find()
Description copied from interface:FolderRecursively find all immediate and nested children of this folder. If this resource does not exist empty resources are returned.
-
copyTo
public 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
public Resources<Resource> copyContentsTo(Folder folder)
Description copied from interface:FolderConvenience methods to move the contents of the folder. Equivalent toFolder.list().copyTo(folder).- Specified by:
copyContentsToin interfaceFolder- Parameters:
folder- the folder to copy the resource to- Returns:
- a resource collection containing the new destination resources
- See Also:
Resources.copyTo(Folder)
-
moveTo
public 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
public Resources<Resource> moveContentsTo(Folder folder)
Description copied from interface:FolderConvenience methods to move the contents of the folder. Equivalent toFolder.list().moveTo(folder).- Specified by:
moveContentsToin interfaceFolder- Parameters:
folder- the folder to move the resource to- Returns:
- a resource collection containing the new destination resources
- See Also:
Resources.moveTo(Folder)
-
rename
public 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.
-
delete
public void delete()
Description copied from interface:ResourceDelete the current resource (and any children). If this resource does not exist then no operation is performed.
-
createIfMissing
public void createIfMissing()
Description copied from interface:ResourceRecursively creates an empty representation of this resource and allparents. Calling this method on an existing resource has not effect.- Specified by:
createIfMissingin interfaceResource
-
jail
public Folder jail()
Description copied from interface:FolderReturn a new folder that is jailed at the current location. A jailed folder acts as a root folder at the current location.
-
toString
public java.lang.String toString(ResourceStringFormat format)
Description copied from interface:ResourceReturns the name of the resource in the specified format.- Specified by:
toStringin interfaceResource- Overrides:
toStringin classStoredResource- Parameters:
format- the format used for the name- Returns:
- the name
- See Also:
Resource.toString(),Resource.toStringRelativeTo(Folder)
-
-