Package adams.core.io
Class SftpFileObject
- java.lang.Object
-
- adams.core.io.SftpFileObject
-
- All Implemented Interfaces:
FileObject,Serializable,Comparable<FileObject>
public class SftpFileObject extends Object implements FileObject
Wrapper for remote SFTP files.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Booleanm_Directorywhether it is a directory (if no entry).protected com.jcraft.jsch.ChannelSftp.LsEntrym_Entrythe underlying file.protected Stringm_Namethe file/dir (if no entry).protected Filem_ParentDirthe parent directory.protected com.jcraft.jsch.Sessionm_Sessionthe session.
-
Constructor Summary
Constructors Modifier Constructor Description SftpFileObject(File parentDir, com.jcraft.jsch.ChannelSftp.LsEntry entry, com.jcraft.jsch.Session session)Initializes the wrapper.protectedSftpFileObject(File parentDir, com.jcraft.jsch.ChannelSftp.LsEntry entry, String name, Boolean dir, com.jcraft.jsch.Session session)Initializes the wrapper.SftpFileObject(File parentDir, String name, boolean dir, com.jcraft.jsch.Session session)Initializes the wrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(FileObject o)Returns whether this file object is the same as the provided one.booleanequals(Object obj)Checks whether this object is the same as the provided one.FilegetActualFile()Returns the actual target (if possible) in case of a link.FilegetFile()Returns the wrapped file.DategetLastModified()Returns the date when the file was last modified.longgetLength()Returns the size of the file.StringgetName()Returns the file name.FileObjectgetParent()Returns the parent, if available.FilegetParentDir()Returns the parent directory.com.jcraft.jsch.SessiongetSession()Returns the session.booleanisDirectory()Returns whether the file represents a directory.booleanisHidden()Returns whether the file is hidden.booleanisLink()Returns whether the file represents a link.booleanisLocal()Returns whether the file is a local file.StringtoString()Returns the long name.
-
-
-
Field Detail
-
m_Session
protected transient com.jcraft.jsch.Session m_Session
the session.
-
m_ParentDir
protected File m_ParentDir
the parent directory.
-
m_Name
protected String m_Name
the file/dir (if no entry).
-
m_Directory
protected Boolean m_Directory
whether it is a directory (if no entry).
-
m_Entry
protected transient com.jcraft.jsch.ChannelSftp.LsEntry m_Entry
the underlying file.
-
-
Constructor Detail
-
SftpFileObject
public SftpFileObject(File parentDir, String name, boolean dir, com.jcraft.jsch.Session session)
Initializes the wrapper.- Parameters:
parentDir- the parent directoryname- the file/dir to wrapdir- whether it is a directorysession- the session
-
SftpFileObject
public SftpFileObject(File parentDir, com.jcraft.jsch.ChannelSftp.LsEntry entry, com.jcraft.jsch.Session session)
Initializes the wrapper.- Parameters:
parentDir- the parent directoryentry- the file to wrapsession- the session
-
SftpFileObject
protected SftpFileObject(File parentDir, com.jcraft.jsch.ChannelSftp.LsEntry entry, String name, Boolean dir, com.jcraft.jsch.Session session)
Initializes the wrapper.- Parameters:
parentDir- the parent directoryentry- the file to wrapname- the file/dir to wrapdir- whether it is a directorysession- the session
-
-
Method Detail
-
getParent
public FileObject getParent()
Returns the parent, if available.- Specified by:
getParentin interfaceFileObject- Returns:
- the parent or null if not available
-
getSession
public com.jcraft.jsch.Session getSession()
Returns the session.- Returns:
- the session
-
getParentDir
public File getParentDir()
Returns the parent directory.- Returns:
- the parent
-
getFile
public File getFile()
Returns the wrapped file.- Specified by:
getFilein interfaceFileObject- Returns:
- the file
-
getActualFile
public File getActualFile()
Returns the actual target (if possible) in case of a link.- Specified by:
getActualFilein interfaceFileObject- Returns:
- the actual file
-
getName
public String getName()
Returns the file name.- Specified by:
getNamein interfaceFileObject- Returns:
- the name
-
getLength
public long getLength()
Returns the size of the file.- Specified by:
getLengthin interfaceFileObject- Returns:
- the size
-
isDirectory
public boolean isDirectory()
Returns whether the file represents a directory.- Specified by:
isDirectoryin interfaceFileObject- Returns:
- true if directory
-
getLastModified
public Date getLastModified()
Returns the date when the file was last modified.- Specified by:
getLastModifiedin interfaceFileObject- Returns:
- date when last modified
-
isHidden
public boolean isHidden()
Returns whether the file is hidden.- Specified by:
isHiddenin interfaceFileObject- Returns:
- true if hidden
-
isLink
public boolean isLink()
Returns whether the file represents a link.- Specified by:
isLinkin interfaceFileObject- Returns:
- true if link
-
isLocal
public boolean isLocal()
Returns whether the file is a local file.- Specified by:
isLocalin interfaceFileObject- Returns:
- true if local
-
toString
public String toString()
Returns the long name.- Specified by:
toStringin interfaceFileObject- Overrides:
toStringin classObject- Returns:
- the long name
-
compareTo
public int compareTo(FileObject o)
Returns whether this file object is the same as the provided one.- Specified by:
compareToin interfaceComparable<FileObject>- Parameters:
o- the file object to compare against- Returns:
- less than zero, equal to zero, greater than zero if this file object is less than, equal to, or greater than the other file object
-
equals
public boolean equals(Object obj)
Checks whether this object is the same as the provided one.- Overrides:
equalsin classObject- Parameters:
obj- the object to compare against- Returns:
- true if the same
- See Also:
compareTo(FileObject)
-
-