Package com.inductiveautomation.snap.web
Class WebFile
- java.lang.Object
- 
- com.inductiveautomation.rm.base.RMListenerList
- 
- com.inductiveautomation.rm.base.RMObject
- 
- com.inductiveautomation.snap.web.WebFile
 
 
 
- 
- All Implemented Interfaces:
- RMJSONArchiver.GetKeys,- RMPropertyChanger,- java.lang.Cloneable,- java.lang.Comparable<WebFile>
 - Direct Known Subclasses:
- ZipFileSite.ZipDataFile
 
 public class WebFile extends RMObject implements java.lang.Comparable<WebFile>, RMJSONArchiver.GetKeys Represents a file from a WebSite.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static interfaceWebFile.UpdaterAn interface for classes that want to post modifications to files.
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringBytes_Propstatic java.lang.StringExists_Propstatic java.lang.StringFile_Propstatic java.lang.StringFiles_Propstatic java.lang.StringModifiedTime_Propstatic java.lang.StringPath_Propstatic java.lang.StringSize_Propstatic java.lang.StringUpdater_Prop
 - 
Constructor SummaryConstructors Constructor Description WebFile()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddFile(WebFile aFile)Adds a file.protected voidaddFile(WebFile aFile, int anIndex)Adds a file at given index.WebFileclone()Standard clone implementation.intcompareTo(WebFile aFile)Standard compareTo implementation.WebFilecreateFile(java.lang.String aName)Returns the file with the given name.protected WebURLcreateURL()Creates a URL for this file.protected WebURLcreateURL(java.lang.String aURL)Creates a URL for string.voiddelete()Deletes the file.booleanequals(java.lang.Object anObj)Standard equals implementation.byte[]getBytes()Returns the file bytes.protected ResponsegetContentResponse()Returns files for path.DataTypegetDataType()Returns the data type of the file.java.lang.StringgetDirPath()Returns the path as a directory (with trailing separator).booleangetExists()Returns whether file exists in data source (has been saved and, if so, not deleted).booleangetExists(boolean doConfirm)Returns whether file exists in data source (with option to confirm if file was created instead of fetched).WebFilegetFile(int anIndex)Returns the individual file at given index.WebFilegetFile(java.lang.String aName)Returns the file with the given name.intgetFileCount()Returns the number of files in this directory.intgetFileIndex(WebFile aFile)Returns the index of a file.java.util.List<java.lang.String>getFileNames()Returns the file keys.<T extends WebFile>
 java.util.List<T>getFiles()Returns the directory files list.java.util.List<WebFile>getFiles(java.lang.String aRegex)Returns the list of files that match given regex.java.io.InputStreamgetInputStream()Returns an input stream for file.intgetInsertIndex(WebFile aFile)Returns the insert index to insert a file in this directory.java.util.List<java.lang.String>getJSONKeys()RMJSONArchiver.GetKeys implementation.java.util.DategetModifiedDate()Returns the modified date.longgetModifiedTime()Returns the file modification time.java.lang.StringgetName()Returns the resource name.WebFilegetParent()Returns the file parent directory.java.lang.StringgetPath()Returns the file path.java.lang.StringgetPresentableName()Returns the Filename without extension, and with underscores replaced with spacesjava.lang.ObjectgetProp(java.lang.String aKey)Returns a file property for key.java.lang.StringgetSimpleName()Returns the file simple name.WebSitegetSite()Returns the WebSite.longgetSize()Returns the file size.java.io.FilegetStandardFile()Returns a standard java.io.File, if available.java.lang.StringgetText()Returns the file bytes as a string.java.lang.StringgetType()Returns the file type (extension without the '.').WebFile.UpdatergetUpdater()Returns the updater.WebURLgetURL()Returns the URL for this file.WebURLgetURL(java.lang.String aPath)Returns a relative URL for the given file path.java.lang.StringgetURLString()Returns the URL string for this file.inthashCode()Standard hashCode implementation.protected voidinitFiles()Initialize files.protected voidinitFiles(java.util.List<? extends WebFile> theFiles)Initialize files.booleanisBytesSet()Returns whether bytes have been set/loaded for file.booleanisDirectory()Returns whether resource is a directory.booleanisFile()Returns whether resource is a directory.booleanisRoot()Returns whether this directory is root directory.booleanisUpdateSet()Returns whether update is set and has update.voidrefresh()Revert the file from saved version.protected WebFileremoveFile(int anIndex)Removes a file at given index.protected intremoveFile(WebFile aFile)Removes given file.voidsave()Saves the file.voidsetBytes(byte[] theBytes)Sets the file bytes.protected voidsetDataType(DataType aDataType)Sets the data type for the file.voidsetDirectory(boolean aValue)Sets whether resource is a directory.protected voidsetExists(boolean aFlag)Sets whether file exists in data source (has been saved and, if so, not deleted).protected voidsetFiles(java.util.List theFiles)Sets the directory files list.voidsetModifiedTime(long aTime)Sets the file modification time.protected voidsetParent(WebFile aFile)Sets the file parent.voidsetPath(java.lang.String aPath)Sets the file path.voidsetProp(java.lang.String aKey, java.lang.Object aValue)Sets a property for a key.protected voidsetSite(WebSite aSite)Sets the WebSite.voidsetSize(long aSize)Sets the file size.voidsetText(java.lang.String aString)Sets the file bytes as a string.voidsetUpdater(WebFile.Updater anUpdater)Sets the Updater.java.lang.StringtoString()Returns a string representation of file.- 
