1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.archive.crawler.extractor;
28
29 import java.io.IOException;
30
31 import org.archive.crawler.datamodel.CrawlURI;
32 import org.archive.crawler.framework.CrawlController;
33
34 import com.anotherbigidea.flash.writers.SWFActionsImpl;
35
36 /***
37 * SWF action that handles discovered URIs.
38 *
39 * @author Igor Ranitovic
40 */
41 public class CrawlUriSWFAction
42 extends SWFActionsImpl {
43 CrawlURI curi;
44 CrawlController controller;
45
46 private long linkCount;
47 static final String JSSTRING = "javascript:";
48
49 /***
50 *
51 * @param curi
52 */
53 public CrawlUriSWFAction(CrawlURI curi, CrawlController controller) {
54 assert (curi != null) : "CrawlURI should not be null";
55 this.curi = curi;
56 this.controller = controller;
57 this.linkCount = 0;
58 }
59
60 /***
61 * Overwrite handling of discovered URIs.
62 *
63 * @param url Discovered URL.
64 * @param target Discovered target (currently not being used.)
65 * @throws IOException
66 */
67 public void getURL(String url, String target)
68 throws IOException {
69
70
71
72 if (url.startsWith(JSSTRING)) {
73 linkCount += ExtractorJS.considerStrings(curi, url, controller, false);
74 } else {
75 curi.createAndAddLinkRelativeToVia(url,Link.EMBED_MISC,Link.EMBED_HOP);
76 linkCount++;
77 }
78 }
79
80 /***
81 * @return Total number of links extracted from a swf file.
82 */
83 public long getLinkCount() {
84 return linkCount;
85 }
86 }