Package snap.web
Class WebFile
java.lang.Object
snap.props.PropObject
snap.web.WebFile
- All Implemented Interfaces:
Comparable<WebFile>
,PropChange.DoChange
Represents a file from a WebSite.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
An interface for classes that want to post modifications to files. -
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected Boolean
protected long
protected boolean
protected String
protected WebSite
protected long
protected WebURL
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class snap.props.PropObject
_pcs, EMPTY_OBJECT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Standard compareTo implementation.boolean
containsFile
(WebFile aFile) Returns whether given file is contained in this directory.static WebFile
createFileForPath
(String filePath, boolean isDir) Creates a WebFile for given file path.static WebFile
createTempFileForName
(String filename, boolean isDir) Create a temp WebFile for given file name.delete()
Deletes the file.boolean
Standard equals implementation.byte[]
getBytes()
Returns the file bytes.Returns the path as a directory (with trailing separator).boolean
Returns whether file exists in site.int
Returns the number of files in this directory.static WebFile
getFileForJavaFile
(File aFile) Returns a WebFile for given Java file.getFileForName
(String aName) Returns the file with the given name.static WebFile
getFileForPath
(String filePath) Returns a WebFile for given file path.static WebFile
getFileForSource
(Object fileSource) Returns a WebFile for given source.WebFile[]
getFiles()
Returns the directory files list.Returns the file type (extension without the '.').Returns an input stream for file.Returns a standard Java File (if available).Returns the modified date.long
Returns the file last modified time.Returns the link file, if this file really points to another.Returns the MIME type of the file.getName()
Returns the resource name.Returns the file parent directory.getPath()
Returns the file path.Returns a file property for key.Returns the real file.Returns the file simple name.getSite()
Returns the WebSite.long
getSize()
Returns the file size.getText()
Returns the file bytes as a string.Returns the updater.getURL()
Returns the URL for this file.Returns a relative URL for the given file path.Returns the URL address string.int
hashCode()
Standard hashCode implementation.boolean
isDir()
Returns whether file is a directory.boolean
isFile()
Returns whether file is a plain file.boolean
Returns whether this file has been modified locally.boolean
Returns whether file has been modified at site (outside this process).boolean
isRoot()
Returns whether this file is root directory.boolean
isText()
Returns whether response is text (regardless of what the data type is).boolean
Returns whether update is set and has update.boolean
Returns whether Exists property has been explicitly set/checked.void
reset()
Resets the file to unverified state where nothing is known about size, mod-time, saved.void
Resets a file with check to make sure Exists and LastModTime properties are updated (and prop changes fired) if appropriate.save()
Saves the file.void
saveLastModTime
(long aValue) Sets the file modification time in file and in site internal storage.void
setBytes
(byte[] theBytes) Sets the file bytes.protected void
setExists
(boolean aValue) Sets whether file is known to exist at site.protected void
setLastModTime
(long aValue) Sets the file last modified time.protected void
setLinkFile
(WebFile aFile) Sets the link file, if this file really points to another.protected void
setMimeType
(String aMIMEType) Sets the MIME type for the file.protected void
setModified
(boolean aValue) Sets whether this file has been modified locally.protected void
Sets the file parent.void
Sets a property for a key.protected void
setSize
(long aSize) Sets the file size.void
Sets the file bytes as a string.void
setUpdater
(WebFile.Updater anUpdater) Sets the Updater.toString()
Returns a string representation of file.Methods inherited from class snap.props.PropObject
addDeepChangeListener, addPropChangeListener, addPropChangeListener, clone, firePropChange, firePropChange, firePropChange, getPropDefault, getPropForName, getPropParent, getPropSet, getPropsForArchival, getPropsForArchivalExtra, getPropsString, getPropValue, initProps, isPropDefault, processPropChange, removeDeepChangeListener, removePropChangeListener, removePropChangeListener, setPropsString, setPropValue, setPropValues, toStringProps
-
Field Details
-
_site
-
_path
-
_dir
protected boolean _dir -
_lastModTime
protected long _lastModTime -
_size
protected long _size -
_exists
-
_url
-
_modified
protected boolean _modified -
Bytes_Prop
- See Also:
-
Size_Prop
- See Also:
-
LastModTime_Prop
- See Also:
-
Modified_Prop
- See Also:
-
Updater_Prop
- See Also:
-
Exists_Prop
- See Also:
-
-
Constructor Details
-
WebFile
public WebFile()Constructor.
-
-
Method Details
-
getSite
Returns the WebSite. -
getParent
Returns the file parent directory. -
setParent
Sets the file parent. -
getPath
Returns the file path. -
getName
Returns the resource name. -
getSimpleName
Returns the file simple name. -
getFileType
Returns the file type (extension without the '.'). -
getDirPath
Returns the path as a directory (with trailing separator). -
getURL
Returns the URL for this file. -
getUrlAddress
Returns the URL address 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. -
getLastModTime
public long getLastModTime()Returns the file last modified time. -
setLastModTime
protected void setLastModTime(long aValue) Sets the file last modified time. -
saveLastModTime
public void saveLastModTime(long aValue) Sets the file modification time in file and in site internal storage. -
getLastModDate
Returns the modified date. -
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
Returns the directory files list. -
save
Saves the file. -
delete
Deletes the file. -
reset
public void reset()Resets the file to unverified state where nothing is known about size, mod-time, saved. -
resetAndVerify
public void resetAndVerify()Resets a file with check to make sure Exists and LastModTime properties are updated (and prop changes fired) if appropriate. -
getFileForName
Returns the file with the given name. -
isModifiedExternally
public boolean isModifiedExternally()Returns whether file has been modified at site (outside this process). -
containsFile
Returns whether given file is contained in this directory. -
getMimeType
Returns the MIME type of the file. -
setMimeType
Sets the MIME type for the file. -
getProp
Returns a file property for key. -
setProp
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
Returns the updater. -
setUpdater
Sets the Updater. -
getLinkFile
Returns the link file, if this file really points to another. -
setLinkFile
Sets the link file, if this file really points to another. -
getRealFile
Returns the real file. -
isText
public boolean isText()Returns whether response is text (regardless of what the data type is). -
getText
Returns the file bytes as a string. -
setText
Sets the file bytes as a string. -
getInputStream
Returns an input stream for file. -
getJavaFile
Returns a standard Java File (if available). -
getURL
Returns a relative URL for the given file path. -
equals
Standard equals implementation. -
hashCode
public int hashCode()Standard hashCode implementation. -
compareTo
Standard compareTo implementation.- Specified by:
compareTo
in interfaceComparable<WebFile>
-
toString
Returns a string representation of file.- Overrides:
toString
in classPropObject
-
getFileForSource
Returns a WebFile for given source. -
getFileForPath
Returns a WebFile for given file path. -
createFileForPath
Creates a WebFile for given file path. -
createTempFileForName
Create a temp WebFile for given file name. -
getFileForJavaFile
Returns a WebFile for given Java file.
-