Package snap.web

Class WebFile

All Implemented Interfaces:
Comparable<WebFile>, PropChange.DoChange

public class WebFile extends PropObject implements Comparable<WebFile>
Represents a file from a WebSite.
  • Field Details

  • Constructor Details

    • WebFile

      public WebFile()
      Constructor.
  • Method Details

    • getSite

      public WebSite getSite()
      Returns the WebSite.
    • getParent

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

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

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

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

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

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

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

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

      public String getUrlString()
      Returns the URL string.
    • isDir

      public boolean isDir()
      Returns whether file is a directory.
    • isFile

      public boolean isFile()
      Returns whether file is a plain file.
    • isRoot

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

      public boolean isVerified()
      Returns whether Exists property has been explicitly set/checked.
    • getExists

      public boolean getExists()
      Returns whether file exists in site.
    • setExists

      protected void setExists(Boolean aValue)
      Sets whether file is known to exist at site.
    • getModTime

      public long getModTime()
      Returns the file modification time.
    • setModTime

      protected void setModTime(long aValue)
      Sets the file modification time.
    • getSize

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

      protected void setSize(long aSize)
      Sets the file size.
    • getBytes

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

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

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

      public WebFile[] getFiles()
      Returns the directory files list.
    • save

      public WebResponse save()
      Saves the file.
    • delete

      public WebResponse delete()
      Deletes the file.
    • reset

      public void reset()
      Resets the file to unverified state where nothing is known about size, mod-time, saved.
    • resetContent

      public void resetContent()
      Resets the file to unloaded state so files/bytes are cleared (to reload when next called).
    • reload

      public void reload()
      Resets a file with check to have parent resetContent() if file is deleted.
    • getFileForName

      public WebFile getFileForName(String aName)
      Returns the file with the given name.
    • isModifiedExternally

      public boolean isModifiedExternally()
      Returns whether file has been modified at site (outside this process).
    • containsFile

      public boolean containsFile(WebFile aFile)
      Returns whether given file is contained in this directory.
    • getMimeType

      public String getMimeType()
      Returns the MIME type of the file.
    • setMimeType

      protected void setMimeType(String aMIMEType)
      Sets the MIME 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.
    • isModified

      public boolean isModified()
      Returns whether this file has been modified locally.
    • setModified

      protected void setModified(boolean aValue)
      Sets whether this file has been modified locally.
    • 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.
    • getLinkFile

      public WebFile getLinkFile()
      Returns the link file, if this file really points to another.
    • setLinkFile

      protected void setLinkFile(WebFile aFile)
      Sets the link file, if this file really points to another.
    • getRealFile

      public WebFile getRealFile()
      Returns the real file.
    • setModTimeSaved

      public void setModTimeSaved(long aValue)
      Sets the file modification time in file and in site internal storage.
    • getModDate

      public Date getModDate()
      Returns the modified date.
    • getLastModTime

      public long getLastModTime()
      Conventional file method that simply wraps getModTime().
    • isText

      public boolean isText()
      Returns whether response is text (regardless of what the data type is).
    • 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.
    • getJavaFile

      public File getJavaFile()
      Returns a standard Java File (if available).
    • getURL

      public WebURL getURL(String aPath)
      Returns a relative URL for the given file path.
    • 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>
    • toString

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