de.hfu.anybeam.networkCore

## Class AbstractTransmission

- java.lang.Object
- - java.lang.Thread
  - - de.hfu.anybeam.networkCore.AbstractTransmission

- All Implemented Interfaces:
    java.lang.Runnable
  Direct Known Subclasses:
    DataSender

      public abstract class AbstractTransmission
      extends java.lang.Thread

  A abstract class providing default functionality for every kind of transmission including progress calculation, average speed calculation, a adapter interface to notify about progress changes and failure handling.
  Since:
    1.0
  Version:
    1.0
  Author:
    chrwuer

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractTransmission(AbstractTransmissionAdapter adapter)` Creates a new AbstarctTransmission instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cancelTransmission()` Cancels the transmission.
    `double` | `getAveragSpeed()` Returns the calculated average speed in Bytes/s.
    `java.lang.String` | `getResourceName()` Returns the name of the resource transmitted by this `AbstractTransmission` instance or a text describing the it.
    `long` | `getTotalLength()` Returns the total length of this transmission in bytes or -1 if the transmission is infinite.
    `long` | `getTransmissionId()` Returns an id unique for every instance of `AbstractTransmission`
    `long` | `getTransmittedLength()` Returns the already transmitted length in bytes.
    `boolean` | `isCanceled()` Returns true if this transmission was canceled, false otherwise
    `boolean` | `isDone()` Returns true if this transmission is done.
    `void` | `run()`
    `void` | `startTransmission()` Starts the transmission.

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

      `activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

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

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractTransmission

          public AbstractTransmission(AbstractTransmissionAdapter adapter)

      Creates a new AbstarctTransmission instance.
      Parameters:
        `adapter` - The `AbstractTransmissionAdapter` that should be informed about progress updates or null

  - ### Method Detail

    - #### run

          public void run()

      Specified by:
        `run` in interface `java.lang.Runnable`
      Overrides:
        `run` in class `java.lang.Thread`

    - #### startTransmission

          public void startTransmission()

      Starts the transmission. Can only be called once.
      See Also:
        `cancelTransmission()`

    - #### cancelTransmission

          public void cancelTransmission()

      Cancels the transmission.

    - #### isCanceled

          public boolean isCanceled()

      Returns true if this transmission was canceled, false otherwise
      Returns:
        true if this transmission was canceled, false otherwise

    - #### isDone

          public boolean isDone()

      Returns true if this transmission is done. This is the case if the transmission was finished successfully or aborted due to an error or through ivnoking `cancelTransmission()`;
      Returns:
        true if the transmission is done, false if it is still in progress

    - #### getTransmissionId

          public long getTransmissionId()

      Returns an id unique for every instance of `AbstractTransmission`
      Returns:
        a unique id for every instance of `AbstractTransmission`

    - #### getTotalLength

          public long getTotalLength()

      Returns the total length of this transmission in bytes or -1 if the transmission is infinite.
      Returns:
        the total length of this transmission in bytes or -1 if the transmission is infinite.
      See Also:
        `setTotalLength(long)`

    - #### getAveragSpeed

          public double getAveragSpeed()

      Returns the calculated average speed in Bytes/s.
      Returns:
        the calculated average speed in Bytes/s.

    - #### getTransmittedLength

          public long getTransmittedLength()

      Returns the already transmitted length in bytes.
      Returns:
        the already transmitted length in bytes.
      See Also:
        `increaseTransmittedLength(long)`

    - #### getResourceName

          public java.lang.String getResourceName()

      Returns the name of the resource transmitted by this `AbstractTransmission` instance or a text describing the it.
      Returns:
        the name of the resource transmitted by this `AbstractTransmission` instance or a text describing the it.