01: // webstructure.java
02: // (C) 2007 by Michael Peter Christen; mc@anomic.de, Frankfurt a. M., Germany
03: // first published 22.05.2007 on http://yacy.net
04: //
05: // This is a part of YaCy, a peer-to-peer based web search engine
06: //
07: // $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
08: // $LastChangedRevision: 1986 $
09: // $LastChangedBy: orbiter $
10: //
11: // LICENSE
12: //
13: // This program is free software; you can redistribute it and/or modify
14: // it under the terms of the GNU General Public License as published by
15: // the Free Software Foundation; either version 2 of the License, or
16: // (at your option) any later version.
17: //
18: // This program is distributed in the hope that it will be useful,
19: // but WITHOUT ANY WARRANTY; without even the implied warranty of
20: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21: // GNU General Public License for more details.
22: //
23: // You should have received a copy of the GNU General Public License
24: // along with this program; if not, write to the Free Software
25: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26:
27: package xml;
28:
29: import java.util.Iterator;
30: import java.util.Map;
31:
32: import de.anomic.http.httpHeader;
33: import de.anomic.plasma.plasmaSwitchboard;
34: import de.anomic.plasma.plasmaWebStructure;
35: import de.anomic.server.serverObjects;
36: import de.anomic.server.serverSwitch;
37:
38: public class webstructure {
39:
40: public static serverObjects respond(httpHeader header,
41: serverObjects post, serverSwitch env) {
42: serverObjects prop = new serverObjects();
43: plasmaSwitchboard sb = (plasmaSwitchboard) env;
44: Iterator<plasmaWebStructure.structureEntry> i = sb.webStructure
45: .structureEntryIterator();
46: int c = 0, d;
47: plasmaWebStructure.structureEntry sentry;
48: Map.Entry<String, Integer> refentry;
49: String refdom, refhash;
50: Integer refcount;
51: Iterator<Map.Entry<String, Integer>> k;
52: while (i.hasNext()) {
53: sentry = i.next();
54: prop.put("domains_" + c + "_hash", sentry.domhash);
55: prop.put("domains_" + c + "_domain", sentry.domain);
56: prop.put("domains_" + c + "_date", sentry.date);
57: k = sentry.references.entrySet().iterator();
58: d = 0;
59: refloop: while (k.hasNext()) {
60: refentry = k.next();
61: refhash = refentry.getKey();
62: refdom = sb.webStructure
63: .resolveDomHash2DomString(refhash);
64: if (refdom == null)
65: continue refloop;
66: prop.put("domains_" + c + "_citations_" + d
67: + "_refhash", refhash);
68: prop.put(
69: "domains_" + c + "_citations_" + d + "_refdom",
70: refdom);
71: refcount = refentry.getValue();
72: prop.put("domains_" + c + "_citations_" + d
73: + "_refcount", refcount.intValue());
74: d++;
75: }
76: prop.put("domains_" + c + "_citations", d);
77: c++;
78: }
79: prop.put("domains", c);
80: prop.put("maxref", plasmaWebStructure.maxref);
81:
82: // return rewrite properties
83: return prop;
84: }
85: }
|