Package com.wavemaker.commons.io
Class ClassPathFile
- java.lang.Object
-
- com.wavemaker.commons.io.AbstractReadOnlyFile
-
- com.wavemaker.commons.io.ClassPathFile
-
public class ClassPathFile extends AbstractReadOnlyFile
Exposes a class-path resource as a read-onlyFile.
-
-
Constructor Summary
Constructors Constructor Description ClassPathFile(java.lang.Class<?> sourceClass, java.lang.String path)Create a newClassPathFileinstance.ClassPathFile(java.lang.ClassLoader classLoader, java.lang.String path)Create a newClassPathFileinstance.ClassPathFile(java.lang.String path)Create a newClassPathFileinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FilecopyToIfNewer(Folder folder)RCopy this file to the specified folder if this file is newer than the destination.protected java.io.InputStreamgetInputStream()Return the input stream for the contents of the File or null if the file does not exist.java.lang.StringgetName()Returns the name of the resource.booleanisModifiedAfter(long n)booleanisModifiedAfter(Resource resource)booleanisModifiedBefore(long n)booleanisModifiedBefore(Resource resource)booleanisRelativeTo(Folder folder)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 com.wavemaker.commons.io.AbstractReadOnlyFile
copyTo, createIfMissing, delete, equals, exists, getContent, getLastModified, getParent, getSize, hashCode, moveTo, newReadOnlyResourceException, performOperation, rename, toString, touch
-
-
-
-
Constructor Detail
-
ClassPathFile
public ClassPathFile(java.lang.String path)
Create a newClassPathFileinstance.- Parameters:
path- the path of the resource
-
ClassPathFile
public ClassPathFile(java.lang.ClassLoader classLoader, java.lang.String path)Create a newClassPathFileinstance.- Parameters:
classLoader- aClassLoaderor null to use the defaultpath- the path of the resource
-
ClassPathFile
public ClassPathFile(java.lang.Class<?> sourceClass, java.lang.String path)Create a newClassPathFileinstance.- Parameters:
sourceClass- the source class used to load the resourcepath- the path of the resource (relative to the sourceClass)
-
-
Method Detail
-
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.- Returns:
- the name of the resource, for example "file.txt"
-
toString
public java.lang.String toString(ResourceStringFormat format)
Description copied from interface:ResourceReturns the name of the resource in the specified format.- 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'.- Parameters:
source- the source folder- Returns:
- the name
- See Also:
Resource.toString(),Resource.toStringRelativeTo(Folder)
-
isRelativeTo
public boolean isRelativeTo(Folder folder)
- Returns:
- true if the given param folder is relative to comprising folder object, else return false
-
isModifiedAfter
public boolean isModifiedAfter(long n)
-
isModifiedAfter
public boolean isModifiedAfter(Resource resource)
-
isModifiedBefore
public boolean isModifiedBefore(long n)
-
isModifiedBefore
public boolean isModifiedBefore(Resource resource)
-
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.- Parameters:
folder- the folder to copy the file to- Returns:
- a new resource (the current resource will no longer
exist
-
getInputStream
protected java.io.InputStream getInputStream()
Description copied from class:AbstractReadOnlyFileReturn the input stream for the contents of the File or null if the file does not exist.- Specified by:
getInputStreamin classAbstractReadOnlyFile- Returns:
- the
InputStreamor null
-
-