public class DefaultReplayCaptureSelector extends Object implements ReplayCaptureSelector
ReplayCaptureSelector
.
This is what used to be embedded in AccessPoint hadleReplay
method.
It compares previous and next capture of the current one, picks closer capture
time-wise. Captures are removed as it traverses the captures list, so that
the same capture will not be returned twice.
It also favors successful (200) captures over closer redirects and errors for
embeds and bestLatestReplayRequest (see DatelessReplayRequestParser
).
New feature 2014-00-18: It also skips captures with any of ROBOT_FLAGS_SKIPPED
in robotflags
field. This is for new soft-blocked captures
feature.
For backward compatibility, this implementation delegates closest-selection (i.e.
selecting the first capture to return) to ReplayDispatcher
passed to
its constructor. ReplayCaptureSelector
is not ready for factory-based
customization because of this. When ReplayCaptureSelector
takes over closest-selection functionality from ReplayDispatcher
,
dependency on replayDispatcher
will be removed.
Modifier and Type | Field and Description |
---|---|
static String |
ROBOT_FLAGS_SKIPPED
captures with these flags in
robotflags field are skipped. |
Constructor and Description |
---|
DefaultReplayCaptureSelector(ReplayDispatcher replayDispatcher)
Initialize object with
ReplayDispatcher , to which
closest-selection is delegated. |
Modifier and Type | Method and Description |
---|---|
protected CaptureSearchResult |
findNextClosest() |
protected static boolean |
hasAnyRobotFlags(CaptureSearchResult capture,
String flags) |
CaptureSearchResult |
next()
return next best capture.
|
void |
setCaptures(CaptureSearchResults captures)
set a list of captures to select replay candidate from.
|
void |
setReplayDispatcher(ReplayDispatcher replayDispatcher)
set
ReplayDispatcher for selecting the best capture. |
void |
setRequest(WaybackRequest wbRequest)
set request information.
|
public static final String ROBOT_FLAGS_SKIPPED
robotflags
field are skipped.
(TODO: make this customizable?)public DefaultReplayCaptureSelector(ReplayDispatcher replayDispatcher)
ReplayDispatcher
, to which
closest-selection is delegated.replayDispatcher
- ReplayDispatcher
, cannot be null.public void setRequest(WaybackRequest wbRequest)
ReplayCaptureSelector
AccessPoint
calls this method just once on each instance.
setRequest
in interface ReplayCaptureSelector
wbRequest
- WaybackRequest for the replay requestpublic void setCaptures(CaptureSearchResults captures)
ReplayCaptureSelector
AccessPoint
may call this method more than once with different
instance of CaptureSearchResults
within a request. When this
method is called, next next()
call shall return the best capture
in new CaptureSearchResults
.
Implementation can make changes to CaptureSearchResults for bookkeeping purposes etc.
setCaptures
in interface ReplayCaptureSelector
captures
- CaptureSearchResults, non-null
public void setReplayDispatcher(ReplayDispatcher replayDispatcher)
ReplayDispatcher
for selecting the best capture.replayDispatcher
- protected static boolean hasAnyRobotFlags(CaptureSearchResult capture, String flags)
public CaptureSearchResult next()
ReplayCaptureSelector
next
in interface ReplayCaptureSelector
null
if there's no more captures
suitable for the request.protected CaptureSearchResult findNextClosest()
Copyright © 2005–2015 IIPC. All rights reserved.