org.apache.tools.ant.taskdefs.optional.ssh

## Class AbstractSshMessage

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

- Direct Known Subclasses:
    ScpFromMessage, ScpToMessage

      public abstract class AbstractSshMessage
      extends java.lang.Object

  Abstract class for ssh upload and download

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractSshMessage(boolean verbose, boolean compressed, com.jcraft.jsch.Session session)` Constructor for AbstractSshMessage
    `AbstractSshMessage(boolean verbose, com.jcraft.jsch.Session session)` Constructor for AbstractSshMessage
    `AbstractSshMessage(com.jcraft.jsch.Session session)` Constructor for AbstractSshMessage

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `execute()` Carry out the transfer.
    `protected boolean` | `getCompressed()` Is the compressed attribute set.
    `protected com.jcraft.jsch.SftpProgressMonitor` | `getProgressMonitor()` Get the progress monitor.
    `protected boolean` | `getVerbose()` Is the verbose attribute set.
    `protected void` | `log(java.lang.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(java.lang.String command)` Open an ssh channel.
    `protected com.jcraft.jsch.ChannelSftp` | `openSftpChannel()` Open an ssh sftp channel.
    `protected void` | `sendAck(java.io.OutputStream out)` Send an ack.
    `void` | `setLogListener(LogListener aListener)` Set a log listener.
    `protected int` | `trackProgress(long filesize, long totalLength, int percentTransmitted)` Track progress every 10% if 100kb < filesize < 1mb.
    `protected void` | `waitForAck(java.io.InputStream in)` Reads the response, throws a BuildException if the response indicates an error.

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### AbstractSshMessage

          public AbstractSshMessage(com.jcraft.jsch.Session session)

      Constructor for AbstractSshMessage
      Parameters:
        `session` - the ssh session to use

    - #### AbstractSshMessage

          public AbstractSshMessage(boolean verbose,
                                    com.jcraft.jsch.Session session)

      Constructor for AbstractSshMessage
      Parameters:
        `verbose` - if true do verbose logging
        `session` - the ssh session to use
      Since:
        Ant 1.6.2

    - #### AbstractSshMessage

          public AbstractSshMessage(boolean verbose,
                                    boolean compressed,
                                    com.jcraft.jsch.Session session)

      Constructor for AbstractSshMessage
      Parameters:
        `verbose` - if true do verbose logging
        `compression` - if true use compression
        `session` - the ssh session to use
      Since:
        Ant 1.9.8

  - ### Method Detail

    - #### openExecChannel

          protected com.jcraft.jsch.Channel openExecChannel(java.lang.String command)
                                                     throws com.jcraft.jsch.JSchException

      Open an ssh channel.
      Parameters:
        `command` - the command to use
      Returns:
        the channel
      Throws:
        `com.jcraft.jsch.JSchException` - on error

    - #### openSftpChannel

          protected com.jcraft.jsch.ChannelSftp openSftpChannel()
                                                         throws com.jcraft.jsch.JSchException

      Open an ssh sftp channel.
      Returns:
        the channel
      Throws:
        `com.jcraft.jsch.JSchException` - on error

    - #### sendAck

          protected void sendAck(java.io.OutputStream out)
                          throws java.io.IOException

      Send an ack.
      Parameters:
        `out` - the output stream to use
      Throws:
        `java.io.IOException` - on error

    - #### waitForAck

          protected void waitForAck(java.io.InputStream in)
                             throws java.io.IOException,
                                    BuildException

      Reads the response, throws a BuildException if the response indicates an error.
      Parameters:
        `in` - the input stream to use
      Throws:
        `java.io.IOException` - on I/O error
        `BuildException` - on other errors

    - #### execute

          public abstract void execute()
                                throws java.io.IOException,
                                       com.jcraft.jsch.JSchException

      Carry out the transfer.
      Throws:
        `java.io.IOException` - on I/O errors
        `com.jcraft.jsch.JSchException` - on ssh errors

    - #### setLogListener

          public void setLogListener(LogListener aListener)

      Set a log listener.
      Parameters:
        `aListener` - the log listener

    - #### log

          protected void log(java.lang.String message)

      Log a message to the log listener.
      Parameters:
        `message` - the message to log

    - #### logStats

          protected void logStats(long timeStarted,
                                  long timeEnded,
                                  long totalLength)

      Log transfer stats to the log listener.
      Parameters:
        `timeStarted` - the time started
        `timeEnded` - the finishing time
        `totalLength` - the total length

    - #### getVerbose

          protected final boolean getVerbose()

      Is the verbose attribute set.
      Returns:
        true if the verbose attribute is set
      Since:
        Ant 1.6.2

    - #### getCompressed

          protected final boolean getCompressed()

      Is the compressed attribute set.
      Returns:
        true if the compressed attribute is set
      Since:
        Ant 1.9.8

    - #### trackProgress

          protected final int trackProgress(long filesize,
                                            long totalLength,
                                            int percentTransmitted)

      Track progress every 10% if 100kb < filesize < 1mb. For larger files track progress for every percent transmitted.
      Parameters:
        `filesize` - the size of the file been transmitted
        `totalLength` - the total transmission size
        `percentTransmitted` - the current percent transmitted
      Returns:
        the percent that the file is of the total

    - #### getProgressMonitor

          protected com.jcraft.jsch.SftpProgressMonitor getProgressMonitor()

      Get the progress monitor.
      Returns:
        the progress monitor.