MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / NiceRefreshHandler

Class NiceRefreshHandler

src/main/java/org/htmlunit/NiceRefreshHandler.java:27–62  ·  view source on GitHub ↗

This refresh handler performs an immediate refresh if the refresh delay is less or equal to the configured time and otherwise ignores totally the refresh instruction. @author Marc Guillemot @author Ronald Brill

Source from the content-addressed store, hash-verified

25 * @author Ronald Brill
26 */
27public class NiceRefreshHandler extends ImmediateRefreshHandler {
28 private final int maxDelay_;
29
30 /**
31 * Creates a new refresh handler that will immediately refresh if the refresh delay is no
32 * longer than {@code maxDelay}. No refresh will be perform at all for refresh values
33 * larger than {@code maxDelay}.
34 *
35 * @param maxDelay the maximum refreshValue (in seconds) that should cause a refresh
36 */
37 public NiceRefreshHandler(final int maxDelay) {
38 super();
39 if (maxDelay <= 0) {
40 throw new IllegalArgumentException("Invalid maxDelay: " + maxDelay);
41 }
42 maxDelay_ = maxDelay;
43 }
44
45 /**
46 * Refreshes the specified page using the specified URL immediately if the {@code requestedWait}
47 * is not larger than the {@code maxDelay}. Does nothing otherwise.
48 * @param page the page that is going to be refreshed
49 * @param url the URL where the new page will be loaded
50 * @param requestedWait the number of seconds to wait before reloading the page
51 * @throws IOException if the refresh fails
52 */
53 @Override
54 public void handleRefresh(final Page page, final URL url, final int requestedWait) throws IOException {
55 if (requestedWait > maxDelay_) {
56 return;
57 }
58
59 super.handleRefresh(page, url, requestedWait);
60 }
61
62}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…