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

Package 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 Object
Abstract class for ssh upload and download

- ## Constructor Summary

  Constructors
  Constructor
  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

  Modifier and Type
  Method
  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​(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 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 java.lang.Object

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

- ## Constructor Details

  - ### 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
      `compressed` - if true use compression
      `session` - the ssh session to use
    Since:
      Ant 1.9.8

- ## Method Details

  - ### openExecChannel

    protected com.jcraft.jsch.Channel openExecChannel​(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​(OutputStream out) throws IOException
    Send an ack.
    Parameters:
      `out` - the output stream to use
    Throws:
      `IOException` - on error

  - ### waitForAck

    protected void waitForAck​(InputStream in) throws IOException, BuildException
    Reads the response, throws a BuildException if the response indicates an error.
    Parameters:
      `in` - the input stream to use
    Throws:
      `IOException` - on I/O error
      `BuildException` - on other errors

  - ### execute

    public abstract void execute() throws IOException, com.jcraft.jsch.JSchException
    Carry out the transfer.
    Throws:
      `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​(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.