ScpFromMessageBySftp (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.taskdefs.optional.ssh, class: ScpFromMessageBySftp

# Class ScpFromMessageBySftp

java.lang.Object
org.apache.tools.ant.taskdefs.optional.ssh.AbstractSshMessage
org.apache.tools.ant.taskdefs.optional.ssh.ScpFromMessage
org.apache.tools.ant.taskdefs.optional.ssh.ScpFromMessageBySftp

public class ScpFromMessageBySftp extends ScpFromMessage
A helper object representing an scp download.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ScpFromMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, String aRemoteFile, File aLocalFile, boolean recursive)`
  Constructor for ScpFromMessageBySftp.
  `ScpFromMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, String aRemoteFile, File aLocalFile, boolean recursive, boolean preserveLastModified)`
  Constructor for ScpFromMessageBySftp.
  `ScpFromMessageBySftp(com.jcraft.jsch.Session session, String aRemoteFile, File aLocalFile, boolean recursive)`
  Constructor for ScpFromMessageBySftp.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `execute()`
  Carry out the transfer.

  ### Methods inherited from class ScpFromMessage

  `getPreserveLastModified`
  Modifier and Type
  Method
  Description
  `protected boolean`
  `getPreserveLastModified()`

  ### Methods inherited from class AbstractSshMessage

  `getCompressed, getProgressMonitor, getVerbose, log, logStats, openExecChannel, openSftpChannel, sendAck, setLogListener, trackProgress, waitForAck`
  Modifier and Type
  Method
  Description
  `protected final boolean`
  `getCompressed()`
  Is the compressed attribute set.
  `protected com.jcraft.jsch.SftpProgressMonitor`
  `getProgressMonitor()`
  Get the progress monitor.
  `protected final boolean`
  `getVerbose()`
  Is the verbose attribute set.
  `protected void`
  `log(String message)`
  Log a message to the log listener.
  `protected void`
  `logStats(long timeStarted, long timeEnded, long totalLength)`
  Log transfer stats to the log listener.
  `protected com.jcraft.jsch.Channel`
  `openExecChannel(String command)`
  Open an ssh channel.
  `protected com.jcraft.jsch.ChannelSftp`
  `openSftpChannel()`
  Open an ssh sftp channel.
  `protected void`
  `sendAck(OutputStream out)`
  Send an ack.
  `void`
  `setLogListener(LogListener aListener)`
  Set a log listener.
  `protected final int`
  `trackProgress(long filesize, long totalLength, int percentTransmitted)`
  Track progress every 10% if 100kb < filesize < 1Mb.
  `protected void`
  `waitForAck(InputStream in)`
  Reads the response, throws a BuildException if the response indicates an error.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ScpFromMessageBySftp

    public ScpFromMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, String aRemoteFile, File aLocalFile, boolean recursive)
    Constructor for ScpFromMessageBySftp.
    Parameters:
      `verbose` - if true log extra information
      `session` - the Scp session to use
      `aRemoteFile` - the remote file name
      `aLocalFile` - the local file
      `recursive` - if true use recursion
    Since:
      Ant 1.7

  - ### ScpFromMessageBySftp

    public ScpFromMessageBySftp(com.jcraft.jsch.Session session, String aRemoteFile, File aLocalFile, boolean recursive)
    Constructor for ScpFromMessageBySftp.
    Parameters:
      `session` - the Scp session to use
      `aRemoteFile` - the remote file name
      `aLocalFile` - the local file
      `recursive` - if true use recursion

  - ### ScpFromMessageBySftp

    public ScpFromMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, String aRemoteFile, File aLocalFile, boolean recursive, boolean preserveLastModified)
    Constructor for ScpFromMessageBySftp.
    Parameters:
      `verbose` - if true log extra information
      `session` - the Scp session to use
      `aRemoteFile` - the remote file name
      `aLocalFile` - the local file
      `recursive` - if true use recursion
      `preserveLastModified` - whether to preserve file modification times
    Since:
      Ant 1.8.0

- ## Method Details

  - ### execute

    public void execute() throws IOException, com.jcraft.jsch.JSchException
    Carry out the transfer.
    Overrides:
      `execute` in class `ScpFromMessage`
    Throws:
      `IOException` - on i/o errors
      `com.jcraft.jsch.JSchException` - on errors detected by scp