Package org.fife.ui.rsyntaxtextarea
Class FileLocation
- java.lang.Object
-
- org.fife.ui.rsyntaxtextarea.FileLocation
-
- Direct Known Subclasses:
FileFileLocation
,URLFileLocation
public abstract class FileLocation extends java.lang.Object
Holds the location of a local or remote file. This provides a common way to read, write, and check properties of both local and remote files.- Version:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description FileLocation()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static FileLocation
create(java.io.File file)
Creates aFileLocation
instance for the specified local file.static FileLocation
create(java.lang.String fileFullPath)
Creates aFileLocation
instance for the specified local file.static FileLocation
create(java.net.URL url)
Creates aFileLocation
instance for the specified file.protected abstract long
getActualLastModified()
Returns the last time this file was modified, orTextEditorPane.LAST_MODIFIED_UNKNOWN
if this value cannot be computed (such as for a remote file).abstract java.lang.String
getFileFullPath()
Returns the full path to the file.abstract java.lang.String
getFileName()
Returns the name of the file.protected abstract java.io.InputStream
getInputStream()
Opens an input stream for reading from this file.protected abstract java.io.OutputStream
getOutputStream()
Opens an output stream for writing this file.abstract boolean
isLocal()
Returns whether this file location is a local file.abstract boolean
isLocalAndExists()
Returns whether this file location is a local file that already exists.boolean
isRemote()
Returns whether this file location is a remote location.
-
-
-
Method Detail
-
create
public static FileLocation create(java.lang.String fileFullPath)
Creates aFileLocation
instance for the specified local file.- Parameters:
fileFullPath
- The full path to a local file.- Returns:
- The file's location.
-
create
public static FileLocation create(java.io.File file)
Creates aFileLocation
instance for the specified local file.- Parameters:
file
- A local file.- Returns:
- The file's location.
-
create
public static FileLocation create(java.net.URL url)
Creates aFileLocation
instance for the specified file.- Parameters:
url
- The URL of a file.- Returns:
- The file's location.
-
getActualLastModified
protected abstract long getActualLastModified()
Returns the last time this file was modified, orTextEditorPane.LAST_MODIFIED_UNKNOWN
if this value cannot be computed (such as for a remote file).- Returns:
- The last time this file was modified.
-
getFileFullPath
public abstract java.lang.String getFileFullPath()
Returns the full path to the file. This will be stripped of sensitive information such as passwords for remote files.- Returns:
- The full path to the file.
- See Also:
getFileName()
-
getFileName
public abstract java.lang.String getFileName()
Returns the name of the file.- Returns:
- The name of the file.
- See Also:
getFileFullPath()
-
getInputStream
protected abstract java.io.InputStream getInputStream() throws java.io.IOException
Opens an input stream for reading from this file.- Returns:
- The input stream.
- Throws:
java.io.IOException
- If the file does not exist, or some other IO error occurs.
-
getOutputStream
protected abstract java.io.OutputStream getOutputStream() throws java.io.IOException
Opens an output stream for writing this file.- Returns:
- An output stream.
- Throws:
java.io.IOException
- If an IO error occurs.
-
isLocal
public abstract boolean isLocal()
Returns whether this file location is a local file.- Returns:
- Whether this is a local file.
- See Also:
isLocalAndExists()
-
isLocalAndExists
public abstract boolean isLocalAndExists()
Returns whether this file location is a local file that already exists.- Returns:
- Whether this file is local and actually exists.
- See Also:
isLocal()
-
isRemote
public boolean isRemote()
Returns whether this file location is a remote location.- Returns:
- Whether this is a remote file location.
-
-