Package org.openstreetmap.josm.io
Class NetworkManager
- java.lang.Object
-
- org.openstreetmap.josm.io.NetworkManager
-
public final class NetworkManager extends java.lang.Object
Handles global network features (errors and online/offline resources).- Since:
- 14121
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,java.lang.Throwable>NETWORK_ERRORSprivate static java.util.Set<OnlineResource>OFFLINE_RESOURCES
-
Constructor Summary
Constructors Modifier Constructor Description privateNetworkManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ThrowableaddNetworkError(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.ThrowableaddNetworkError(java.net.URL url, java.lang.Throwable t)Adds a new network error that occur to give a hint about broken Internet connection.static voidclearNetworkErrors()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 booleanisOffline(java.lang.String url)Determines if the given online resource specified as URL is currently offline.static booleanisOffline(OnlineResource r)Determines if the given online resource is currently offline.static booleansetOffline(OnlineResource r)Sets the given online resource to offline state.static booleansetOnline(OnlineResource r)Sets the given online resource to online state.
-
-
-
Field Detail
-
NETWORK_ERRORS
private static final java.util.Map<java.lang.String,java.lang.Throwable> NETWORK_ERRORS
-
OFFLINE_RESOURCES
private static final java.util.Set<OnlineResource> OFFLINE_RESOURCES
-
-
Constructor Detail
-
NetworkManager
private NetworkManager()
-
-
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 errort- 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 errort- 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:
trueifurlis 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:
trueifris 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:
trueifrwas not already offline
-
setOnline
public static boolean setOnline(OnlineResource r)
Sets the given online resource to online state.- Parameters:
r- the online resource- Returns:
trueifrwas offline
-
getOfflineResources
public static java.util.Set<OnlineResource> getOfflineResources()
Replies the set of online resources currently offline.- Returns:
- the set of online resources currently offline
-
-