Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

refactoring

Michael Peter Christena37d067692ca
diff --git a/htroot/api/linkstructure.java b/htroot/api/linkstructure.java
index 302405eae..1cc2d9454 100644
--- a/htroot/api/linkstructure.java
+++ b/htroot/api/linkstructure.java
@@ -30,6 +30,7 @@ import net.yacy.search.index.Fulltext;
import net.yacy.search.index.Segment.ReferenceReportCache;
import net.yacy.search.schema.HyperlinkEdge;
import net.yacy.search.schema.HyperlinkGraph;
+import net.yacy.search.schema.HyperlinkType;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
import net.yacy.server.servletProperties;
@@ -96,7 +97,7 @@ public class linkstructure {
int c = 0;
for (HyperlinkEdge e: hlg) {
prop.putJSON("edges_" + c + "_source", e.source.getPath());
- prop.putJSON("edges_" + c + "_target", e.type.equals(HyperlinkEdge.Type.Outbound) ? e.target.toNormalform(true) : e.target.getPath());
+ prop.putJSON("edges_" + c + "_target", e.type.equals(HyperlinkType.Outbound) ? e.target.toNormalform(true) : e.target.getPath());
prop.putJSON("edges_" + c + "_type", e.type.name());
Integer depth_source = hlg.getDepth(e.source);
Integer depth_target = hlg.getDepth(e.target);
diff --git a/source/net/yacy/search/schema/HyperlinkEdge.java b/source/net/yacy/search/schema/HyperlinkEdge.java
index 6526f0871..67a53ffae 100644
--- a/source/net/yacy/search/schema/HyperlinkEdge.java
+++ b/source/net/yacy/search/schema/HyperlinkEdge.java
@@ -23,15 +23,11 @@ package net.yacy.search.schema;
import net.yacy.cora.document.id.DigestURL;
public class HyperlinkEdge {
-
- public static enum Type {
- Inbound, InboundNofollow, Outbound, Dead;
- }
public DigestURL source, target;
- public Type type;
+ public HyperlinkType type;
- public HyperlinkEdge(DigestURL source, DigestURL target, Type type) {
+ public HyperlinkEdge(DigestURL source, DigestURL target, HyperlinkType type) {
this.source = source;
this.target = target;
this.type = type;
diff --git a/source/net/yacy/search/schema/HyperlinkGraph.java b/source/net/yacy/search/schema/HyperlinkGraph.java
index 05642f47a..34117d840 100644
--- a/source/net/yacy/search/schema/HyperlinkGraph.java
+++ b/source/net/yacy/search/schema/HyperlinkGraph.java
@@ -99,7 +99,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
try {
DigestURL linkurl = new DigestURL(link, null);
String edgehash = ids + ASCII.String(linkurl.hash());
- inboundEdges.put(edgehash, new HyperlinkEdge(from, linkurl, HyperlinkEdge.Type.Inbound));
+ inboundEdges.put(edgehash, new HyperlinkEdge(from, linkurl, HyperlinkType.Inbound));
if (stopURL != null && linkurl.equals(stopURL)) break retrieval;
} catch (MalformedURLException e) {}
}
@@ -109,7 +109,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
try {
DigestURL linkurl = new DigestURL(link, null);
String edgehash = ids + ASCII.String(linkurl.hash());
- outboundEdges.put(edgehash, new HyperlinkEdge(from, linkurl, HyperlinkEdge.Type.Outbound));
+ outboundEdges.put(edgehash, new HyperlinkEdge(from, linkurl, HyperlinkType.Outbound));
if (stopURL != null && linkurl.equals(stopURL)) break retrieval;
} catch (MalformedURLException e) {}
}
@@ -128,7 +128,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
edge = i.next();
if (errorDocs.containsKey(edge.getValue().target.toNormalform(true))) {
i.remove();
- edge.getValue().type = HyperlinkEdge.Type.Dead;
+ edge.getValue().type = HyperlinkType.Dead;
errorEdges.put(edge.getKey(), edge.getValue());
}
}
@@ -137,7 +137,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
edge = i.next();
if (errorDocs.containsKey(edge.getValue().target.toNormalform(true))) {
i.remove();
- edge.getValue().type = HyperlinkEdge.Type.Dead;
+ edge.getValue().type = HyperlinkType.Dead;
errorEdges.put(edge.getKey(), edge.getValue());
}
}
@@ -170,7 +170,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
String path = edge.source.getPath();
if (ROOTFNS.contains(path)) {
if (!this.depths.containsKey(edge.source)) this.depths.put(edge.source, 0);
- if (edge.type == HyperlinkEdge.Type.Inbound && !this.depths.containsKey(edge.target)) this.depths.put(edge.target, 1);
+ if (edge.type == HyperlinkType.Inbound && !this.depths.containsKey(edge.target)) this.depths.put(edge.target, 1);
nodes.add(edge.source);
nextnodes.add(edge.target);
remaining--;
@@ -187,7 +187,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
for (HyperlinkEdge edge: this.edges.values()) {
if (nodes.contains(edge.source)) {
if (!this.depths.containsKey(edge.source)) this.depths.put(edge.source, depth);
- if (edge.type == HyperlinkEdge.Type.Inbound && !this.depths.containsKey(edge.target)) this.depths.put(edge.target, depth + 1);
+ if (edge.type == HyperlinkType.Inbound && !this.depths.containsKey(edge.target)) this.depths.put(edge.target, depth + 1);
nextnodes.add(edge.target);
remaining--;
found = true;
diff --git a/source/net/yacy/search/schema/HyperlinkType.java b/source/net/yacy/search/schema/HyperlinkType.java
new file mode 100644
index 000000000..9c4c941ed
--- /dev/null
+++ b/source/net/yacy/search/schema/HyperlinkType.java
@@ -0,0 +1,25 @@
+/**
+ * HyperlinkType
+ * Copyright 2014 by Michael Peter Christen
+ * First released 04.04.2014 at http://yacy.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program in the file lgpl21.txt
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.yacy.search.schema;
+
+public enum HyperlinkType {
+ Inbound, InboundNofollow, Outbound, Dead;
+}