1 2 3 4 package net.nutch.parse; 5 6 import java.io.*; 7 import java.net.MalformedURLException ; 8 9 import net.nutch.io.*; 10 import net.nutch.net.UrlNormalizerFactory; 11 12 13 public class Outlink implements Writable { 14 15 private String toUrl; 16 private String anchor; 17 18 public Outlink() {} 19 20 public Outlink(String toUrl, String anchor) throws MalformedURLException { 21 this.toUrl = UrlNormalizerFactory.getNormalizer().normalize(toUrl); 22 this.anchor = anchor; 23 } 24 25 public void readFields(DataInput in) throws IOException { 26 toUrl = UTF8.readString(in); 27 anchor = UTF8.readString(in); 28 } 29 30 31 public static void skip(DataInput in) throws IOException { 32 UTF8.skip(in); UTF8.skip(in); } 35 36 public void write(DataOutput out) throws IOException { 37 UTF8.writeString(out, toUrl); 38 UTF8.writeString(out, anchor); 39 } 40 41 public static Outlink read(DataInput in) throws IOException { 42 Outlink outlink = new Outlink(); 43 outlink.readFields(in); 44 return outlink; 45 } 46 47 public String getToUrl() { return toUrl; } 48 public String getAnchor() { return anchor; } 49 50 51 public boolean equals(Object o) { 52 if (!(o instanceof Outlink)) 53 return false; 54 Outlink other = (Outlink)o; 55 return 56 this.toUrl.equals(other.toUrl) && 57 this.anchor.equals(other.anchor); 58 } 59 60 public String toString() { 61 return "toUrl: " + toUrl + " anchor: " + anchor; } 63 64 } 65 | Popular Tags |