Class NetworkManager

java.lang.Object
org.openstreetmap.josm.io.NetworkManager

public final class NetworkManager extends Object
Handles global network features (errors and online/offline resources).
Since:
14121
  • Field Details

  • Constructor Details

  • Method Details

    • addNetworkError

      public static Throwable addNetworkError(String url, Throwable t)
      Adds a new network error that occur to give a hint about broken Internet connection. Do not use this method for errors known for sure thrown because of a bad proxy configuration.
      Parameters:
      url - The accessed URL that caused the error
      t - The network error
      Returns:
      The previous error associated to the given resource, if any. Can be null
    • addNetworkError

      public static Throwable addNetworkError(URL url, Throwable t)
      Adds a new network error that occur to give a hint about broken Internet connection. Do not use this method for errors known for sure thrown because of a bad proxy configuration.
      Parameters:
      url - The accessed URL that caused the error
      t - The network error
      Returns:
      The previous error associated to the given resource, if any. Can be null
    • getNetworkErrors

      Returns the network errors that occurred until now.
      Returns:
      the network errors that occurred until now, indexed by URL
    • clearNetworkErrors

      public static void clearNetworkErrors()
      Clears the network errors cache.
    • isOffline

      public static boolean isOffline(String url)
      Determines if the given online resource specified as URL is currently offline.
      Parameters:
      url - the online resource specified as URL
      Returns:
      true if url is offline and should not be accessed
      Since:
      16426
    • isOffline

      public static boolean isOffline(OnlineResource r)
      Determines if the given online resource is currently offline.
      Parameters:
      r - the online resource
      Returns:
      true if r is offline and should not be accessed
    • setOffline

      public static boolean setOffline(OnlineResource r)
      Sets the given online resource to offline state.
      Parameters:
      r - the online resource
      Returns:
      true if r was not already offline
    • setOnline

      public static boolean setOnline(OnlineResource r)
      Sets the given online resource to online state.
      Parameters:
      r - the online resource
      Returns:
      true if r was offline
    • getOfflineResources

      Replies the set of online resources currently offline.
      Returns:
      the set of online resources currently offline