Package org.qdl_lang.vfs
Class AbstractVFSFileProvider
- java.lang.Object
-
- org.qdl_lang.vfs.AbstractVFSFileProvider
-
- All Implemented Interfaces:
Serializable,VFSFileProvider
- Direct Known Subclasses:
VFSMemoryFileProvider,VFSMySQLProvider,VFSPassThruFileProvider,VFSZipFileProvider
public abstract class AbstractVFSFileProvider extends Object implements VFSFileProvider
Created by Jeff Gaynor
on 2/28/20 at 5:07 PM- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractVFSFileProvider(String scheme, String mountPoint, boolean canRead, boolean canWrite)Constructor without a current directoryAbstractVFSFileProvider(String scheme, String mountPoint, String currentDir, boolean canRead, boolean canWrite)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanRead()booleancanWrite()protected voidcheckPath(String path)booleancheckScheme(String name)Checks if the name has the scheme for this provider.booleancontains(String path)Contains is a type of read.voiddelete(String path)A delete is a type of write.String[]dir(String path)booleaneasSupported()If this store supports extended attributes.VFSEntryget(String path, int type)Get the named item.StringgetCurrentDir()edu.uiuc.ncsa.security.core.configuration.XPropertiesgetFileInfo(String path)StringgetMountPoint()This is the mount point for the virtual file system.protected StringgetRealPath(String path)Resolves this against any current directory and returns the unqualified *relative* path against the store's root path.StringgetScheme()The scheme that uniquely identifies this providerStringgetStoreRoot()The root fo this store.static booleanisAbsolute(String path)Returns if this path is absolute, i.e.protected booleanisChildOf(String[] top, String target, boolean isRoot)Use this for stores that keep everything in a flat list (like a database table or hash map of file paths.) You useVFSPaths.toPathComponents(String)on the argument to thedir(String)command and specify if it is the root node (since figuring that out is store dependent).booleanisDirectory(String path)booleanisScript(String name)Checks if the FQ name can be resolved to a script by this provider.longlength(String path)booleanmkdir(String path)Make a set of directories.voidput(String newPath, VFSEntry entry)Add the using the path.voidput(VFSEntry entry)Put this in the store at its current pathvoidrm(String path)Remove a file from the store.booleanrmdir(String path)This will remove a directory.voidsetCurrentDir(String path)voidsetMountPoint(String mountPoint)The mount point does both start and end with the path separator since we always need it.voidsetRead(boolean newValue)voidsetScheme(String scheme)The scheme is does not end with the scheme delimiter and should be normalized here.voidsetWrite(boolean newValue)protected StringunqualifyPath(String x)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.qdl_lang.vfs.VFSFileProvider
getType
-
-
-
-
Method Detail
-
getMountPoint
public String getMountPoint()
Description copied from interface:VFSFileProviderThis is the mount point for the virtual file system.- Specified by:
getMountPointin interfaceVFSFileProvider- Returns:
-
setScheme
public void setScheme(String scheme)
Description copied from interface:VFSFileProviderThe scheme is does not end with the scheme delimiter and should be normalized here.- Specified by:
setSchemein interfaceVFSFileProvider
-
setMountPoint
public void setMountPoint(String mountPoint)
Description copied from interface:VFSFileProviderThe mount point does both start and end with the path separator since we always need it. The mount point should be normalized in the setter.- Specified by:
setMountPointin interfaceVFSFileProvider
-
getScheme
public String getScheme()
Description copied from interface:VFSFileProviderThe scheme that uniquely identifies this provider- Specified by:
getSchemein interfaceVFSFileProvider- Returns:
-
checkScheme
public boolean checkScheme(String name)
Description copied from interface:VFSFileProviderChecks if the name has the scheme for this provider.- Specified by:
checkSchemein interfaceVFSFileProvider- Returns:
-
canRead
public boolean canRead()
- Specified by:
canReadin interfaceVFSFileProvider
-
canWrite
public boolean canWrite()
- Specified by:
canWritein interfaceVFSFileProvider
-
setRead
public void setRead(boolean newValue)
- Specified by:
setReadin interfaceVFSFileProvider
-
setWrite
public void setWrite(boolean newValue)
- Specified by:
setWritein interfaceVFSFileProvider
-
getFileInfo
public edu.uiuc.ncsa.security.core.configuration.XProperties getFileInfo(String path) throws Throwable
- Specified by:
getFileInfoin interfaceVFSFileProvider- Throws:
Throwable
-
getCurrentDir
public String getCurrentDir()
- Specified by:
getCurrentDirin interfaceVFSFileProvider
-
setCurrentDir
public void setCurrentDir(String path)
- Specified by:
setCurrentDirin interfaceVFSFileProvider
-
checkPath
protected void checkPath(String path)
-
isScript
public boolean isScript(String name)
Description copied from interface:VFSFileProviderChecks if the FQ name can be resolved to a script by this provider.- Specified by:
isScriptin interfaceVFSFileProvider- Returns:
-
isAbsolute
public static boolean isAbsolute(String path)
Returns if this path is absolute, i.e. if it starts with the path separator. So A#/a/b/c is absolute, A#b/c is not.
An absolute path contains enough information to find the file. A relative path does not. This will compare them ignoring schemes.- Parameters:
path-- Returns:
-
getRealPath
protected String getRealPath(String path)
Resolves this against any current directory and returns the unqualified *relative* path against the store's root path.- Parameters:
path-- Returns:
-
getStoreRoot
public String getStoreRoot()
The root fo this store. So if the scheme is A and the mount point is /a/b/c then this returns A#/a/b/c. Operations on the store typiclly use this for resolving paths.- Returns:
-
get
public VFSEntry get(String path, int type) throws Throwable
Description copied from interface:VFSFileProviderGet the named item. Note that all of the names are qualified.- Specified by:
getin interfaceVFSFileProvider- Returns:
- Throws:
Throwable
-
put
public void put(String newPath, VFSEntry entry) throws Throwable
Description copied from interface:VFSFileProviderAdd the using the path. If and entry exists there it will be over-written.- Specified by:
putin interfaceVFSFileProvider- Throws:
Throwable
-
put
public void put(VFSEntry entry) throws Throwable
Description copied from interface:VFSFileProviderPut this in the store at its current path- Specified by:
putin interfaceVFSFileProvider- Throws:
Throwable
-
delete
public void delete(String path) throws Throwable
Description copied from interface:VFSFileProviderA delete is a type of write. If the store is not writeable, it cannot delete files.- Specified by:
deletein interfaceVFSFileProvider- Throws:
Throwable
-
contains
public boolean contains(String path) throws Throwable
Description copied from interface:VFSFileProviderContains is a type of read. If the store is not readable, it cannot tell if it contains an entry.- Specified by:
containsin interfaceVFSFileProvider- Returns:
- Throws:
Throwable
-
dir
public String[] dir(String path) throws Throwable
- Specified by:
dirin interfaceVFSFileProvider- Throws:
Throwable
-
isDirectory
public boolean isDirectory(String path)
- Specified by:
isDirectoryin interfaceVFSFileProvider
-
isChildOf
protected boolean isChildOf(String[] top, String target, boolean isRoot)
Use this for stores that keep everything in a flat list (like a database table or hash map of file paths.) You useVFSPaths.toPathComponents(String)on the argument to thedir(String)command and specify if it is the root node (since figuring that out is store dependent). This then compares paths by lengths to give back the right one.- Parameters:
top-target-isRoot-- Returns:
-
mkdir
public boolean mkdir(String path)
Description copied from interface:VFSFileProviderMake a set of directories. This will make a given directory and any intermediate directories.- Specified by:
mkdirin interfaceVFSFileProvider- Returns:
-
rmdir
public boolean rmdir(String path) throws Throwable
Description copied from interface:VFSFileProviderThis will remove a directory. Note that this requires that the directory be empty of all files.- Specified by:
rmdirin interfaceVFSFileProvider- Returns:
- Throws:
Throwable
-
rm
public void rm(String path) throws Throwable
Description copied from interface:VFSFileProviderRemove a file from the store.- Specified by:
rmin interfaceVFSFileProvider- Throws:
Throwable
-
easSupported
public boolean easSupported()
Description copied from interface:VFSFileProviderIf this store supports extended attributes.- Specified by:
easSupportedin interfaceVFSFileProvider- Returns:
-
length
public long length(String path) throws Throwable
- Specified by:
lengthin interfaceVFSFileProvider- Throws:
Throwable
-
-