Package com.wavemaker.commons.io.store
Class StoredFile
- java.lang.Object
-
- com.wavemaker.commons.io.store.StoredResource
-
- com.wavemaker.commons.io.store.StoredFile
-
- Direct Known Subclasses:
LocalFile
public abstract class StoredFile extends StoredResource implements File
AFilethat is backed by aFileStore. Allows developers to use the simplerFileStoreinterface to provide a fullFileimplementation. Subclasses must provide a suitableFileStoreimplementation via thegetStore()method.- See Also:
FileStore,StoredFolder
-
-
Constructor Summary
Constructors Constructor Description StoredFile()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description FilecopyTo(Folder folder)Recursively copy this resource to the specified folder.FilecopyToIfNewer(Folder folder)RCopy this file to the specified folder if this file is newer than the destination.voidcreateIfMissing()Recursively creates an empty representation of this resource and allparents.voiddelete()Delete the current resource (and any children).FileContentgetContent()Provides access to file content.longgetLastModified()Gets the time this resource object was last modified.longgetSize()Returns the size in bytes of the virtual file.protected abstract FileStoregetStore()FilemoveTo(Folder folder)Move this resource to the specified folder.Filerename(java.lang.String name)Rename the current resource.voidtouch()Update thelast modified timestampof the file to now.protected booleanwrite(File file)Called to write the contents of another file to this file.-
Methods inherited from class com.wavemaker.commons.io.store.StoredResource
createParentIfMissing, ensureExists, equals, exists, getName, getParent, getPath, hashCode, isModifiedAfter, isModifiedAfter, isModifiedBefore, isModifiedBefore, isRelativeTo, performOperation, toString, 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, getName, getParent, isModifiedAfter, isModifiedAfter, isModifiedBefore, isModifiedBefore, isRelativeTo, performOperation, toString, toString, toStringRelativeTo
-
-
-
-
Method Detail
-
getStore
protected abstract FileStore getStore()
- Specified by:
getStorein classStoredResource
-
getSize
public long getSize()
Description copied from interface:FileReturns the size in bytes of the virtual file.
-
getLastModified
public long getLastModified()
Description copied from interface:ResourceGets the time this resource object was last modified. The time is measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970).- Specified by:
getLastModifiedin interfaceResource- Overrides:
getLastModifiedin classStoredResource- Returns:
- the time this resource object was last modified; or 0 if the resource object does not exist, if an I/O error occurred, or if the operation is not supported
-
touch
public void touch()
Description copied from interface:FileUpdate thelast modified timestampof the file to now.
-
getContent
public FileContent getContent()
Description copied from interface:FileProvides access to file content. Calling any method on a file that does notexistwill cause it to be created.- Specified by:
getContentin interfaceFile- Returns:
- the file content
-
rename
public File 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.
-
moveTo
public File 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.
-
copyTo
public File 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.
-
copyToIfNewer
public File copyToIfNewer(Folder folder)
Description copied from interface:FileRCopy this file to the specified folder if this file is newer than the destination.- Specified by:
copyToIfNewerin interfaceFile- Parameters:
folder- the folder to copy the file to- Returns:
- a new resource (the current resource will no longer
exist
-
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
-
write
protected boolean write(File file)
Called to write the contents of another file to this file. This method is can optionally be implemented by subclasses to implement custom file copy strategies.- Parameters:
file- the file being written to this one- Returns:
- if the write operation has been handled. Return false for standard stream based writes.
-
-