From c0e3d18bbfe21e8fb5794c1644d278572e278239 Mon Sep 17 00:00:00 2001 From: borg-0300 Date: Tue, 6 Sep 2005 16:58:12 +0000 Subject: [PATCH] *) remove import java.lang *) Added Super() *) replaced startsWith() *) cleaned git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@670 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/plasma/plasmaURLPattern.java | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/source/de/anomic/plasma/plasmaURLPattern.java b/source/de/anomic/plasma/plasmaURLPattern.java index 16cd37774..30b7092ac 100644 --- a/source/de/anomic/plasma/plasmaURLPattern.java +++ b/source/de/anomic/plasma/plasmaURLPattern.java @@ -41,52 +41,53 @@ package de.anomic.plasma; -import java.lang.String; -import java.util.HashMap; import java.io.File; - +import java.util.HashMap; import de.anomic.kelondro.kelondroMSetTools; public class plasmaURLPattern { - + private File rootPath = null; private HashMap hostpaths = null; // key=host, value=path; mapped url is http://host/path; path does not start with '/' here - + public plasmaURLPattern(File rootPath) { + super(); this.rootPath = rootPath; this.hostpaths = new HashMap(); } - + public void clear() { this.hostpaths = new HashMap(); } - + public int size() { return hostpaths.size(); } - + public void loadLists(String mapname, String filenames, String sep) { - //File listsPath = new File(getRootPath(), getConfig("listsPath", "DATA/LISTS")); - String filenamesarray[] = filenames.split(","); - - if(filenamesarray.length >0) - for(int i = 0; i < filenamesarray.length; i++) + // File listsPath = new File(getRootPath(), getConfig("listsPath", "DATA/LISTS")); + final String[] filenamesarray = filenames.split(","); + + if( filenamesarray.length > 0) { + for (int i = 0; i < filenamesarray.length; i++) { hostpaths.putAll(kelondroMSetTools.loadMap(mapname, (new File(rootPath, filenamesarray[i])).toString(), sep)); + } + } } - + public void remove(String host) { hostpaths.remove(host); } - + public void add(String host, String path) { - if (path.startsWith("/")) path = path.substring(1); + if (path.length() > 0 && path.charAt(0) == '/') path = path.substring(1); hostpaths.put(host, path); } - + public boolean isListed(String hostlow, String path) { - if (path.startsWith("/")) path = path.substring(1); + if (path.length() > 0 && path.charAt(0) == '/') path = path.substring(1); String pp = ""; // path-pattern - + // first try to match the domain with wildcard '*' // [TL] While "." are found within the string int index = 0; @@ -101,10 +102,10 @@ public class plasmaURLPattern { return ((pp.equals("*")) || (path.matches(pp))); } } - + // try to match without wildcard in domain return (((pp = (String) hostpaths.get(hostlow)) != null) && ((pp.equals("*")) || (path.matches(pp)))); } - + }