de.caff.util

## Class SemanticVersionChecker

- java.lang.Object
- - de.caff.util.SemanticVersionChecker

- All Implemented Interfaces:
    KnockOffListener

      public class SemanticVersionChecker
      extends java.lang.Object
      implements KnockOffListener

  Check whether a new program version is available.

  This is very similar to `VersionChecker`, but uses semantic versions.

  If a newer one is available the new jar can be downloaded and saved in a way that the old jar is replaced. Possibly the program can also be restarted using the new jar.

  Author:
    Rammi

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `SemanticVersionChecker.ProgramAccess` Program information necessary for automatic update.
    `static class` | `SemanticVersionChecker.Version` Helper class for a simple version build from numbers separated by points.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `TAG_COMMENT`
    `static java.lang.String` | `TAG_MINJVM`
    `static java.lang.String` | `TAG_NOUPDATE`
    `static java.lang.String` | `TAG_SEPARATOR`
    `static java.lang.String` | `TAG_VERSION`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `checkForNewVersion(SemanticVersionChecker.ProgramAccess pa)` Check whether a new version is available.
    `void` | `knockedOff(Worker worker)` Invoked when the worker has finished.
    `static boolean` | `writeStreamToFile(java.io.InputStream is, java.io.File target)` Write the complete content of a stream to a file.

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

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

- - ### Field Detail

    - #### TAG_SEPARATOR

          public static final java.lang.String TAG_SEPARATOR

      See Also:
        Constant Field Values

    - #### TAG_COMMENT

          public static final java.lang.String TAG_COMMENT

      See Also:
        Constant Field Values

    - #### TAG_VERSION

          public static final java.lang.String TAG_VERSION

      See Also:
        Constant Field Values

    - #### TAG_MINJVM

          public static final java.lang.String TAG_MINJVM

      See Also:
        Constant Field Values

    - #### TAG_NOUPDATE

          public static final java.lang.String TAG_NOUPDATE

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### knockedOff

          public void knockedOff(@NotNull
                                 Worker worker)

      Invoked when the worker has finished.
      Specified by:
        `knockedOff` in interface `KnockOffListener`
      Parameters:
        `worker` - worker which finished

    - #### writeStreamToFile

          public static boolean writeStreamToFile(@NotNull
                                                  java.io.InputStream is,
                                                  @NotNull
                                                  java.io.File target)
                                           throws java.io.IOException

      Write the complete content of a stream to a file.
      Parameters:
        `is` - input stream
        `target` - target
      Returns:
        `true` if anything was written
        `false`: if nothing was written
      Throws:
        `java.io.IOException` - on read and write errors

    - #### checkForNewVersion

          public static void checkForNewVersion(@NotNull
                                                SemanticVersionChecker.ProgramAccess pa)

      Check whether a new version is available.
      Parameters:
        `pa` - access to already running program