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 boolean
canRead()
boolean
canWrite()
protected void
checkPath(String path)
boolean
checkScheme(String name)
Checks if the name has the scheme for this provider.boolean
contains(String path)
Contains is a type of read.void
delete(String path)
A delete is a type of write.String[]
dir(String path)
boolean
easSupported()
If this store supports extended attributes.VFSEntry
get(String path, int type)
Get the named item.String
getCurrentDir()
edu.uiuc.ncsa.security.core.configuration.XProperties
getFileInfo(String path)
String
getMountPoint()
This is the mount point for the virtual file system.protected String
getRealPath(String path)
Resolves this against any current directory and returns the unqualified *relative* path against the store's root path.String
getScheme()
The scheme that uniquely identifies this providerString
getStoreRoot()
The root fo this store.static boolean
isAbsolute(String path)
Returns if this path is absolute, i.e.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).boolean
isDirectory(String path)
boolean
isScript(String name)
Checks if the FQ name can be resolved to a script by this provider.long
length(String path)
boolean
mkdir(String path)
Make a set of directories.void
put(String newPath, VFSEntry entry)
Add the using the path.void
put(VFSEntry entry)
Put this in the store at its current pathvoid
rm(String path)
Remove a file from the store.boolean
rmdir(String path)
This will remove a directory.void
setCurrentDir(String path)
void
setMountPoint(String mountPoint)
The mount point does both start and end with the path separator since we always need it.void
setRead(boolean newValue)
void
setScheme(String scheme)
The scheme is does not end with the scheme delimiter and should be normalized here.void
setWrite(boolean newValue)
protected String
unqualifyPath(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:VFSFileProvider
This is the mount point for the virtual file system.- Specified by:
getMountPoint
in interfaceVFSFileProvider
- Returns:
-
setScheme
public void setScheme(String scheme)
Description copied from interface:VFSFileProvider
The scheme is does not end with the scheme delimiter and should be normalized here.- Specified by:
setScheme
in interfaceVFSFileProvider
-
setMountPoint
public void setMountPoint(String mountPoint)
Description copied from interface:VFSFileProvider
The 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:
setMountPoint
in interfaceVFSFileProvider
-
getScheme
public String getScheme()
Description copied from interface:VFSFileProvider
The scheme that uniquely identifies this provider- Specified by:
getScheme
in interfaceVFSFileProvider
- Returns:
-
checkScheme
public boolean checkScheme(String name)
Description copied from interface:VFSFileProvider
Checks if the name has the scheme for this provider.- Specified by:
checkScheme
in interfaceVFSFileProvider
- Returns:
-
canRead
public boolean canRead()
- Specified by:
canRead
in interfaceVFSFileProvider
-
canWrite
public boolean canWrite()
- Specified by:
canWrite
in interfaceVFSFileProvider
-
setRead
public void setRead(boolean newValue)
- Specified by:
setRead
in interfaceVFSFileProvider
-
setWrite
public void setWrite(boolean newValue)
- Specified by:
setWrite
in interfaceVFSFileProvider
-
getFileInfo
public edu.uiuc.ncsa.security.core.configuration.XProperties getFileInfo(String path) throws Throwable
- Specified by:
getFileInfo
in interfaceVFSFileProvider
- Throws:
Throwable
-
getCurrentDir
public String getCurrentDir()
- Specified by:
getCurrentDir
in interfaceVFSFileProvider
-
setCurrentDir
public void setCurrentDir(String path)
- Specified by:
setCurrentDir
in interfaceVFSFileProvider
-
checkPath
protected void checkPath(String path)
-
isScript
public boolean isScript(String name)
Description copied from interface:VFSFileProvider
Checks if the FQ name can be resolved to a script by this provider.- Specified by:
isScript
in 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:VFSFileProvider
Get the named item. Note that all of the names are qualified.- Specified by:
get
in interfaceVFSFileProvider
- Returns:
- Throws:
Throwable
-
put
public void put(String newPath, VFSEntry entry) throws Throwable
Description copied from interface:VFSFileProvider
Add the using the path. If and entry exists there it will be over-written.- Specified by:
put
in interfaceVFSFileProvider
- Throws:
Throwable
-
put
public void put(VFSEntry entry) throws Throwable
Description copied from interface:VFSFileProvider
Put this in the store at its current path- Specified by:
put
in interfaceVFSFileProvider
- Throws:
Throwable
-
delete
public void delete(String path) throws Throwable
Description copied from interface:VFSFileProvider
A delete is a type of write. If the store is not writeable, it cannot delete files.- Specified by:
delete
in interfaceVFSFileProvider
- Throws:
Throwable
-
contains
public boolean contains(String path) throws Throwable
Description copied from interface:VFSFileProvider
Contains is a type of read. If the store is not readable, it cannot tell if it contains an entry.- Specified by:
contains
in interfaceVFSFileProvider
- Returns:
- Throws:
Throwable
-
dir
public String[] dir(String path) throws Throwable
- Specified by:
dir
in interfaceVFSFileProvider
- Throws:
Throwable
-
isDirectory
public boolean isDirectory(String path)
- Specified by:
isDirectory
in 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:VFSFileProvider
Make a set of directories. This will make a given directory and any intermediate directories.- Specified by:
mkdir
in interfaceVFSFileProvider
- Returns:
-
rmdir
public boolean rmdir(String path) throws Throwable
Description copied from interface:VFSFileProvider
This will remove a directory. Note that this requires that the directory be empty of all files.- Specified by:
rmdir
in interfaceVFSFileProvider
- Returns:
- Throws:
Throwable
-
rm
public void rm(String path) throws Throwable
Description copied from interface:VFSFileProvider
Remove a file from the store.- Specified by:
rm
in interfaceVFSFileProvider
- Throws:
Throwable
-
easSupported
public boolean easSupported()
Description copied from interface:VFSFileProvider
If this store supports extended attributes.- Specified by:
easSupported
in interfaceVFSFileProvider
- Returns:
-
length
public long length(String path) throws Throwable
- Specified by:
length
in interfaceVFSFileProvider
- Throws:
Throwable
-
-