Methods inherited from class com.inductiveautomation.rm.base.RMObjectaddPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener, sendPropertyChange
 - 
Methods inherited from class com.inductiveautomation.rm.base.RMListenerListaddListener, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, hasListeners, removeListener
 
- 
 
- 
- 
- 
Field Detail- 
Path_Proppublic static final java.lang.String Path_Prop - See Also:
- Constant Field Values
 
 - 
ModifiedTime_Proppublic static final java.lang.String ModifiedTime_Prop - See Also:
- Constant Field Values
 
 - 
Bytes_Proppublic static final java.lang.String Bytes_Prop - See Also:
- Constant Field Values
 
 - 
Size_Proppublic static final java.lang.String Size_Prop - See Also:
- Constant Field Values
 
 - 
File_Proppublic static final java.lang.String File_Prop - See Also:
- Constant Field Values
 
 - 
Files_Proppublic static final java.lang.String Files_Prop - See Also:
- Constant Field Values
 
 - 
Exists_Proppublic static final java.lang.String Exists_Prop - See Also:
- Constant Field Values
 
 - 
Updater_Proppublic static final java.lang.String Updater_Prop - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getSitepublic WebSite getSite() Returns the WebSite.
 - 
setSiteprotected void setSite(WebSite aSite) Sets the WebSite.
 - 
getURLpublic WebURL getURL() Returns the URL for this file.
 - 
createURLprotected WebURL createURL() Creates a URL for this file.
 - 
getPathpublic java.lang.String getPath() Returns the file path.
 - 
setPathpublic void setPath(java.lang.String aPath) Sets the file path.
 - 
getNamepublic java.lang.String getName() Returns the resource name.
 - 
getSimpleNamepublic java.lang.String getSimpleName() Returns the file simple name.
 - 
getPresentableNamepublic java.lang.String getPresentableName() Returns the Filename without extension, and with underscores replaced with spaces
 - 
getTypepublic java.lang.String getType() Returns the file type (extension without the '.').
 - 
getDirPathpublic java.lang.String getDirPath() Returns the path as a directory (with trailing separator).
 - 
getExistspublic boolean getExists() Returns whether file exists in data source (has been saved and, if so, not deleted).
 - 
getExistspublic boolean getExists(boolean doConfirm) Returns whether file exists in data source (with option to confirm if file was created instead of fetched).
 - 
setExistsprotected void setExists(boolean aFlag) Sets whether file exists in data source (has been saved and, if so, not deleted).
 - 
getParentpublic WebFile getParent() Returns the file parent directory.
 - 
setParentprotected void setParent(WebFile aFile) Sets the file parent.
 - 
getModifiedTimepublic long getModifiedTime() Returns the file modification time.
 - 
setModifiedTimepublic void setModifiedTime(long aTime) Sets the file modification time.
 - 
getModifiedDatepublic java.util.Date getModifiedDate() Returns the modified date.
 - 
isFilepublic boolean isFile() Returns whether resource is a directory.
 - 
isDirectorypublic boolean isDirectory() Returns whether resource is a directory.
 - 
setDirectorypublic void setDirectory(boolean aValue) Sets whether resource is a directory.
 - 
getSizepublic long getSize() Returns the file size.
 - 
