public class LatestURL extends Object implements Initializable
last(java.net.URL) methods, for repetetive access, it is advisable to construct a
new object and call the update() method.| Modifier and Type | Class and Description |
|---|---|
static class |
LatestURL.Dump
Dump an url-content to system-out.
|
protected static class |
LatestURL.URLTime
A class that enhances an url for the modification time.
|
| Modifier and Type | Field and Description |
|---|---|
private FileFilter |
accept
The file filter.
|
private URL |
base
The base URL.
|
private Collection<URL> |
cache
The collection of all refences matching the filter retrieved lately.
|
private LatestURL.URLTime |
latest
The youngest URL from the current cache.
|
| Constructor and Description |
|---|
LatestURL(URL dir)
Constructs an new latest url object.
|
LatestURL(URL dir,
FileFilter filter)
Constructs an new latest url object.
|
| Modifier and Type | Method and Description |
|---|---|
protected LatestURL.URLTime |
deduceYoungest(Collection<URL> cc)
The base class only uses the modification time of the url.
|
private static Set<URL> |
getFilteredReferences(URL dir,
FileFilter pass)
Returns all references from the base url in a set.
|
URL |
getLatest()
Returns the last url-reference strored in the latest field.
|
protected static long |
getModificationTime(URL ref)
Opens a connection to the specified URL and returns the time-stamp of the
modification time.
|
private static LatestURL.URLTime |
getYoungest(Collection<URL> filtered)
Takes a collection of filtered references and returns the newest one.
|
void |
init()
This stupid splitting is just becaus super must always be first.
|
static URL |
last(URL dir)
Retrieves all references, passes them through the filter and returns the
url with the most actual date from the remaining list.
|
static URL |
last(URL dir,
FileFilter pass)
Retrieves all references, passes them through the filter and returns the
url with the most actual date from the remaining list.
|
String |
toString()
Returns the string representation of the latest url.
|
URL |
update()
Updates the reference cache and checks if we have to re-do evaluation of
the youngest neighbour.
|
private final URL base
private final FileFilter accept
private Collection<URL> cache
private LatestURL.URLTime latest
public LatestURL(URL dir)
update() first check, if new references had been added to or
removed from the base url and acts only on the changes.public LatestURL(URL dir, FileFilter filter)
update() first check, if new references had been added to or
removed from the base url and acts only on the changes.public void init()
init in interface Initializablepublic static URL last(URL dir)
public URL update()
public URL getLatest()
public String toString()
public static URL last(URL dir, FileFilter pass)
private static Set<URL> getFilteredReferences(URL dir, FileFilter pass)
protected LatestURL.URLTime deduceYoungest(Collection<URL> cc)
private static LatestURL.URLTime getYoungest(Collection<URL> filtered)
protected static long getModificationTime(URL ref) throws IOException
IOException