Package com.wavemaker.commons.io
Class AbstractReadOnlyFile
- java.lang.Object
-
- com.wavemaker.commons.io.AbstractReadOnlyFile
-
- Direct Known Subclasses:
ClassPathFile
public abstract class AbstractReadOnlyFile extends java.lang.Object implements File
-
-
Constructor Summary
Constructors Constructor Description AbstractReadOnlyFile()
-
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.voidcreateIfMissing()Recursively creates an empty representation of this resource and allparents.voiddelete()Delete the current resource (and any children).booleanequals(java.lang.Object obj)Determines if this resource is equal to another object.booleanexists()Returns true if the resource exists in the underlying store.FileContentgetContent()Provides access to file content.protected abstract java.io.InputStreamgetInputStream()Return the input stream for the contents of the File or null if the file does not exist.longgetLastModified()Gets the time this resource object was last modified.FoldergetParent()Returns the parent folder of the resource or null if this is the root folder.longgetSize()Returns the size in bytes of the virtual file.inthashCode()FilemoveTo(Folder folder)Move this resource to the specified folder.protected ReadOnlyResourceExceptionnewReadOnlyResourceException()Return theReadOnlyResourceExceptionthat should be thrown on error.<R extends Resource,O extends ResourceOperation<R>>
OperformOperation(O operation)Filerename(java.lang.String name)Rename the current resource.java.lang.StringtoString()Returns the complete name of the resource.voidtouch()Update thelast modified timestampof the file to now.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.wavemaker.commons.io.File
copyToIfNewer
-
Methods inherited from interface com.wavemaker.commons.io.Resource
getName, isModifiedAfter, isModifiedAfter, isModifiedBefore, isModifiedBefore, isRelativeTo, toString, toStringRelativeTo
-
-
-
-
Method Detail
-
getParent
public Folder getParent()
Description copied from interface:ResourceReturns the parent folder of the resource or null if this is the root folder.
-
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.
-
exists
public boolean exists()
Description copied from interface:ResourceReturns true if the resource exists in the underlying store.
-
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
-
toString
public java.lang.String toString()
Description copied from interface:ResourceReturns the complete name of the resource. This name includes path elements. Folders always end in '/'.- Specified by:
toStringin interfaceResource- Overrides:
toStringin classjava.lang.Object- Returns:
- the full name of the resource, for example "/folder/file.txt" or "/folder/"
- See Also:
Resource.getName(),Resource.toString(ResourceStringFormat),Resource.toStringRelativeTo(Folder)
-
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.
-
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.
-
touch
public void touch()
Description copied from interface:FileUpdate thelast modified timestampof the file to now.
-
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- 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
-
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
-
performOperation
public <R extends Resource,O extends ResourceOperation<R>> O performOperation(O operation)
- Specified by:
performOperationin interfaceResource
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:ResourceDetermines if this resource is equal to another object. Any resources that have the same type, path and are stored in the same underlying system are considered equal.
-
getInputStream
protected abstract java.io.InputStream getInputStream()
Return the input stream for the contents of the File or null if the file does not exist.- Returns:
- the
InputStreamor null
-
newReadOnlyResourceException
protected ReadOnlyResourceException newReadOnlyResourceException()
Return theReadOnlyResourceExceptionthat should be thrown on error.- Returns:
- the exception
-
-