From cdbaf637fbed12d4ae7ce89f235c4244a26c9632 Mon Sep 17 00:00:00 2001 From: borg-0300 Date: Mon, 17 Oct 2005 23:12:40 +0000 Subject: [PATCH] added - getIP(), getJunior(), getSenior(), getPrincipal(); - setIP(), setJunior(), setSenior(), setPrincipal(), setLastSeen(long rd); - isPeerOK(), isOnline(String type); next try to remove hello.class java.util.ConcurrentModificationException:null ;) git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@948 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/yacy/yacySeed.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java index d9f56be63..801919a22 100644 --- a/source/de/anomic/yacy/yacySeed.java +++ b/source/de/anomic/yacy/yacySeed.java @@ -130,7 +130,7 @@ public class yacySeed { this.available = 0; } - public yacySeed(String hash) { + public yacySeed(String hash) { dna = new HashMap(); // settings that can only be computed by originating peer: @@ -174,11 +174,22 @@ public class yacySeed { available = 0; } + public String getIP() { return get(IP, ""); } + public String getJunior() { return get(PEERTYPE, PEERTYPE_JUNIOR); } + public String getSenior() { return get(PEERTYPE, PEERTYPE_SENIOR); } + public String getPrincipal() { return get(PEERTYPE, PEERTYPE_PRINCIPAL); } + public String get(String key, String dflt) { final Object o = dna.get(key); if (o == null) { return dflt; } else { return (String) o; } } + public void setIP(String ip) { put(IP, ip); } + public void setJunior() { put(PEERTYPE, PEERTYPE_JUNIOR); } + public void setSenior() { put(PEERTYPE, PEERTYPE_SENIOR); } + public void setPrincipal() { put(PEERTYPE, PEERTYPE_PRINCIPAL); } + public void setLastSeen(long rd) { put(LASTSEEN, yacyCore.shortFormatter.format(new Date(System.currentTimeMillis() + serverDate.UTCDiff() - rd))); } + public void put(String key, String value) { dna.put(key, value); } @@ -342,6 +353,9 @@ public class yacySeed { public boolean isOnline() { return (isSenior() || isPrincipal()); } + public boolean isOnline(String type) { + return (type.equals(PEERTYPE_SENIOR) || type.equals(PEERTYPE_PRINCIPAL)); + } public String encodeLex(long c, int length) { if (length < 0) { length = 0; } @@ -491,10 +505,14 @@ public class yacySeed { return genSeedStr('b', key); } - public String genSeedStr(char method, String key) { + synchronized public String genSeedStr(char method, String key) { return crypt.simpleEncode(toString(), key, method); } + public boolean isPeerOK() { + return (this.hash != null && isProper() == null); + } + public String isProper() { // checks if everything is ok with that seed if (this.hash == null) { return "hash is null"; }