mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-07-18 13:37:20 +00:00
Added a data map to Link. Becomes the CrawlURI's data map when Link is
promoted to CrawlURI
This commit is contained in:
@@ -1649,6 +1649,7 @@ implements Reporter, Serializable, OverlayContext {
|
||||
extendHopsPath(getPathFromSeed(),link.getHopType().getHopChar()),
|
||||
getUURI(), link.getContext());
|
||||
newCaURI.inheritFrom(this);
|
||||
newCaURI.data=link.getRawData();
|
||||
return newCaURI;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,12 @@
|
||||
package org.archive.modules.extractor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.commons.httpclient.URIException;
|
||||
import org.archive.modules.CoreAttributeConstants;
|
||||
import org.archive.modules.CrawlURI;
|
||||
import org.archive.net.UURI;
|
||||
import org.archive.net.UURIFactory;
|
||||
@@ -57,6 +60,14 @@ public class Link implements Serializable, Comparable<Link> {
|
||||
|
||||
/** hop-type */
|
||||
private Hop hop;
|
||||
|
||||
/**
|
||||
* Flexible dynamic attributes list.
|
||||
* <p>
|
||||
* See further {@link Link#getData()}
|
||||
*/
|
||||
protected Map<String,Object> data;
|
||||
|
||||
|
||||
/**
|
||||
* Create a Link with the given fields.
|
||||
@@ -106,7 +117,37 @@ public class Link implements Serializable, Comparable<Link> {
|
||||
public String toString() {
|
||||
return this.destination + " " + hop.getHopChar() + " " + this.context;
|
||||
}
|
||||
/**
|
||||
* Attribute list
|
||||
* <p>
|
||||
* By convention the attribute list is keyed by constants found in the
|
||||
* {@link CoreAttributeConstants} interface. Use this list to carry
|
||||
* data or state produced by custom processors rather change the
|
||||
* classes {@link CrawlURI} or this class, CrawlURI.
|
||||
* <p>
|
||||
* This list becomes {@link CrawlURI#getData()} when the Link is promoted to CrawlURI via
|
||||
* {@link CrawlURI#createCrawlURI(UURI, Link)}
|
||||
* <p>
|
||||
* If the list is null when this method is invoked, a new instance will be created and returned.
|
||||
*
|
||||
* @returns a flexible map of key/value pairs for storing
|
||||
* status of this URI for use by other processors.
|
||||
*/
|
||||
public Map<String, Object> getData() {
|
||||
if (data == null) {
|
||||
data = new HashMap<String,Object>();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link Link#getData()} except null will be returned if the underlying map is null
|
||||
* instead of creating a new map
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getRawData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
Reference in New Issue
Block a user