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 StringBINARY_TYPEstatic StringCONTENTstatic StringCONTENT_TYPEstatic StringINPUT_STREAM_TYPEstatic StringTEXT_TYPEstatic StringTYPE-
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 QDLStemconvertToStem()byte[]getBytes()byte[]getContents()InputStreamgetInputStream()In the case of actual files, the reader will be set to aReader.List<String>getLines()StringgetPath()edu.uiuc.ncsa.security.core.configuration.XPropertiesgetProperties()These properties are for external systems that must manage when or how the scripts are run.ObjectgetProperty(String key)StringgetText()StringgetText(String regexFilter)Filters lines.StringgetType()booleanhasContent()booleanisBinaryType()booleanisDirectory()protected StringlinesToString()voidsetBytes(byte[] bytes)voidsetInputStream(InputStream inputStream)voidsetLines(List<String> lines)voidsetPath(String path)voidsetProperties(edu.uiuc.ncsa.security.core.configuration.XProperties xp)voidsetProperty(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:
isBinaryTypein interfaceVFSEntry
-
hasContent
public boolean hasContent()
-
setBytes
public void setBytes(byte[] bytes)
-
getContents
public byte[] getContents()
- Specified by:
getContentsin interfaceVFSEntry
-
getText
public String getText(String regexFilter)
Filters lines. If a line matches the regex, then it is omitted.
-
linesToString
protected String linesToString()
-
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:
getPropertiesin interfaceVFSEntry- Returns:
-
setProperties
public void setProperties(edu.uiuc.ncsa.security.core.configuration.XProperties xp)
- Specified by:
setPropertiesin interfaceVFSEntry
-
setProperty
public void setProperty(String key, Object value)
- Specified by:
setPropertyin interfaceVFSEntry
-
getProperty
public Object getProperty(String key)
- Specified by:
getPropertyin interfaceVFSEntry
-
convertToStem
public QDLStem convertToStem()
- Specified by:
convertToStemin 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 genericInputStreamhas 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:
getInputStreamin interfaceVFSEntry- Returns:
-
isDirectory
public boolean isDirectory()
- Specified by:
isDirectoryin interfaceVFSMetaEntry
-
-