setSizepublic void setSize(long aSize) Sets the file size.
 - 
getContentResponseprotected Response getContentResponse() Returns files for path.
 - 
isBytesSetpublic boolean isBytesSet() Returns whether bytes have been set/loaded for file.
 - 
getBytespublic byte[] getBytes() Returns the file bytes.
 - 
setBytespublic void setBytes(@Nullable byte[] theBytes)Sets the file bytes.
 - 
getFileCountpublic int getFileCount() Returns the number of files in this directory.
 - 
getFilepublic WebFile getFile(int anIndex) Returns the individual file at given index.
 - 
getFilespublic <T extends WebFile> java.util.List<T> getFiles() Returns the directory files list.
 - 
setFilesprotected void setFiles(java.util.List theFiles) Sets the directory files list.
 - 
initFilesprotected void initFiles() Initialize files.
 - 
initFilesprotected void initFiles(java.util.List<? extends WebFile> theFiles) Initialize files.
 - 
addFileprotected void addFile(WebFile aFile) Adds a file.
 - 
addFileprotected void addFile(WebFile aFile, int anIndex) Adds a file at given index.
 - 
removeFileprotected WebFile removeFile(int anIndex) Removes a file at given index.
 - 
removeFileprotected int removeFile(WebFile aFile) Removes given file.
 - 
createFilepublic WebFile createFile(java.lang.String aName) Returns the file with the given name.
 - 
getFilepublic WebFile getFile(java.lang.String aName) Returns the file with the given name.
 - 
getFilespublic java.util.List<WebFile> getFiles(java.lang.String aRegex) Returns the list of files that match given regex.
 - 
getFileIndexpublic int getFileIndex(WebFile aFile) Returns the index of a file.
 - 
getInsertIndexpublic int getInsertIndex(WebFile aFile) Returns the insert index to insert a file in this directory.
 - 
getFileNamespublic java.util.List<java.lang.String> getFileNames() Returns the file keys.
 - 
getDataTypepublic DataType getDataType() Returns the data type of the file.
 - 
setDataTypeprotected void setDataType(DataType aDataType) Sets the data type for the file.
 - 
getProppublic java.lang.Object getProp(java.lang.String aKey) Returns a file property for key.
 - 
setProppublic void setProp(java.lang.String aKey, java.lang.Object aValue)Sets a property for a key.
 - 
isUpdateSetpublic boolean isUpdateSet() Returns whether update is set and has update.
 - 
getUpdaterpublic WebFile.Updater getUpdater() Returns the updater.
 - 
setUpdaterpublic void setUpdater(WebFile.Updater anUpdater) Sets the Updater.
 - 
savepublic void save() throws ResponseExceptionSaves the file.- Throws:
- ResponseException
 
 - 
deletepublic void delete() throws ResponseExceptionDeletes the file.- Throws:
- ResponseException
 
 - 
refreshpublic void refresh() Revert the file from saved version.
 - 
isRootpublic boolean isRoot() Returns whether this directory is root directory.
 - 
getURLStringpublic java.lang.String getURLString() Returns the URL string for this file.
 - 
getTextpublic java.lang.String getText() Returns the file bytes as a string.
 - 
setTextpublic void setText(java.lang.String aString) Sets the file bytes as a string.
 - 
getInputStreampublic java.io.InputStream getInputStream() Returns an input stream for file.
 - 
getStandardFilepublic java.io.File getStandardFile() Returns a standard java.io.File, if available.
 - 
getURLpublic WebURL getURL(java.lang.String aPath) Returns a relative URL for the given file path.
 - 
createURLprotected WebURL createURL(java.lang.String aURL) Creates a URL for string.
 - 
equalspublic boolean equals(java.lang.Object anObj) Standard equals implementation.- Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() Standard hashCode implementation.- Overrides:
- hashCodein class- java.lang.Object
 
 - 
compareTopublic int compareTo(WebFile aFile) Standard compareTo implementation.- Specified by:
- compareToin interface- java.lang.Comparable<WebFile>
 
 - 
clonepublic WebFile clone() Standard clone implementation.- Overrides:
- clonein class- RMListenerList
 
 - 
getJSONKeyspublic java.util.List<java.lang.String> getJSONKeys() RMJSONArchiver.GetKeys implementation.- Specified by:
- getJSONKeysin interface- RMJSONArchiver.GetKeys
 
 
- 
 
-