private final class SftpFileSystem.Wrapper extends AbstractSftpClient
SftpClient.Attribute, SftpClient.Attributes, SftpClient.CloseableHandle, SftpClient.CopyMode, SftpClient.DirEntry, SftpClient.Handle, SftpClient.OpenMode| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.atomic.AtomicInteger |
count |
private SftpClient |
delegate |
private int |
readSize |
private int |
writeSize |
DEFAULT_WRITE_CHUNK_SIZE, WRITE_CHUNK_SIZElogDEFAULT_CHANNEL_MODES, DEFAULT_CHANNEL_OPEN_TIMEOUT, DEFAULT_NAME_DECODING_CHARSET, DEFAULT_READ_BUFFER_SIZE, DEFAULT_WAIT_TIMEOUT, DEFAULT_WRITE_BUFFER_SIZE, EMPTY_DIR_ENTRIES, IO_BUFFER_SIZE, MIN_BUFFER_SIZE, MIN_READ_BUFFER_SIZE, MIN_WRITE_BUFFER_SIZE, NAME_DECODING_CHARSET, SFTP_CHANNEL_OPEN_TIMEOUTBY_NAME_COMPARATOR, NAME_EXTRACTOR| Modifier | Constructor and Description |
|---|---|
private |
Wrapper(SftpClient delegate,
int readSize,
int writeSize) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
canonicalPath(java.lang.String path)
The effective "normalized" remote path
|
void |
close() |
void |
close(SftpClient.Handle handle)
Close the handle obtained from one of the
open methods |
ClientChannel |
getClientChannel() |
ClientSession |
getClientSession() |
java.nio.charset.Charset |
getNameDecodingCharset() |
java.util.NavigableMap<java.lang.String,byte[]> |
getServerExtensions() |
int |
getVersion() |
void |
increment() |
boolean |
isClosing() |
boolean |
isOpen() |
void |
link(java.lang.String linkPath,
java.lang.String targetPath,
boolean symbolic)
Create a link
|
java.lang.Iterable<SftpClient.DirEntry> |
listDir(SftpClient.Handle handle) |
void |
lock(SftpClient.Handle handle,
long offset,
long length,
int mask) |
SftpClient.Attributes |
lstat(java.lang.String path)
Retrieve remote path meta-data - do not follow symbolic links
|
void |
mkdir(java.lang.String path)
Create remote directory
|
SftpClient.CloseableHandle |
open(java.lang.String path,
java.util.Collection<SftpClient.OpenMode> options)
Opens a remote file with the specified mode(s)
|
SftpClient.CloseableHandle |
openDir(java.lang.String path)
Obtain a handle for a directory
|
int |
read(SftpClient.Handle handle,
long fileOffset,
byte[] dst,
int dstOffset,
int len) |
java.io.InputStream |
read(java.lang.String path) |
java.io.InputStream |
read(java.lang.String path,
java.util.Collection<SftpClient.OpenMode> mode) |
java.io.InputStream |
read(java.lang.String path,
int bufferSize,
java.util.Collection<SftpClient.OpenMode> mode)
Read a remote file's data via an input stream
|
java.io.InputStream |
read(java.lang.String path,
SftpClient.OpenMode... mode) |
java.util.List<SftpClient.DirEntry> |
readDir(SftpClient.Handle handle) |
java.lang.Iterable<SftpClient.DirEntry> |
readDir(java.lang.String path) |
java.lang.String |
readLink(java.lang.String path)
Retrieve target of a link
|
Buffer |
receive(int id) |
void |
remove(java.lang.String path) |
void |
rename(java.lang.String oldPath,
java.lang.String newPath,
java.util.Collection<SftpClient.CopyMode> options) |
void |
rmdir(java.lang.String path)
Remove remote directory
|
int |
send(int cmd,
Buffer buffer) |
void |
setNameDecodingCharset(java.nio.charset.Charset cs) |
void |
setStat(SftpClient.Handle handle,
SftpClient.Attributes attributes)
Update remote node meta-data
|
void |
setStat(java.lang.String path,
SftpClient.Attributes attributes)
Update remote node meta-data
|
SftpClient.Attributes |
stat(SftpClient.Handle handle)
Retrieve file/directory handle meta-data
|
SftpClient.Attributes |
stat(java.lang.String path)
Retrieve remote path meta-data - follow symbolic links if encountered
|
void |
symLink(java.lang.String linkPath,
java.lang.String targetPath)
Create symbolic link
|
void |
unlock(SftpClient.Handle handle,
long offset,
long length) |
void |
write(SftpClient.Handle handle,
long fileOffset,
byte[] src,
int srcOffset,
int len)
Write data to (open) file handle
|
java.io.OutputStream |
write(java.lang.String path) |
java.io.OutputStream |
write(java.lang.String path,
java.util.Collection<SftpClient.OpenMode> mode) |
java.io.OutputStream |
write(java.lang.String path,
int bufferSize,
java.util.Collection<SftpClient.OpenMode> mode)
Write to a remote file via an output stream
|
java.io.OutputStream |
write(java.lang.String path,
SftpClient.OpenMode... mode) |
checkAttributes, checkAttributesResponse, checkCommandStatus, checkData, checkDataResponse, checkDirResponse, checkHandle, checkHandleResponse, checkOneName, checkOneNameResponse, checkResponseStatus, checkResponseStatus, getChannel, getExtension, getExtension, getExtension, getParsedServerExtensions, getParsedServerExtensions, getReferencedName, handleUnexpectedAttributesPacket, handleUnexpectedHandlePacket, handleUnexpectedPacket, handleUnknownDataPacket, handleUnknownDirListingPacket, handleUnknownOneNamePacket, putReferencedName, read, readAttributes, readDir, throwStatusException, validateIncomingResponse, writeAttributesgetSession, toStringgetSimplifiedLoggerclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetName, open, open, openRemoteFileChannel, openRemoteFileChannel, openRemotePathChannel, openRemotePathChannel, read, read, read, read, rename, rename, write, write, writegetSessionfindByName, getNameList, getNames, ofName, removeByNameprivate final SftpClient delegate
private final java.util.concurrent.atomic.AtomicInteger count
private final int readSize
private final int writeSize
private Wrapper(SftpClient delegate, int readSize, int writeSize)
public int getVersion()
public ClientSession getClientSession()
ClientSession usedpublic ClientChannel getClientChannel()
ClientChannel usedpublic java.util.NavigableMap<java.lang.String,byte[]> getServerExtensions()
NavigableMap of the reported server extensions.
where key=extension name (case insensitive)public java.nio.charset.Charset getNameDecodingCharset()
null) Charset used to decode referenced files/folders namesSftpClient.NAME_DECODING_CHARSETpublic void setNameDecodingCharset(java.nio.charset.Charset cs)
public boolean isClosing()
public boolean isOpen()
public void close()
throws java.io.IOException
java.io.IOExceptionpublic void increment()
public SftpClient.CloseableHandle open(java.lang.String path, java.util.Collection<SftpClient.OpenMode> options) throws java.io.IOException
SftpClientopen in interface SftpClientopen in class AbstractSftpClientpath - The remote pathoptions - The desired mode - if none specified
then SftpClient.OpenMode.Read is assumedSftpClient.CloseableHandlejava.io.IOException - If failed to open the remote filepublic void close(SftpClient.Handle handle) throws java.io.IOException
SftpClientopen methodsclose in interface SftpClientclose in class AbstractSftpClienthandle - The Handle to closejava.io.IOException - If failed to executepublic void remove(java.lang.String path)
throws java.io.IOException
remove in interface SftpClientremove in class AbstractSftpClientpath - The remote path to removejava.io.IOException - If failed to executepublic void rename(java.lang.String oldPath,
java.lang.String newPath,
java.util.Collection<SftpClient.CopyMode> options)
throws java.io.IOException
rename in interface SftpClientrename in class AbstractSftpClientjava.io.IOExceptionpublic int read(SftpClient.Handle handle, long fileOffset, byte[] dst, int dstOffset, int len) throws java.io.IOException
java.io.IOExceptionpublic void write(SftpClient.Handle handle, long fileOffset, byte[] src, int srcOffset, int len) throws java.io.IOException
SftpClientwrite in interface SftpClientwrite in class AbstractSftpClienthandle - The file SftpClient.HandlefileOffset - Zero-based offset to write in filesrc - Data buffersrcOffset - Offset of valid data in bufferlen - Number of bytes to writejava.io.IOException - If failed to write the datapublic void mkdir(java.lang.String path)
throws java.io.IOException
SftpClientmkdir in interface SftpClientmkdir in class AbstractSftpClientpath - Remote directory pathjava.io.IOException - If failed to executepublic void rmdir(java.lang.String path)
throws java.io.IOException
SftpClientrmdir in interface SftpClientrmdir in class AbstractSftpClientpath - Remote directory pathjava.io.IOException - If failed to executepublic SftpClient.CloseableHandle openDir(java.lang.String path) throws java.io.IOException
SftpClientopenDir in interface SftpClientopenDir in class AbstractSftpClientpath - Remote directory pathSftpClient.Handlejava.io.IOException - If failed to executepublic java.util.List<SftpClient.DirEntry> readDir(SftpClient.Handle handle) throws java.io.IOException
handle - Directory SftpClient.Handle to read fromList of entries - null to indicate no more entries
Note: the list may be incomplete since the client and
server have some internal imposed limit on the number of entries they
can process. Therefore several calls to this method may be required
(until null). In order to iterate over all the entries use
SftpClient.readDir(String)java.io.IOException - If failed to access the remote sitepublic java.lang.Iterable<SftpClient.DirEntry> listDir(SftpClient.Handle handle) throws java.io.IOException
handle - A directory SftpClient.HandleIterable that can be used to iterate over all the
directory entries (like SftpClient.readDir(String)). Note: the
iterable instance is not re-usable - i.e., files can be iterated
only oncejava.io.IOException - If failed to access the directorypublic java.lang.String canonicalPath(java.lang.String path)
throws java.io.IOException
SftpClientcanonicalPath in interface SftpClientcanonicalPath in class AbstractSftpClientpath - The requested path - may be relative, and/or contain
dots - e.g., ".", "..", "./foo", "../bar"java.io.IOException - If failed to executepublic SftpClient.Attributes stat(java.lang.String path) throws java.io.IOException
SftpClientstat in interface SftpClientstat in class AbstractSftpClientpath - The remote pathSftpClient.Attributesjava.io.IOException - If failed to executepublic SftpClient.Attributes lstat(java.lang.String path) throws java.io.IOException
SftpClientlstat in interface SftpClientlstat in class AbstractSftpClientpath - The remote pathSftpClient.Attributesjava.io.IOException - If failed to executepublic SftpClient.Attributes stat(SftpClient.Handle handle) throws java.io.IOException
SftpClientstat in interface SftpClientstat in class AbstractSftpClienthandle - The SftpClient.Handle obtained via one of the open callsSftpClient.Attributesjava.io.IOException - If failed to executepublic void setStat(java.lang.String path,
SftpClient.Attributes attributes)
throws java.io.IOException
SftpClientsetStat in interface SftpClientsetStat in class AbstractSftpClientpath - The remote pathattributes - The SftpClient.Attributes to updatejava.io.IOException - If failed to executepublic void setStat(SftpClient.Handle handle, SftpClient.Attributes attributes) throws java.io.IOException
SftpClientsetStat in interface SftpClientsetStat in class AbstractSftpClienthandle - The SftpClient.Handle obtained via one of the open callsattributes - The SftpClient.Attributes to updatejava.io.IOException - If failed to executepublic java.lang.String readLink(java.lang.String path)
throws java.io.IOException
SftpClientreadLink in interface SftpClientreadLink in class AbstractSftpClientpath - Remote path that represents a linkjava.io.IOException - If failed to executepublic void symLink(java.lang.String linkPath,
java.lang.String targetPath)
throws java.io.IOException
SftpClientlinkPath - The link locationtargetPath - The referenced target by the linkjava.io.IOException - If failed to executeSftpClient.link(String, String, boolean)public java.lang.Iterable<SftpClient.DirEntry> readDir(java.lang.String path) throws java.io.IOException
path - The remote directory pathIterable that can be used to iterate over all the
directory entries (unlike SftpClient.readDir(Handle))java.io.IOException - If failed to access the remote siteSftpClient.readDir(Handle)public java.io.InputStream read(java.lang.String path)
throws java.io.IOException
java.io.IOExceptionpublic java.io.InputStream read(java.lang.String path,
SftpClient.OpenMode... mode)
throws java.io.IOException
java.io.IOExceptionpublic java.io.InputStream read(java.lang.String path,
java.util.Collection<SftpClient.OpenMode> mode)
throws java.io.IOException
java.io.IOExceptionpublic java.io.InputStream read(java.lang.String path,
int bufferSize,
java.util.Collection<SftpClient.OpenMode> mode)
throws java.io.IOException
SftpClientpath - The remote file pathbufferSize - The internal read buffer sizemode - The remote file SftpClient.OpenModesInputStream for reading the remote file datajava.io.IOException - If failed to executepublic java.io.OutputStream write(java.lang.String path)
throws java.io.IOException
java.io.IOExceptionpublic java.io.OutputStream write(java.lang.String path,
SftpClient.OpenMode... mode)
throws java.io.IOException
java.io.IOExceptionpublic java.io.OutputStream write(java.lang.String path,
java.util.Collection<SftpClient.OpenMode> mode)
throws java.io.IOException
java.io.IOExceptionpublic java.io.OutputStream write(java.lang.String path,
int bufferSize,
java.util.Collection<SftpClient.OpenMode> mode)
throws java.io.IOException
SftpClientpath - The remote file pathbufferSize - The internal write buffer sizemode - The remote file SftpClient.OpenModesOutputStream for writing the datajava.io.IOException - If failed to executepublic void link(java.lang.String linkPath,
java.lang.String targetPath,
boolean symbolic)
throws java.io.IOException
SftpClientlink in interface SftpClientlink in class AbstractSftpClientlinkPath - The link locationtargetPath - The referenced target by the linksymbolic - If true then make this a symbolic link, otherwise a hard onejava.io.IOException - If failed to executepublic void lock(SftpClient.Handle handle, long offset, long length, int mask) throws java.io.IOException
lock in interface SftpClientlock in class AbstractSftpClientjava.io.IOExceptionpublic void unlock(SftpClient.Handle handle, long offset, long length) throws java.io.IOException
unlock in interface SftpClientunlock in class AbstractSftpClientjava.io.IOExceptionpublic int send(int cmd,
Buffer buffer)
throws java.io.IOException
cmd - Command to send - Note: only lower 8-bits are usedbuffer - The Buffer containing the command datajava.io.IOException - if failed to send command