Package com.wavemaker.commons.io.store
Class StoredResource
- java.lang.Object
-
- com.wavemaker.commons.io.store.StoredResource
-
- All Implemented Interfaces:
Resource
- Direct Known Subclasses:
StoredFile,StoredFolder
public abstract class StoredResource extends java.lang.Object implements Resource
Base forStoredFileandStoredFolder.- See Also:
StoredFile,StoredFolder
-
-
Constructor Summary
Constructors Constructor Description StoredResource()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcreateParentIfMissing()protected voidensureExists()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.longgetLastModified()Gets the time this resource object was last modified.java.lang.StringgetName()Returns the name of the resource.FoldergetParent()Returns the parent folder of the resource or null if this is the root folder.protected JailedResourcePathgetPath()protected abstract ResourceStoregetStore()inthashCode()booleanisModifiedAfter(long n)booleanisModifiedAfter(Resource resource)booleanisModifiedBefore(long n)booleanisModifiedBefore(Resource resource)booleanisRelativeTo(Folder folder)<R extends Resource,O extends ResourceOperation<R>>
OperformOperation(O operation)Resourcerename(java.lang.String name)Rename the current resource.java.lang.StringtoString()Returns the complete name of the resource.java.lang.StringtoString(ResourceStringFormat format)Returns the name of the resource in the specified format.java.lang.StringtoStringRelativeTo(Folder source)Returns the the complete name of this resource (including path elements) relative to the specified source folder.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.wavemaker.commons.io.Resource
copyTo, createIfMissing, delete, moveTo
-
-
-
-
Method Detail
-
getStore
protected abstract ResourceStore getStore()
-
getPath
protected final JailedResourcePath getPath()
-
ensureExists
protected final void ensureExists()
-
createParentIfMissing
protected final void createParentIfMissing()
-
getParent
public Folder getParent()
Description copied from interface:ResourceReturns the parent folder of the resource or null if this is the root folder.
-
getName
public java.lang.String getName()
Description copied from interface:ResourceReturns the name of the resource. This name does not include any path element. Root folders will have an empty string name.
-
rename
public Resource 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.
-
exists
public boolean exists()
Description copied from interface:ResourceReturns true if the resource exists in the underlying store.
-
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- Parameters:
format- the format used for the name- Returns:
- the name
- See Also:
Resource.toString(),Resource.toStringRelativeTo(Folder)
-
toStringRelativeTo
public java.lang.String toStringRelativeTo(Folder source)
Description copied from interface:ResourceReturns the the complete name of this resource (including path elements) relative to the specified source folder. The source must be a parent (or grandparent etc) of this resource. If the source is this folder an empty String is returned. The returned value does not include any leading slash, for example: '/a/b/c.txt' relative to '/a/' will return 'b/c.txt'.- Specified by:
toStringRelativeToin interfaceResource- Parameters:
source- the source folder- Returns:
- the name
- See Also:
Resource.toString(),Resource.toStringRelativeTo(Folder)
-
isRelativeTo
public boolean isRelativeTo(Folder folder)
- Specified by:
isRelativeToin interfaceResource- Returns:
- true if the given param folder is relative to comprising folder object, else return false
-
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.
-
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)
-
isModifiedAfter
public boolean isModifiedAfter(long n)
- Specified by:
isModifiedAfterin interfaceResource
-
isModifiedAfter
public boolean isModifiedAfter(Resource resource)
- Specified by:
isModifiedAfterin interfaceResource
-
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
-
isModifiedBefore
public boolean isModifiedBefore(long n)
- Specified by:
isModifiedBeforein interfaceResource
-
isModifiedBefore
public boolean isModifiedBefore(Resource resource)
- Specified by:
isModifiedBeforein interfaceResource
-
-