Class NetworkManager


  • public final class NetworkManager
    extends java.lang.Object
    Handles global network features (errors and online/offline resources).
    Since:
    14121
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private NetworkManager()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Throwable addNetworkError​(java.lang.String url, java.lang.Throwable t)
      Adds a new network error that occur to give a hint about broken Internet connection.
      static java.lang.Throwable addNetworkError​(java.net.URL url, java.lang.Throwable t)
      Adds a new network error that occur to give a hint about broken Internet connection.
      static void clearNetworkErrors()
      Clears the network errors cache.
      static java.util.Map<java.lang.String,​java.lang.Throwable> getNetworkErrors()
      Returns the network errors that occurred until now.
      static java.util.Set<OnlineResource> getOfflineResources()
      Replies the set of online resources currently offline.
      static boolean isOffline​(java.lang.String url)
      Determines if the given online resource specified as URL is currently offline.
      static boolean isOffline​(OnlineResource r)
      Determines if the given online resource is currently offline.
      static boolean setOffline​(OnlineResource r)
      Sets the given online resource to offline state.
      static boolean setOnline​(OnlineResource r)
      Sets the given online resource to online state.
      • Methods inherited from class java.lang.Object

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

      • addNetworkError

        public static java.lang.Throwable addNetworkError​(java.lang.String url,
                                                          java.lang.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 java.lang.Throwable addNetworkError​(java.net.URL url,
                                                          java.lang.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

        public static java.util.Map<java.lang.String,​java.lang.Throwable> 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​(java.lang.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

        public static java.util.Set<OnlineResourcegetOfflineResources()
        Replies the set of online resources currently offline.
        Returns:
        the set of online resources currently offline