- java.lang.Object
-
- util.io.Mirror
-
public class Mirror extends java.lang.Object
- Author:
- Til Schneider, www.murfman.de
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_WEIGHT
The default weight of a mirrorstatic java.lang.String
MIRROR_LIST_FILE_NAME
The name extension of mirror filesstatic Localizer
mLocalizer
The localizer for this class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Mirror
chooseUpToDateMirror(Mirror[] mirrorArr, ProgressMonitor monitor, java.lang.String name, java.lang.String id, java.lang.Class<?> caller, java.lang.String additionalErrorMsg)
Chooses a up to date mirror.static Mirror
chooseWorkingMirror(Mirror[] mirrorArr, ProgressMonitor monitor, java.lang.String name, java.lang.String id, java.lang.Class<?> caller, java.lang.String additionalErrorMsg, int timeout)
Chooses a mirror that can be connected to.boolean
equals(java.lang.Object obj)
java.lang.String
getUrl()
Gets the URL of this Mirror.int
getWeight()
Gets the weight of this Mirror.int
hashCode()
static Mirror[]
loadMirrorList(java.io.File file, java.lang.String[] mirrorUrlArr, Mirror[] serverDefindedMirros)
Loads the mirror lists from the given file and the given server defined mirror array.static Mirror[]
readMirrorListFromFile(java.io.File file)
Reads the mirrors in the given file.static void
resetBannedServers()
Reset the List of banned Serversvoid
setWeight(int weight)
Sets the weight of this Mirror.static void
writeMirrorListToFile(java.io.File file, Mirror[] mirrorArr)
-
-
-
Field Detail
-
mLocalizer
public static final Localizer mLocalizer
The localizer for this class.
-
MIRROR_LIST_FILE_NAME
public static final java.lang.String MIRROR_LIST_FILE_NAME
The name extension of mirror files- See Also:
- Constant Field Values
-
DEFAULT_WEIGHT
public static final int DEFAULT_WEIGHT
The default weight of a mirror- See Also:
- Constant Field Values
-
-
Method Detail
-
getUrl
public java.lang.String getUrl()
Gets the URL of this Mirror.- Returns:
- The URL of this Mirror.
-
getWeight
public int getWeight()
Gets the weight of this Mirror.- Returns:
- The weight of this Mirror.
-
setWeight
public void setWeight(int weight)
Sets the weight of this Mirror.- Parameters:
weight
- The new weight of this Mirror.
-
readMirrorListFromFile
public static Mirror[] readMirrorListFromFile(java.io.File file) throws java.io.IOException, FileFormatException
Reads the mirrors in the given file.- Parameters:
file
- The file to read the mirrors from.- Returns:
- The mirror array read from the file.
- Throws:
java.io.IOException
- Thrown if something went wrong.FileFormatException
- Thrown if something went wrong.
-
writeMirrorListToFile
public static void writeMirrorListToFile(java.io.File file, Mirror[] mirrorArr) throws java.io.IOException
- Parameters:
file
- The file to write the mirror array to.mirrorArr
- The mirror array to write.- Throws:
java.io.IOException
- Thrown if something went wrong.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
loadMirrorList
public static Mirror[] loadMirrorList(java.io.File file, java.lang.String[] mirrorUrlArr, Mirror[] serverDefindedMirros)
Loads the mirror lists from the given file and the given server defined mirror array.- Parameters:
file
- The file to load the mirrors from.mirrorUrlArr
- The array with the current mirrors urls.serverDefindedMirros
- The array with the server definded mirrors- Returns:
- The load mirror array.
-
chooseWorkingMirror
public static Mirror chooseWorkingMirror(Mirror[] mirrorArr, ProgressMonitor monitor, java.lang.String name, java.lang.String id, java.lang.Class<?> caller, java.lang.String additionalErrorMsg, int timeout) throws TvBrowserException
Chooses a mirror that can be connected to.- Parameters:
mirrorArr
- The mirror array to check.monitor
- The progress monitor to use.name
- The name of the file to check.id
- The id of the file to check.caller
- The caller class.additionalErrorMsg
- An additional error message value.timeout
- The timeout of the check in milliseconds.- Returns:
- The choosen mirror or
null
, if no up to date mirror was found or something went wrong. - Throws:
TvBrowserException
- Thrown if something went wrong.- Since:
- 3.4.1
-
chooseUpToDateMirror
public static Mirror chooseUpToDateMirror(Mirror[] mirrorArr, ProgressMonitor monitor, java.lang.String name, java.lang.String id, java.lang.Class<?> caller, java.lang.String additionalErrorMsg) throws TvBrowserException
Chooses a up to date mirror.- Parameters:
mirrorArr
- The mirror array to check.monitor
- The progress monitor to use.name
- The name of the file to check.id
- The id of the file to check.caller
- The caller class.additionalErrorMsg
- An additional error message value.- Returns:
- The choosen mirror or
null
, if no up to date mirror was found or something went wrong. - Throws:
TvBrowserException
- Thrown if something went wrong.
-
resetBannedServers
public static void resetBannedServers()
Reset the List of banned Servers
-
-