org.eclipse.rse.subsystems.files.core.subsystems
Class RemoteFile
java.lang.Object
org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile
-
All Implemented Interfaces:
-
Comparable,
IAdaptable,
ISchedulingRule,
ISystemContainer,
IRemoteContainer,
IRemotePropertyHolder,
IRemoteFile
-
Direct Known Subclasses:
-
AbstractRemoteFile,
RemoteFileEmpty,
RemoteFileRoot
-
public abstract class RemoteFile
- extends
Object
- implements
IRemoteFile,
IAdaptable,
Comparable
A remote file represents a named file on a remote file system. This class
works with remote file names that do not include the preceding ""
prefix. Such ultimately-qualified names are known as IRemoteFilePath names.
Base parent class that supplies all of the
functionality required by the IRemoteFile interface.
This base functionality is possible because this is a
read-only representation of a remote file ... all actions
like delete and rename are handled by the subsystem.
For all this base functionality to work, the subsystem
that creates this object must call the setter methods to
prefill this object with the core required information:
A concrete implementation which extends this class, also needs to ensure
that information is properly set by some means such that the
IRemoteFile.exists()
,
IRemoteFile.getAbsolutePath()
,
IRemoteFile.getLength()
and similar methods can be implemented.
Method Summary
|
int
|
compareTo
(
Object other)
Compare one remote file to another. |
boolean
|
contains
(
ISchedulingRule rule)
|
protected boolean
|
containsFilterKey
(
HashMap filters,
String filter)
|
void
|
copyContentsTo
(
IRemoteContainer target)
Copies the persistable contents from this one to another one |
boolean
|
equals
(
Object otherObj)
|
String
|
getAbsolutePathPlusConnection
()
Get fully qualified connection and file name: connection:\path\file
Note the separator character between the profile name and the connection name is always '.' |
Object
|
getAdapter
(
Class adapterType)
This is the method required by the IAdaptable interface. |
RemoteFileFilterString[]
|
getAllFilterStrings
()
If this is a folder, it is possible that it is listed as part of a multiple filter string
filter. |
String
|
getComment
()
|
Object[]
|
getContents
(
ISystemContentsType contentsType)
Returns all the contents of the object (combining results of all filters |
Object[]
|
getContents
(
ISystemContentsType contentsType,
String filter)
Returns the contents of the object. |
IRemoteFileContext
|
getContext
()
Return the context associated with this remote file |
String
|
getEncoding
()
Returns the encoding of the remote file. |
String
|
getExtension
()
Return the extension part of a file name. |
Object
|
getFile
()
Get the object. |
RemoteFileFilterString
|
getFilterString
()
Return the filter string resolved to get this object |
IHost
|
getHost
()
Return the connection this remote file is from. |
String
|
getHostName
()
|
String
|
getLabel
()
Get the display name for this file. |
Date
|
getLastModifiedDate
()
Return the last modified time as a Date object. |
String
|
getLineSeparator
()
Return as a string the line separator character values |
IRemoteFile
|
getParentRemoteFile
()
Return the parent remote file object expanded to get this object, or null if no such parent |
IRemoteFileSubSystem
|
getParentRemoteFileSubSystem
()
Return the parent subsystem |
IRemoteFileSubSystemConfiguration
|
getParentRemoteFileSubSystemConfiguration
()
Return the parent subsystem factory |
IHostFilePermissions
|
getPermissions
()
Returns the permissions for this file if they exist |
Object[]
|
getProperties
(
String[] keys)
Returns the value of the properties with the given keys. |
Object
|
getProperty
(
String key)
Returns the value of the property with the given key. |
String
|
getSeparator
()
Return the separator character for this file system, as a string: "\" or "/". |
char
|
getSeparatorChar
()
Return the separator character for this file system: \ or /. |
boolean
|
hasContents
(
ISystemContentsType contentsType)
Returns whether the object has contents of a particular type. |
boolean
|
hasContents
(
ISystemContentsType contentsType,
String filter)
Returns whether the object has contents of a particular type associated with the specified filter string. |
boolean
|
isAncestorOf
(
IRemoteFile file)
Note: if this remoteFile is the same as the file passed
as parameter, then this method returns true. |
boolean
|
isArchive
()
Returns true if this represents an archive file, versues a non-archive file |
boolean
|
isBinary
()
Returns true if this is a binary file |
boolean
|
isConflicting
(
ISchedulingRule rule)
|
boolean
|
isDescendantOf
(
IRemoteFile file)
Note: if this remoteFile is the same as the file passed
as parameter, then this method returns true. |
boolean
|
isExecutable
()
Returns whether the file is executable or not. |
boolean
|
isLink
()
Returns whether the file is a symbolic link or not. |
boolean
|
isPropertyStale
(
String key)
Returns whether the property with the given key is stale. |
boolean
|
isStale
()
Indicates whether the cached object is stale |
boolean
|
isText
()
Returns true if this is a text file |
boolean
|
isUnix
()
Return if this is a file on Unix, versus windows say
Queries it from the subsystem factory. |
void
|
markAllPropertiesStale
()
Marks all properties as stale. |
void
|
markPropertyStale
(
String key)
Marks the property with the given key as stale. |
void
|
markStale
(boolean isStale)
Marks the object as stale or not |
void
|
markStale
(boolean isStale,
boolean clearCache)
Marks the object as stale or not |
void
|
replaceContent
(
Object oldObject,
Object newObject)
|
void
|
setContents
(
ISystemContentsType contentsType,
String filter,
Object[] con)
Sets the contents of this object that match a particular filter |
void
|
setEncoding
(
String encoding)
Sets the encoding of the remote file. |
void
|
setFile
(
Object obj)
|
void
|
setFilterString
(
RemoteFileFilterString filterString)
Set the filter string resolved to get this object |
void
|
setIsContainer
(boolean con)
|
void
|
setLabel
(
String newLabel)
|
void
|
setParentRemoteFile
(
IRemoteFile parentFile)
|
void
|
setProperties
(
String[] keys,
Object[] values)
Sets the values of the properties with the given keys. |
void
|
setProperty
(
String key,
Object value)
Sets the value of the property with the given key. |
String
|
toString
()
Return the cached copy of this remote file. |
Methods inherited from interface org.eclipse.rse.subsystems.files.core.subsystems.
IRemoteFile
|
canRead,
canWrite,
exists,
getAbsolutePath,
getCanonicalPath,
getClassification,
getHostFile,
getLastModified,
getLength,
getName,
getParentName,
getParentNoRoot,
getParentPath,
getRoot,
isDirectory,
isFile,
isHidden,
isRoot,
showBriefPropertySet,
showReadOnlyProperty
|
_context
protected
IRemoteFileContext _context
_label
protected
String _label
remoteObj
protected
Object remoteObj
_parentFile
protected
IRemoteFile _parentFile
isContainer
protected boolean isContainer
_contents
protected
HashMap _contents
_isStale
protected boolean _isStale
properties
protected
HashMap properties
propertyStates
protected
HashMap propertyStates
RemoteFile
public RemoteFile(
IRemoteFileContext context)
- Constructor that takes a context object containing important information.
-
Parameters:
-
context
- An object holding contextual information about this object -
See Also:
-
IRemoteFileContext
setFilterString
public void setFilterString(
RemoteFileFilterString filterString)
- Set the filter string resolved to get this object
-
-
setLabel
public void setLabel(
String newLabel)
-
-
getContext
public
IRemoteFileContext getContext()
- Return the context associated with this remote file
-
-
getParentRemoteFileSubSystem
public
IRemoteFileSubSystem getParentRemoteFileSubSystem()
- Return the parent subsystem
-
-
Specified by:
-
getParentRemoteFileSubSystem
in interface
IRemoteFile
-
-
Returns:
- the Subsystem holding this file.
getParentRemoteFileSubSystemConfiguration
public
IRemoteFileSubSystemConfiguration getParentRemoteFileSubSystemConfiguration()
- Return the parent subsystem factory
-
-
setParentRemoteFile
public void setParentRemoteFile(
IRemoteFile parentFile)
-
-
getParentRemoteFile
public
IRemoteFile getParentRemoteFile()
- Return the parent remote file object expanded to get this object, or null if no such parent
-
-
Specified by:
-
getParentRemoteFile
in interface
IRemoteFile
-
-
Returns:
- the parent remote file object or
null
.
getFilterString
public
RemoteFileFilterString getFilterString()
- Return the filter string resolved to get this object
-
-
Specified by:
-
getFilterString
in interface
IRemoteFile
-
getAllFilterStrings
public
RemoteFileFilterString[] getAllFilterStrings()
- If this is a folder, it is possible that it is listed as part of a multiple filter string
filter. In this case, when the folder is expanded, we want to filter the file names to
show all the files that match any of the filter strings that have the same parent path.
This method supports that by returning all the filter strings in the filter which have the
same parent path as was used to produce this file.
-
-
Specified by:
-
getAllFilterStrings
in interface
IRemoteFile
-
getSeparatorChar
public char getSeparatorChar()
- Return the separator character for this file system: \ or /.
Queries it from the subsystem factory.
-
-
Specified by:
-
getSeparatorChar
in interface
IRemoteFile
-
-
Returns:
- the separator character for this file system.
getSeparator
public
String getSeparator()
- Return the separator character for this file system, as a string: "\" or "/".
Queries it from the subsystem factory.
-
-
Specified by:
-
getSeparator
in interface
IRemoteFile
-
-
Returns:
- the separator character for this file system as a String.
getLineSeparator
public
String getLineSeparator()
- Return as a string the line separator character values
-
-
Specified by:
-
getLineSeparator
in interface
IRemoteFile
-
isUnix
public boolean isUnix()
- Return if this is a file on Unix, versus windows say
Queries it from the subsystem factory.
-
-
isLink
public boolean isLink()
-
Description copied from interface:
IRemoteFile
- Returns whether the file is a symbolic link or not.
-
-
Specified by:
-
isLink
in interface
IRemoteFile
-
-
Returns:
-
true
if the file is a symbolic link, false
otherwise.
isExecutable
public boolean isExecutable()
-
Description copied from interface:
IRemoteFile
- Returns whether the file is executable or not.
-
-
Specified by:
-
isExecutable
in interface
IRemoteFile
-
-
Returns:
-
true
if the file is executable, false
otherwise.
isArchive
public boolean isArchive()
-
Description copied from interface:
IRemoteFile
- Returns true if this represents an archive file, versues a non-archive file
-
-
Specified by:
-
isArchive
in interface
IRemoteFile
-
getHost
public
IHost getHost()
- Return the connection this remote file is from.
-
-
Specified by:
-
getHost
in interface
IRemoteFile
-
-
Since:
- 3.0 renamed getSystemConnection() to getHost()
getAbsolutePathPlusConnection
public
String getAbsolutePathPlusConnection()
- Get fully qualified connection and file name: connection:\path\file
Note the separator character between the profile name and the connection name is always '.'
Note the separator character between the connection and qualified-file is always ':'
-
-
Specified by:
-
getAbsolutePathPlusConnection
in interface
IRemoteFile
-
getLabel
public
String getLabel()
-
Description copied from interface:
IRemoteFile
- Get the display name for this file. By default, this should be the same as the name
If this object represents only a root drive, this is the same as getRoot().
-
-
Specified by:
-
getLabel
in interface
IRemoteFile
-
-
See Also:
-
IRemoteFile.getLabel()
isBinary
public boolean isBinary()
-
Description copied from interface:
IRemoteFile
- Returns true if this is a binary file
-
-
Specified by:
-
isBinary
in interface
IRemoteFile
-
-
See Also:
-
IRemoteFile.isBinary()
isText
public boolean isText()
-
Description copied from interface:
IRemoteFile
- Returns true if this is a text file
-
-
Specified by:
-
isText
in interface
IRemoteFile
-
-
See Also:
-
IRemoteFile.isText()
getLastModifiedDate
public
Date getLastModifiedDate()
-
Description copied from interface:
IRemoteFile
- Return the last modified time as a Date object.
-
-
Specified by:
-
getLastModifiedDate
in interface
IRemoteFile
-
-
See Also:
-
IRemoteFile.getLastModifiedDate()
getExtension
public
String getExtension()
- Return the extension part of a file name.
Eg, for abc.java, return "java"
-
-
Specified by:
-
getExtension
in interface
IRemoteFile
-
toString
public
String toString()
- Return the cached copy of this remote file. The returned IFile must be used for read-only
purposes since no locks are acquired on the remote file.
-
-
Overrides:
-
toString
in class
Object
-
-
Returns:
- IFile The cached copy of this file if it exists AND it is upto date. null is returned if a local
cached copy of this file is not available or the local cached copy is not upto date (last modified
timestamp comparison.)
getAdapter
public
Object getAdapter(
Class adapterType)
- This is the method required by the IAdaptable interface.
Given an adapter class type, return an object castable to the type, or
null if this is not possible.
By default this returns Platform.getAdapterManager().getAdapter(this, adapterType);
This in turn results in the default subsystem adapter SystemViewSubSystemAdapter,
in package org.eclipse.rse.ui.view.
-
-
Specified by:
-
getAdapter
in interface
IAdaptable
-
compareTo
public int compareTo(
Object other)
throws
ClassCastException
- Compare one remote file to another. This enables us to sort the files so they
are shown folders-first, and in alphabetical order.
-
-
Specified by:
-
compareTo
in interface
Comparable
-
Specified by:
-
compareTo
in interface
IRemoteFile
-
-
Throws:
-
ClassCastException
setFile
public void setFile(
Object obj)
-
-
getFile
public
Object getFile()
-
Description copied from interface:
IRemoteFile
- Get the object.
-
-
Specified by:
-
getFile
in interface
IRemoteFile
-
isAncestorOf
public boolean isAncestorOf(
IRemoteFile file)
-
Description copied from interface:
IRemoteFile
- Note: if this remoteFile is the same as the file passed
as parameter, then this method returns true.
-
-
Specified by:
-
isAncestorOf
in interface
IRemoteFile
-
isDescendantOf
public boolean isDescendantOf(
IRemoteFile file)
-
Description copied from interface:
IRemoteFile
- Note: if this remoteFile is the same as the file passed
as parameter, then this method returns true.
-
-
Specified by:
-
isDescendantOf
in interface
IRemoteFile
-
hasContents
public boolean hasContents(
ISystemContentsType contentsType)
-
Description copied from interface:
ISystemContainer
- Returns whether the object has contents of a particular type.
-
-
Specified by:
-
hasContents
in interface
ISystemContainer
-
-
Parameters:
-
contentsType
- type of contents
-
Returns:
-
true
if the object has contents, false
otherwise.
hasContents
public boolean hasContents(
ISystemContentsType contentsType,
String filter)
-
Description copied from interface:
IRemoteContainer
- Returns whether the object has contents of a particular type associated with the specified filter string.
-
-
Specified by:
-
hasContents
in interface
IRemoteContainer
-
-
Parameters:
-
contentsType
- type of contents -
filter
- criteria for contained contents
-
Returns:
-
true
if the object has contents, false
otherwise.
containsFilterKey
protected boolean containsFilterKey(
HashMap filters,
String filter)
-
-
getContents
public
Object[] getContents(
ISystemContentsType contentsType)
-
Description copied from interface:
ISystemContainer
- Returns all the contents of the object (combining results of all filters
-
-
Specified by:
-
getContents
in interface
ISystemContainer
-
-
Parameters:
-
contentsType
- type of contents
-
Returns:
- an array of contents.
getContents
public
Object[] getContents(
ISystemContentsType contentsType,
String filter)
-
Description copied from interface:
IRemoteContainer
- Returns the contents of the object.
-
-
Specified by:
-
getContents
in interface
IRemoteContainer
-
-
Parameters:
-
contentsType
- type of contents -
filter
- criteria for contained contents.
-
Returns:
- an array of contents.
setIsContainer
public void setIsContainer(boolean con)
-
-
replaceContent
public void replaceContent(
Object oldObject,
Object newObject)
-
-
Specified by:
-
replaceContent
in interface
IRemoteContainer
-
setContents
public void setContents(
ISystemContentsType contentsType,
String filter,
Object[] con)
-
Description copied from interface:
IRemoteContainer
- Sets the contents of this object that match a particular filter
-
-
Specified by:
-
setContents
in interface
IRemoteContainer
-
-
Parameters:
-
contentsType
- type of contents -
filter
- matching criteria for the contained objects -
con
- the contained objects that match the filter
isStale
public boolean isStale()
-
Description copied from interface:
ISystemContainer
- Indicates whether the cached object is stale
-
-
Specified by:
-
isStale
in interface
ISystemContainer
-
-
Returns:
- whether the container is stale
-
See Also:
-
ISystemContainer.isStale()
markStale
public void markStale(boolean isStale)
-
Description copied from interface:
ISystemContainer
- Marks the object as stale or not
-
-
Specified by:
-
markStale
in interface
ISystemContainer
-
-
Parameters:
-
isStale
- whether the object is to be marked stale or not -
See Also:
-
ISystemContainer.markStale(boolean)
markStale
public void markStale(boolean isStale,
boolean clearCache)
-
Description copied from interface:
ISystemContainer
- Marks the object as stale or not
-
-
Specified by:
-
markStale
in interface
ISystemContainer
-
-
Parameters:
-
isStale
- whether the object is to be marked stale or not -
clearCache
- indicates whether or not to clear the cache -
See Also:
-
ISystemContainer.markStale(boolean)
copyContentsTo
public void copyContentsTo(
IRemoteContainer target)
-
Description copied from interface:
IRemoteContainer
- Copies the persistable contents from this one to another one
-
-
Specified by:
-
copyContentsTo
in interface
IRemoteContainer
-
-
Parameters:
-
target
- the container to copy contents to
getProperties
public
Object[] getProperties(
String[] keys)
-
Description copied from interface:
IRemotePropertyHolder
- Returns the value of the properties with the given keys.
-
-
Specified by:
-
getProperties
in interface
IRemotePropertyHolder
-
-
Parameters:
-
keys
- the property keys.
-
Returns:
- the correspoding values of the properties.
-
See Also:
-
IRemotePropertyHolder.getProperties(java.lang.String[])
getProperty
public
Object getProperty(
String key)
-
Description copied from interface:
IRemotePropertyHolder
- Returns the value of the property with the given key.
-
-
Specified by:
-
getProperty
in interface
IRemotePropertyHolder
-
-
Parameters:
-
key
- the property key.
-
Returns:
- the value of the property.
-
See Also:
-
IRemotePropertyHolder.getProperty(java.lang.String)
isPropertyStale
public boolean isPropertyStale(
String key)
-
Description copied from interface:
IRemotePropertyHolder
- Returns whether the property with the given key is stale.
-
-
Specified by:
-
isPropertyStale
in interface
IRemotePropertyHolder
-
-
Parameters:
-
key
- the property key.
-
Returns:
-
true
if the property is stale, false
otherwise. -
See Also:
-
IRemotePropertyHolder.isPropertyStale(java.lang.String)
markAllPropertiesStale
public void markAllPropertiesStale()
-
Description copied from interface:
IRemotePropertyHolder
- Marks all properties as stale.
-
-
Specified by:
-
markAllPropertiesStale
in interface
IRemotePropertyHolder
-
-
See Also:
-
IRemotePropertyHolder.markAllPropertiesStale()
markPropertyStale
public void markPropertyStale(
String key)
-
Description copied from interface:
IRemotePropertyHolder
- Marks the property with the given key as stale.
-
-
Specified by:
-
markPropertyStale
in interface
IRemotePropertyHolder
-
-
Parameters:
-
key
- the property key. -
See Also:
-
IRemotePropertyHolder.markPropertyStale(java.lang.String)
setProperties
public void setProperties(
String[] keys,
Object[] values)
-
Description copied from interface:
IRemotePropertyHolder
- Sets the values of the properties with the given keys.
-
-
Specified by:
-
setProperties
in interface
IRemotePropertyHolder
-
-
Parameters:
-
keys
- the property keys. -
values
- the corresponding values of the properties. -
See Also:
-
IRemotePropertyHolder.setProperties(java.lang.String[], java.lang.Object[])
setProperty
public void setProperty(
String key,
Object value)
-
Description copied from interface:
IRemotePropertyHolder
- Sets the value of the property with the given key.
-
-
Specified by:
-
setProperty
in interface
IRemotePropertyHolder
-
-
Parameters:
-
key
- the property key. -
value
- the value of the property. -
See Also:
-
IRemotePropertyHolder.setProperty(java.lang.String, java.lang.Object)
getComment
public
String getComment()
-
-
Specified by:
-
getComment
in interface
IRemoteFile
-
-
Returns:
- Any comments stored with the file in the file system or archive.
contains
public boolean contains(
ISchedulingRule rule)
-
-
Specified by:
-
contains
in interface
ISchedulingRule
-
isConflicting
public boolean isConflicting(
ISchedulingRule rule)
-
-
Specified by:
-
isConflicting
in interface
ISchedulingRule
-
equals
public boolean equals(
Object otherObj)
-
-
Overrides:
-
equals
in class
Object
-
getHostName
public
String getHostName()
-
-
getEncoding
public
String getEncoding()
- Returns the encoding of the remote file. If a user specified value does not exist, then we check
it's ancestry for an encoding. Otherwise the encoding of the parent subsystem is returned.
-
-
Specified by:
-
getEncoding
in interface
IRemoteFile
-
-
Returns:
- the encoding of the remote file.
-
See Also:
-
IRemoteFile.getEncoding()
setEncoding
public void setEncoding(
String encoding)
- Sets the encoding of the remote file. It sets the encoding of the remote file in
RemoteFileEncodingManager
.
-
-
-
Parameters:
-
encoding
- the encoding to be set for the remote file.
getPermissions
public
IHostFilePermissions getPermissions()
- Returns the permissions for this file if they exist
-
-
Specified by:
-
getPermissions
in interface
IRemoteFile
-
-
Returns:
- the permissions
-
Since:
- 3.0
Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.