Class WebFile

All Implemented Interfaces:
RMJSONArchiver.GetKeys, RMPropertyChanger, Cloneable, Comparable<WebFile>
Direct Known Subclasses:
ZipFileSite.ZipDataFile

public class WebFile extends RMObject implements Comparable<WebFile>, RMJSONArchiver.GetKeys
Represents a file from a WebSite.
  • Field Details

  • Constructor Details

    • WebFile

      public WebFile()
  • Method Details

    • getSite

      public WebSite getSite()
      Returns the WebSite.
    • setSite

      protected void setSite(WebSite aSite)
      Sets the WebSite.
    • getURL

      public WebURL getURL()
      Returns the URL for this file.
    • createURL

      protected WebURL createURL()
      Creates a URL for this file.
    • getPath

      public String getPath()
      Returns the file path.
    • setPath

      public void setPath(String aPath)
      Sets the file path.
    • getName

      public String getName()
      Returns the resource name.
    • getSimpleName

      public String getSimpleName()
      Returns the file simple name.
    • getPresentableName

      public String getPresentableName()
      Returns the Filename without extension, and with underscores replaced with spaces
    • getType

      public String getType()
      Returns the file type (extension without the '.').
    • getDirPath

      public String getDirPath()
      Returns the path as a directory (with trailing separator).
    • getExists

      public boolean getExists()
      Returns whether file exists in data source (has been saved and, if so, not deleted).
    • getExists

      public boolean getExists(boolean doConfirm)
      Returns whether file exists in data source (with option to confirm if file was created instead of fetched).
    • setExists

      protected void setExists(boolean aFlag)
      Sets whether file exists in data source (has been saved and, if so, not deleted).
    • getParent

      public WebFile getParent()
      Returns the file parent directory.
    • setParent

      protected void setParent(WebFile aFile)
      Sets the file parent.
    • getModifiedTime

      public long getModifiedTime()
      Returns the file modification time.
    • setModifiedTime

      public void setModifiedTime(long aTime)
      Sets the file modification time.
    • getModifiedDate

      public Date getModifiedDate()
      Returns the modified date.
    • isFile

      public boolean isFile()
      Returns whether resource is a directory.
    • isDirectory

      public boolean isDirectory()
      Returns whether resource is a directory.
    • setDirectory

      public void setDirectory(boolean aValue)
      Sets whether resource is a directory.
    • getSize

      public long getSize()
      Returns the file size.
    • setSize

      public void setSize(long aSize)
      Sets the file size.
    • getContentResponse

      protected Response getContentResponse()
      Returns files for path.
    • isBytesSet

      public boolean isBytesSet()
      Returns whether bytes have been set/loaded for file.
    • getBytes

      public byte[] getBytes()
      Returns the file bytes.
    • setBytes

      public void setBytes(@Nullable byte[] theBytes)
      Sets the file bytes.
    • getFileCount

      public int getFileCount()
      Returns the number of files in this directory.
    • getFile

      public WebFile getFile(int anIndex)
      Returns the individual file at given index.
    • getFiles

      public <T extends WebFile> List<T> getFiles()
      Returns the directory files list.
    • setFiles

      protected void setFiles(List theFiles)
      Sets the directory files list.
    • initFiles

      protected void initFiles()
      Initialize files.
    • initFiles

      protected void initFiles(List<? extends WebFile> theFiles)
      Initialize files.
    • addFile

      protected void addFile(WebFile aFile)
      Adds a file.
    • addFile

      protected void addFile(WebFile aFile, int anIndex)
      Adds a file at given index.
    • removeFile

      protected WebFile removeFile(int anIndex)
      Removes a file at given index.
    • removeFile

      protected int removeFile(WebFile aFile)
      Removes given file.
    • createFile

      public WebFile createFile(String aName)
      Returns the file with the given name.
    • getFile

      public WebFile getFile(String aName)
      Returns the file with the given name.
    • getFiles

      public List<WebFile> getFiles(String aRegex)
      Returns the list of files that match given regex.
    • getFileIndex

      public int getFileIndex(WebFile aFile)
      Returns the index of a file.
    • getInsertIndex

      public int getInsertIndex(WebFile aFile)
      Returns the insert index to insert a file in this directory.
    • getFileNames

      public List<String> getFileNames()
      Returns the file keys.
    • getDataType

      public DataType getDataType()
      Returns the data type of the file.
    • setDataType

      protected void setDataType(DataType aDataType)
      Sets the data type for the file.
    • getProp

      public Object getProp(String aKey)
      Returns a file property for key.
    • setProp

      public void setProp(String aKey, Object aValue)
      Sets a property for a key.
    • isUpdateSet

      public boolean isUpdateSet()
      Returns whether update is set and has update.
    • getUpdater

      public WebFile.Updater getUpdater()
      Returns the updater.
    • setUpdater

      public void setUpdater(WebFile.Updater anUpdater)
      Sets the Updater.
    • save

      public void save() throws ResponseException
      Saves the file.
      Throws:
      ResponseException
    • delete

      public void delete() throws ResponseException
      Deletes the file.
      Throws:
      ResponseException
    • refresh

      public void refresh()
      Revert the file from saved version.
    • isRoot

      public boolean isRoot()
      Returns whether this directory is root directory.
    • getURLString

      public String getURLString()
      Returns the URL string for this file.
    • getText

      public String getText()
      Returns the file bytes as a string.
    • setText

      public void setText(String aString)
      Sets the file bytes as a string.
    • getInputStream

      public InputStream getInputStream()
      Returns an input stream for file.
    • getStandardFile

      public File getStandardFile()
      Returns a standard java.io.File, if available.
    • getURL

      public WebURL getURL(String aPath)
      Returns a relative URL for the given file path.
    • createURL

      protected WebURL createURL(String aURL)
      Creates a URL for string.
    • equals

      public boolean equals(Object anObj)
      Standard equals implementation.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Standard hashCode implementation.
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(WebFile aFile)
      Standard compareTo implementation.
      Specified by:
      compareTo in interface Comparable<WebFile>
    • clone

      public WebFile clone()
      Standard clone implementation.
      Overrides:
      clone in class RMListenerList
    • getJSONKeys

      public List<String> getJSONKeys()
      RMJSONArchiver.GetKeys implementation.
      Specified by:
      getJSONKeys in interface RMJSONArchiver.GetKeys
    • toString

      public String toString()
      Returns a string representation of file.
      Overrides:
      toString in class RMObject