Class EntityFile
- java.lang.Object
-
- uk.ac.warwick.dcs.sherlock.engine.storage.EntityFile
-
- All Implemented Interfaces:
java.io.Serializable
,ISourceFile
@Entity(name="File") public class EntityFile extends java.lang.Object implements ISourceFile, java.io.Serializable
ISourceFile object for base storage implementation- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description EntityFile(EntityArchive archive, java.lang.String filename, java.lang.String extension, java.sql.Timestamp timestamp, long size, int line, int contentLine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(ISourceFile file)
File equality checklong
getArchiveId()
Get the id for the immediate parent submission, this may not be the top level submission seen by the userjava.lang.String
getDisplayFileSize(boolean si)
Fetches the file size in String form with the correct extensionjava.io.InputStream
getFileContents()
java.lang.String
getFileContentsAsString()
java.util.List<java.lang.String>
getFileContentsAsStringList()
java.lang.String
getFileDisplayName()
java.lang.String
getFileDisplayPath()
java.lang.String
getFileIdentifier()
long
getFileSize()
Fetches the file size in bytesjava.lang.String
getHash()
int
getNonEmptyLineCount()
Count of the number of lines in the file containing characters, non emptylong
getPersistentId()
byte[]
getSecureParam()
ISubmission
getSubmission()
Get the top level, "super parent", submission object, this is the submission for this file seen by the user, NOT a sub-directoryjava.sql.Timestamp
getTimestamp()
int
getTotalLineCount()
Count of the total number of lines in the filevoid
remove()
Remove the filevoid
setHash(java.lang.String hash)
void
setSecureParam(byte[] secure)
java.lang.String
toString()
-
-
-
Constructor Detail
-
EntityFile
public EntityFile(EntityArchive archive, java.lang.String filename, java.lang.String extension, java.sql.Timestamp timestamp, long size, int line, int contentLine)
-
-
Method Detail
-
equals
public boolean equals(ISourceFile file)
Description copied from interface:ISourceFile
File equality check- Specified by:
equals
in interfaceISourceFile
- Parameters:
file
- file to compare- Returns:
- equals
-
getArchiveId
public long getArchiveId()
Description copied from interface:ISourceFile
Get the id for the immediate parent submission, this may not be the top level submission seen by the user- Specified by:
getArchiveId
in interfaceISourceFile
- Returns:
- the id for the submission
-
getDisplayFileSize
public java.lang.String getDisplayFileSize(boolean si)
Description copied from interface:ISourceFile
Fetches the file size in String form with the correct extension- Specified by:
getDisplayFileSize
in interfaceISourceFile
- Parameters:
si
- use SI (1000) or binary (1024) for calculations- Returns:
- string for the file size
-
getFileContents
public java.io.InputStream getFileContents()
- Specified by:
getFileContents
in interfaceISourceFile
- Returns:
- the content of the file
-
getFileContentsAsString
public java.lang.String getFileContentsAsString()
- Specified by:
getFileContentsAsString
in interfaceISourceFile
- Returns:
- the content of the file as a string
-
getFileContentsAsStringList
public java.util.List<java.lang.String> getFileContentsAsStringList()
- Specified by:
getFileContentsAsStringList
in interfaceISourceFile
- Returns:
- the content of the file as a list of strings
-
getFileDisplayName
public java.lang.String getFileDisplayName()
- Specified by:
getFileDisplayName
in interfaceISourceFile
- Returns:
- string containing display formatted file name
-
getFileDisplayPath
public java.lang.String getFileDisplayPath()
- Specified by:
getFileDisplayPath
in interfaceISourceFile
- Returns:
- string containing display formatted file path
-
getFileIdentifier
public java.lang.String getFileIdentifier()
- Specified by:
getFileIdentifier
in interfaceISourceFile
- Returns:
- a web path safe file identifier
-
getFileSize
public long getFileSize()
Description copied from interface:ISourceFile
Fetches the file size in bytes- Specified by:
getFileSize
in interfaceISourceFile
- Returns:
- file size in bytes
-
getHash
public java.lang.String getHash()
-
setHash
public void setHash(java.lang.String hash)
-
getNonEmptyLineCount
public int getNonEmptyLineCount()
Description copied from interface:ISourceFile
Count of the number of lines in the file containing characters, non empty- Specified by:
getNonEmptyLineCount
in interfaceISourceFile
- Returns:
- count of non empty lines
-
getPersistentId
public long getPersistentId()
- Specified by:
getPersistentId
in interfaceISourceFile
- Returns:
- fetches a unique, persistent id for the file. No other file should EVER be able to take this ID, even if this file is deleted.
-
getSecureParam
public byte[] getSecureParam()
-
setSecureParam
public void setSecureParam(byte[] secure)
-
getSubmission
public ISubmission getSubmission()
Description copied from interface:ISourceFile
Get the top level, "super parent", submission object, this is the submission for this file seen by the user, NOT a sub-directory- Specified by:
getSubmission
in interfaceISourceFile
- Returns:
- the highest level parent submission
-
getTimestamp
public java.sql.Timestamp getTimestamp()
-
getTotalLineCount
public int getTotalLineCount()
Description copied from interface:ISourceFile
Count of the total number of lines in the file- Specified by:
getTotalLineCount
in interfaceISourceFile
- Returns:
- count of all lines
-
remove
public void remove()
Description copied from interface:ISourceFile
Remove the file- Specified by:
remove
in interfaceISourceFile
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-