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 booleanequals(ISourceFile file)File equality checklonggetArchiveId()Get the id for the immediate parent submission, this may not be the top level submission seen by the userjava.lang.StringgetDisplayFileSize(boolean si)Fetches the file size in String form with the correct extensionjava.io.InputStreamgetFileContents()java.lang.StringgetFileContentsAsString()java.util.List<java.lang.String>getFileContentsAsStringList()java.lang.StringgetFileDisplayName()java.lang.StringgetFileDisplayPath()java.lang.StringgetFileIdentifier()longgetFileSize()Fetches the file size in bytesjava.lang.StringgetHash()intgetNonEmptyLineCount()Count of the number of lines in the file containing characters, non emptylonggetPersistentId()byte[]getSecureParam()ISubmissiongetSubmission()Get the top level, "super parent", submission object, this is the submission for this file seen by the user, NOT a sub-directoryjava.sql.TimestampgetTimestamp()intgetTotalLineCount()Count of the total number of lines in the filevoidremove()Remove the filevoidsetHash(java.lang.String hash)voidsetSecureParam(byte[] secure)java.lang.StringtoString()
-
-
-
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:ISourceFileFile equality check- Specified by:
equalsin interfaceISourceFile- Parameters:
file- file to compare- Returns:
- equals
-
getArchiveId
public long getArchiveId()
Description copied from interface:ISourceFileGet the id for the immediate parent submission, this may not be the top level submission seen by the user- Specified by:
getArchiveIdin interfaceISourceFile- Returns:
- the id for the submission
-
getDisplayFileSize
public java.lang.String getDisplayFileSize(boolean si)
Description copied from interface:ISourceFileFetches the file size in String form with the correct extension- Specified by:
getDisplayFileSizein 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:
getFileContentsin interfaceISourceFile- Returns:
- the content of the file
-
getFileContentsAsString
public java.lang.String getFileContentsAsString()
- Specified by:
getFileContentsAsStringin interfaceISourceFile- Returns:
- the content of the file as a string
-
getFileContentsAsStringList
public java.util.List<java.lang.String> getFileContentsAsStringList()
- Specified by:
getFileContentsAsStringListin interfaceISourceFile- Returns:
- the content of the file as a list of strings
-
getFileDisplayName
public java.lang.String getFileDisplayName()
- Specified by:
getFileDisplayNamein interfaceISourceFile- Returns:
- string containing display formatted file name
-
getFileDisplayPath
public java.lang.String getFileDisplayPath()
- Specified by:
getFileDisplayPathin interfaceISourceFile- Returns:
- string containing display formatted file path
-
getFileIdentifier
public java.lang.String getFileIdentifier()
- Specified by:
getFileIdentifierin interfaceISourceFile- Returns:
- a web path safe file identifier
-
getFileSize
public long getFileSize()
Description copied from interface:ISourceFileFetches the file size in bytes- Specified by:
getFileSizein 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:ISourceFileCount of the number of lines in the file containing characters, non empty- Specified by:
getNonEmptyLineCountin interfaceISourceFile- Returns:
- count of non empty lines
-
getPersistentId
public long getPersistentId()
- Specified by:
getPersistentIdin 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:ISourceFileGet the top level, "super parent", submission object, this is the submission for this file seen by the user, NOT a sub-directory- Specified by:
getSubmissionin interfaceISourceFile- Returns:
- the highest level parent submission
-
getTimestamp
public java.sql.Timestamp getTimestamp()
-
getTotalLineCount
public int getTotalLineCount()
Description copied from interface:ISourceFileCount of the total number of lines in the file- Specified by:
getTotalLineCountin interfaceISourceFile- Returns:
- count of all lines
-
remove
public void remove()
Description copied from interface:ISourceFileRemove the file- Specified by:
removein interfaceISourceFile
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-