Package org.qdl_lang.vfs
Class FileEntry
- java.lang.Object
-
- org.qdl_lang.vfs.FileEntry
-
- All Implemented Interfaces:
Serializable
,VFSEntry
,VFSMetaEntry
- Direct Known Subclasses:
QDLScript
public class FileEntry extends Object implements VFSEntry
Generic entry for the virtual file system. Note that these are not designed to be mutable. If there is a write, just replace this object with a new one.Created by Jeff Gaynor
on 2/19/20 at 5:58 AM- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
BINARY_TYPE
static String
CONTENT
static String
CONTENT_TYPE
static String
INPUT_STREAM_TYPE
static String
TEXT_TYPE
static String
TYPE
-
Fields inherited from interface org.qdl_lang.vfs.VFSEntry
SHEBANG_REGEX
-
-
Constructor Summary
Constructors Constructor Description FileEntry(byte[] bytes)
FileEntry(byte[] bytes, edu.uiuc.ncsa.security.core.configuration.XProperties xp)
FileEntry(edu.uiuc.ncsa.security.core.configuration.XProperties xp)
FileEntry(InputStream inputStream, edu.uiuc.ncsa.security.core.configuration.XProperties xp)
FileEntry(String lines)
FileEntry(List<String> lines)
FileEntry(List<String> lines, edu.uiuc.ncsa.security.core.configuration.XProperties xp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QDLStem
convertToStem()
byte[]
getBytes()
byte[]
getContents()
InputStream
getInputStream()
In the case of actual files, the reader will be set to aReader
.List<String>
getLines()
String
getPath()
edu.uiuc.ncsa.security.core.configuration.XProperties
getProperties()
These properties are for external systems that must manage when or how the scripts are run.Object
getProperty(String key)
String
getText()
String
getText(String regexFilter)
Filters lines.String
getType()
boolean
hasContent()
boolean
isBinaryType()
boolean
isDirectory()
void
setBytes(byte[] bytes)
void
setInputStream(InputStream inputStream)
void
setLines(List<String> lines)
void
setPath(String path)
void
setProperties(edu.uiuc.ncsa.security.core.configuration.XProperties xp)
void
setProperty(String key, Object value)
-
-
-
Constructor Detail
-
FileEntry
public FileEntry(edu.uiuc.ncsa.security.core.configuration.XProperties xp)
-
FileEntry
public FileEntry(byte[] bytes)
-
FileEntry
public FileEntry(byte[] bytes, edu.uiuc.ncsa.security.core.configuration.XProperties xp)
-
FileEntry
public FileEntry(String lines)
-
FileEntry
public FileEntry(List<String> lines, edu.uiuc.ncsa.security.core.configuration.XProperties xp)
-
FileEntry
public FileEntry(InputStream inputStream, edu.uiuc.ncsa.security.core.configuration.XProperties xp)
-
-
Method Detail
-
isBinaryType
public boolean isBinaryType()
- Specified by:
isBinaryType
in interfaceVFSEntry
-
hasContent
public boolean hasContent()
-
setBytes
public void setBytes(byte[] bytes)
-
getContents
public byte[] getContents()
- Specified by:
getContents
in interfaceVFSEntry
-
getText
public String getText(String regexFilter)
Filters lines. If a line matches the regex, then it is omitted.
-
getProperties
public edu.uiuc.ncsa.security.core.configuration.XProperties getProperties()
These properties are for external systems that must manage when or how the scripts are run. For instance, if there is a version of the script. QDL does not care what version the author has of this, but it must be preserved. These are set and managed externally -- QDL itself never touches these or cares about them.- Specified by:
getProperties
in interfaceVFSEntry
- Returns:
-
setProperties
public void setProperties(edu.uiuc.ncsa.security.core.configuration.XProperties xp)
- Specified by:
setProperties
in interfaceVFSEntry
-
setProperty
public void setProperty(String key, Object value)
- Specified by:
setProperty
in interfaceVFSEntry
-
getProperty
public Object getProperty(String key)
- Specified by:
getProperty
in interfaceVFSEntry
-
convertToStem
public QDLStem convertToStem()
- Specified by:
convertToStem
in interfaceVFSEntry
-
setInputStream
public void setInputStream(InputStream inputStream)
-
getInputStream
public InputStream getInputStream()
In the case of actual files, the reader will be set to aReader
. In other cases (such as from a zip file or collection of lines in a memory VFS) about the best we can do is return a reader for iterating. Note that you should get this once and use it until you close it. This is because there are no well defined ways in Java to check if a genericInputStream
has been closed without trying something (like reading some bytes) and seeing if it throws an exception. Therefore, this will take the backing set of lines and return a new byte array output stream every time.- Specified by:
getInputStream
in interfaceVFSEntry
- Returns:
-
isDirectory
public boolean isDirectory()
- Specified by:
isDirectory
in interfaceVFSMetaEntry
-
-