Package esmska.update

Class HttpDownloader

  • All Implemented Interfaces:
    java.lang.Runnable, java.util.concurrent.Future<java.lang.Object>, java.util.concurrent.RunnableFuture<java.lang.Object>

    public class HttpDownloader
    extends javax.swing.SwingWorker<java.lang.Object,​java.lang.Void>
    Download file via HTTP. Returns String or byte[] depending if text or binary content was required.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.SwingWorker

        javax.swing.SwingWorker.StateValue
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpDownloader​(java.lang.String url, boolean binary)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Object doInBackground()  
      byte[] getBinaryContent()
      Retrieve binary content.
      java.lang.String getTextContent()
      Retrieve text content.
      boolean isFinishedOk()
      Whether file was downloaded ok, or there was some error (or still running)
      • Methods inherited from class javax.swing.SwingWorker

        addPropertyChangeListener, cancel, done, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgress
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HttpDownloader

        public HttpDownloader​(java.lang.String url,
                              boolean binary)
        Constructor.
        Parameters:
        url - file url
        binary - if file contents is binary
    • Method Detail

      • doInBackground

        protected java.lang.Object doInBackground()
        Specified by:
        doInBackground in class javax.swing.SwingWorker<java.lang.Object,​java.lang.Void>
      • getTextContent

        public java.lang.String getTextContent()
        Retrieve text content. Null if requested binary file or some error.
      • getBinaryContent

        public byte[] getBinaryContent()
        Retrieve binary content. Null if requested text file or some error.
      • isFinishedOk

        public boolean isFinishedOk()
        Whether file was downloaded ok, or there was some error (or still running)