Author: orbiter Date: 2008-01-23 22:09:56 +0100 (Wed, 23 Jan 2008) New Revision: 4379
Removed: trunk/source/de/anomic/tools/dirlistComparator.java Modified: trunk/htroot/htdocsdefault/dir.java trunk/source/de/anomic/tools/PKCS12Tool.java trunk/source/de/anomic/tools/cryptbig.java trunk/source/de/anomic/tools/disorderHeap.java trunk/source/de/anomic/tools/disorderSet.java trunk/source/de/anomic/tools/enumerateFiles.java trunk/source/de/anomic/tools/loaderThreads.java trunk/source/de/anomic/xml/crawlHandler.java trunk/source/de/anomic/xml/rssReader.java Log: more generics Modified: trunk/htroot/htdocsdefault/dir.java =================================================================== --- trunk/htroot/htdocsdefault/dir.java 2008-01-23 20:18:36 UTC (rev 4378) +++ trunk/htroot/htdocsdefault/dir.java 2008-01-23 21:09:56 UTC (rev 4379) @@ -1,13 +1,15 @@ // dir.java -// ----------------------- -// (C) by Michael Peter Christen; [EMAIL PROTECTED] -// first published on http://www.anomic.de -// Frankfurt, Germany, 2004, 2005 +// (C) 2004, 2005 by Michael Peter Christen; [EMAIL PROTECTED], Frankfurt a. M., Germany +// first published 2004 on http://yacy.net // +// This is a part of YaCy, a peer-to-peer based web search engine +// // $LastChangedDate$ // $LastChangedRevision$ // $LastChangedBy$ // +// LICENSE +// // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or @@ -21,30 +23,6 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// Using this software in any meaning (reading, learning, copying, compiling, -// running) means that you agree that the Author(s) is (are) not responsible -// for cost, loss of data or any harm that may be caused directly or indirectly -// by usage of this softare or this documentation. The usage of this software -// is on your own risk. The installation and usage (starting/running) of this -// software may allow other people or application to access your computer and -// any attached devices and is highly dependent on the configuration of the -// software which must be done by the user of the software; the author(s) is -// (are) also not responsible for proper configuration and usage of the -// software, even if provoked by documentation provided together with -// the software. -// -// Any changes to this file according to the GPL as documented in the file -// gpl.txt aside this file in the shipment you received can be done to the -// lines that follows this copyright notice here, but changes must not be -// done inside the copyright notive above. A re-distribution must contain -// the intact and unchanged copyright notice. -// Contributions and changes to the program code must be marked as such. -// -// You must compile this file with -// javac -classpath <application_root>/classes <application_root>/htroot/htdocsdefault/dir.java -// which most probably means to compile this with -// javac -classpath ../../classes dir.java import java.io.ByteArrayInputStream; import java.io.File; @@ -53,6 +31,7 @@ import java.net.UnknownHostException; import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.Comparator; import java.util.Date; import java.util.Iterator; @@ -74,7 +53,6 @@ import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; import de.anomic.server.logging.serverLog; -import de.anomic.tools.dirlistComparator; import de.anomic.tools.md5DirFileFilter; import de.anomic.yacy.yacyCore; import de.anomic.yacy.yacySeed; @@ -233,7 +211,7 @@ // sorting the dir list dirlistComparator comparator = new dirlistComparator(); - Arrays.sort(list,comparator); + Arrays.sort(list, comparator); String md5s, description; // tree += "<span class=\"tt\">path = " + path + "</span><br><br>"; @@ -399,10 +377,10 @@ public static void deletePhrase(plasmaSwitchboard switchboard, String urlstring, String phrase, String descr) { try { final String urlhash = (new yacyURL(urlstring, null)).hash(); - final Iterator words = plasmaCondenser.getWords(("yacyshare " + phrase + " " + descr).getBytes("UTF-8"), "UTF-8").keySet().iterator(); + final Iterator<String> words = plasmaCondenser.getWords(("yacyshare " + phrase + " " + descr).getBytes("UTF-8"), "UTF-8").keySet().iterator(); String word; while (words.hasNext()) { - word = (String) words.next(); + word = words.next(); switchboard.wordIndex.removeEntry(plasmaCondenser.word2hash(word), urlhash); } switchboard.wordIndex.loadedURL.remove(urlhash); @@ -411,4 +389,17 @@ } } + public static class dirlistComparator implements Comparator<File> { + + public int compare(File file1, File file2) { + if (file1.isDirectory() && !file2.isDirectory()) { + return -1; + } else if (!file1.isDirectory() && file2.isDirectory()) { + return 1; + } else { + return file1.getName().compareToIgnoreCase(file2.getName()); + } + } + + } } Modified: trunk/source/de/anomic/tools/PKCS12Tool.java =================================================================== --- trunk/source/de/anomic/tools/PKCS12Tool.java 2008-01-23 20:18:36 UTC (rev 4378) +++ trunk/source/de/anomic/tools/PKCS12Tool.java 2008-01-23 21:09:56 UTC (rev 4379) @@ -80,14 +80,13 @@ fileIn.close(); } - public Enumeration aliases() throws KeyStoreException { - Enumeration aliases = this.kspkcs12.aliases(); - return aliases; + public Enumeration<String> aliases() throws KeyStoreException { + return this.kspkcs12.aliases(); } public void printAliases() throws KeyStoreException { - Enumeration aliases = aliases(); - while(aliases.hasMoreElements()) { + Enumeration<String> aliases = aliases(); + while (aliases.hasMoreElements()) { System.out.println(aliases.nextElement()); } } @@ -109,7 +108,7 @@ jks.load(jksFileIn,(jksPassword!=null)?jksPassword.toCharArray():null); if (jksFileIn != null) jksFileIn.close(); - Enumeration pkcs12Aliases = aliases(); + Enumeration<String> pkcs12Aliases = aliases(); while (pkcs12Aliases.hasMoreElements()) { String strAlias = (String)pkcs12Aliases.nextElement(); System.err.println("Importing Alias '" + strAlias + "'"); Modified: trunk/source/de/anomic/tools/cryptbig.java =================================================================== --- trunk/source/de/anomic/tools/cryptbig.java 2008-01-23 20:18:36 UTC (rev 4378) +++ trunk/source/de/anomic/tools/cryptbig.java 2008-01-23 21:09:56 UTC (rev 4379) @@ -194,15 +194,15 @@ // This method returns the available implementations for a service type - public static Set listCryptoMethods(String serviceType) { - Set result = new HashSet(); + public static Set<String> listCryptoMethods(String serviceType) { + Set<String> result = new HashSet<String>(); // All providers Provider[] providers = Security.getProviders(); for (int i = 0; i < providers.length; i++) { // Get services provided by each provider - Set keys = providers[i].keySet(); - for (Iterator it = keys.iterator(); it.hasNext(); ) { + Set<?> keys = providers[i].keySet(); + for (Iterator<?> it = keys.iterator(); it.hasNext(); ) { String key = (String) it.next(); key = key.split(" ")[0]; if (key.startsWith(serviceType + ".")) { @@ -216,9 +216,9 @@ return result; } - public static void testCryptMethods(Set methods) { + public static void testCryptMethods(Set<String> methods) { String method; - Iterator i = methods.iterator(); + Iterator<String> i = methods.iterator(); while (i.hasNext()) { method = (String) i.next(); System.out.print(method + " : "); @@ -569,7 +569,7 @@ } if (s[0].equals("-tc")) { // list all available crypt mehtods: - Set methods = listCryptoMethods("Cipher"); + Set<String> methods = listCryptoMethods("Cipher"); System.out.println(methods.size() + " crypt methods:" + methods.toString()); testCryptMethods(methods); System.exit(0); Deleted: trunk/source/de/anomic/tools/dirlistComparator.java =================================================================== --- trunk/source/de/anomic/tools/dirlistComparator.java 2008-01-23 20:18:36 UTC (rev 4378) +++ trunk/source/de/anomic/tools/dirlistComparator.java 2008-01-23 21:09:56 UTC (rev 4379) @@ -1,68 +0,0 @@ -package de.anomic.tools; -// dirlistComparator.java -// ----------------------- -// (C) by Michael Peter Christen; [EMAIL PROTECTED] -// first published on http://www.anomic.de -// Frankfurt, Germany, 2004, 2005 -// -// This file is contributed by Martin Thelian -// -// $LastChangedDate: 2006-08-06 10:09:39 +0200 (So, 06 Aug 2006) $ -// $LastChangedRevision: 2349 $ -// $LastChangedBy: theli $ -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// Using this software in any meaning (reading, learning, copying, compiling, -// running) means that you agree that the Author(s) is (are) not responsible -// for cost, loss of data or any harm that may be caused directly or indirectly -// by usage of this softare or this documentation. The usage of this software -// is on your own risk. The installation and usage (starting/running) of this -// software may allow other people or application to access your computer and -// any attached devices and is highly dependent on the configuration of the -// software which must be done by the user of the software; the author(s) is -// (are) also not responsible for proper configuration and usage of the -// software, even if provoked by documentation provided together with -// the software. -// -// Any changes to this file according to the GPL as documented in the file -// gpl.txt aside this file in the shipment you received can be done to the -// lines that follows this copyright notice here, but changes must not be -// done inside the copyright notive above. A re-distribution must contain -// the intact and unchanged copyright notice. -// Contributions and changes to the program code must be marked as such. -import java.io.File; -import java.util.Comparator; - - -public class dirlistComparator implements Comparator { - - public int compare(Object obj1, Object obj2) { - if (!(obj1 instanceof File)) throw new IllegalArgumentException(); - if (!(obj2 instanceof File)) throw new IllegalArgumentException(); - - File file1 = (File)obj1; - File file2 = (File)obj2; - - if (file1.isDirectory() && !file2.isDirectory()) { - return -1; - } else if (!file1.isDirectory() && file2.isDirectory()) { - return 1; - } else { - return file1.getName().compareToIgnoreCase(file2.getName()); - } - } - -} Modified: trunk/source/de/anomic/tools/disorderHeap.java =================================================================== --- trunk/source/de/anomic/tools/disorderHeap.java 2008-01-23 20:18:36 UTC (rev 4378) +++ trunk/source/de/anomic/tools/disorderHeap.java 2008-01-23 21:09:56 UTC (rev 4379) @@ -45,51 +45,51 @@ public class disorderHeap { - LinkedList list; + LinkedList<String> list; public disorderHeap() { - list = new LinkedList(); + list = new LinkedList<String>(); } public disorderHeap(int numbers) { - // create a disorder heap with numbers in it - // the numbers are 0..numbers-1 - this(); - for (int i = 0; i < numbers; i++) add(Integer.toString(i)); + // create a disorder heap with numbers in it + // the numbers are 0..numbers-1 + this(); + for (int i = 0; i < numbers; i++) add(Integer.toString(i)); } - public synchronized void add(Object element) { - // add one element into the list at an arbitrary position - int pos = (int) ((System.currentTimeMillis() / 7) % (list.size() + 1)); - list.add(pos, element); + public synchronized void add(String element) { + // add one element into the list at an arbitrary position + int pos = (int) ((System.currentTimeMillis() / 7) % (list.size() + 1)); + list.add(pos, element); } - public synchronized Object remove() { - if (list.size() == 0) return null; - int pos = (int) ((System.currentTimeMillis() / 13) % list.size()); - return list.remove(pos); + public synchronized String remove() { + if (list.size() == 0) return null; + int pos = (int) ((System.currentTimeMillis() / 13) % list.size()); + return list.remove(pos); } public synchronized int number() { - String n = (String) this.remove(); - if (n == null) return -1; - try { - return Integer.parseInt(n); - } catch (Exception e) { - return -1; - } + String n = this.remove(); + if (n == null) return -1; + try { + return Integer.parseInt(n); + } catch (Exception e) { + return -1; + } } public synchronized int size() { - return list.size(); + return list.size(); } public static void main(String[] args) { - disorderHeap ul = new disorderHeap(); - for (int i = 0; i < args.length; i++) ul.add(args[i]); - for (int i = 0; i < args.length; i++) System.out.print((String) ul.remove() + " "); - System.out.println(); + disorderHeap ul = new disorderHeap(); + for (int i = 0; i < args.length; i++) ul.add(args[i]); + for (int i = 0; i < args.length; i++) System.out.print(ul.remove() + " "); + System.out.println(); } } \ No newline at end of file Modified: trunk/source/de/anomic/tools/disorderSet.java =================================================================== --- trunk/source/de/anomic/tools/disorderSet.java 2008-01-23 20:18:36 UTC (rev 4378) +++ trunk/source/de/anomic/tools/disorderSet.java 2008-01-23 21:09:56 UTC (rev 4379) @@ -38,44 +38,43 @@ // the intact and unchanged copyright notice. // Contributions and changes to the program code must be marked as such. - package de.anomic.tools; import java.util.HashSet; import java.util.Iterator; import java.util.Set; -public class disorderSet extends HashSet implements Set { +public class disorderSet extends HashSet<String> implements Set<String> { private static final long serialVersionUID = 1L; - disorderHeap dh; + disorderHeap dh; public disorderSet() { - super(); - dh = null; + super(); + dh = null; } public boolean hasAny() { - return (this.size() > 0); + return (this.size() > 0); } public Object any() { - // return just any element - if ((dh == null) || (dh.size() == 0)) { - if (this.size() == 0) return null; - // fill up the queue - dh = new disorderHeap(); - Iterator elements = this.iterator(); - while (elements.hasNext()) dh.add(elements.next()); - } - return dh.remove(); + // return just any element + if ((dh == null) || (dh.size() == 0)) { + if (this.size() == 0) return null; + // fill up the queue + dh = new disorderHeap(); + Iterator<String> elements = this.iterator(); + while (elements.hasNext()) dh.add(elements.next()); + } + return dh.remove(); } public static void main(String[] args) { - disorderSet ds = new disorderSet(); - for (int i = 0; i < args.length; i++) ds.add(args[i]); - for (int i = 0; i < args.length * 3; i++) System.out.print((String) ds.any() + " "); - System.out.println(); + disorderSet ds = new disorderSet(); + for (int i = 0; i < args.length; i++) ds.add(args[i]); + for (int i = 0; i < args.length * 3; i++) System.out.print((String) ds.any() + " "); + System.out.println(); } } \ No newline at end of file Modified: trunk/source/de/anomic/tools/enumerateFiles.java =================================================================== --- trunk/source/de/anomic/tools/enumerateFiles.java 2008-01-23 20:18:36 UTC (rev 4378) +++ trunk/source/de/anomic/tools/enumerateFiles.java 2008-01-23 21:09:56 UTC (rev 4379) @@ -45,14 +45,14 @@ import java.util.Enumeration; import java.util.TreeSet; -public class enumerateFiles implements Enumeration { +public class enumerateFiles implements Enumeration<File> { // implements iterative search through recursively defined subdirectories // and return all paths to the files - private ArrayList hierarchy; // contains TreeSet elements, each TreeSet contains File Entries + private ArrayList<TreeSet<File>> hierarchy; // contains TreeSet elements, each TreeSet contains File Entries private boolean incOrder; // if true, the smallest value is returned first - private Object buffer; // the prefetch-buffer + private File buffer; // the prefetch-buffer private boolean return_files; private boolean return_folders; private boolean delete_emptyFolders; @@ -62,10 +62,10 @@ this.return_files = files; this.return_folders = folders; this.delete_emptyFolders = deleteEmptyFolders; - this.hierarchy = new ArrayList(); + this.hierarchy = new ArrayList<TreeSet<File>>(); this.incOrder = increasing; // the we initially fill the hierarchy with the content of the root folder - TreeSet t = new TreeSet(); + TreeSet<File> t = new TreeSet<File>(); String[] l = root.list(); // System.out.println("D " + l.toString()); if (l != null) for (int i = 0; i < l.length; i++) t.add(new File(root, l[i])); @@ -74,15 +74,15 @@ this.buffer = nextElement0(); } - private Object nextElement0() { + private File nextElement0() { // the object is a File pointing to the corresponding file File f; - TreeSet t; + TreeSet<File> t; do { // System.out.println("D " + hierarchy.toString()); t = null; while ((t == null) && (hierarchy.size() > 0)) { - t = (TreeSet) hierarchy.get(hierarchy.size() - 1); + t = hierarchy.get(hierarchy.size() - 1); if (t.size() == 0) { hierarchy.remove(hierarchy.size() - 1); // we step up one hierarchy t = null; @@ -94,7 +94,7 @@ t.remove(f); // if the value represents another folder, we step into the next hierarchy if (f.isDirectory()) { - t = new TreeSet(); + t = new TreeSet<File>(); String[] l = f.list(); if (l == null) { // f has disappeared @@ -125,8 +125,8 @@ return buffer != null; } - public Object nextElement() { - Object r = buffer; + public File nextElement() { + File r = buffer; buffer = nextElement0(); return r; } Modified: trunk/source/de/anomic/tools/loaderThreads.java =================================================================== --- trunk/source/de/anomic/tools/loaderThreads.java 2008-01-23 20:18:36 UTC (rev 4378) +++ trunk/source/de/anomic/tools/loaderThreads.java 2008-01-23 21:09:56 UTC (rev 4379) @@ -57,7 +57,7 @@ protected httpRemoteProxyConfig remoteProxyConfig; // management objects for collection of threads - Hashtable threads; + Hashtable<String, Thread> threads; int completed, failed; public loaderThreads() { @@ -78,7 +78,7 @@ this.user = user; this.password = password; this.remoteProxyConfig = theremoteProxyConfig; - this.threads = new Hashtable(); + this.threads = new Hashtable<String, Thread>(); this.completed = 0; this.failed = 0; } @@ -199,7 +199,7 @@ int line = 0; String s, key, value; int p; - ArrayList lines = nxTools.strings(v); + ArrayList<String> lines = nxTools.strings(v); try { while ((this.run) && (line < lines.size())) { // parse line and construct a property Modified: trunk/source/de/anomic/xml/crawlHandler.java =================================================================== --- trunk/source/de/anomic/xml/crawlHandler.java 2008-01-23 20:18:36 UTC (rev 4378) +++ trunk/source/de/anomic/xml/crawlHandler.java 2008-01-23 21:09:56 UTC (rev 4379) @@ -54,7 +54,7 @@ "docs" // }; - private static final HashSet startpointTagsSet = new HashSet(); + private static final HashSet<String> startpointTagsSet = new HashSet<String>(); static { for (int i = 0; i < startpointTags.length; i++) { startpointTagsSet.add(startpointTags[i]); @@ -65,8 +65,8 @@ private Startpoint channel, startpoint; private StringBuffer buffer; private boolean parsingAttributes, parsingStartpoint; - private ArrayList startpointsGUID; // a list of GUIDs, so the items can be retrieved by a specific order - private HashMap startpoints; // a guid:Item map + private ArrayList<String> startpointsGUID; // a list of GUIDs, so the items can be retrieved by a specific order + private HashMap<String, Startpoint> startpoints; // a guid:Item map public crawlHandler(String path) { @@ -80,8 +80,8 @@ } private void init() { - startpointsGUID = new ArrayList(); - startpoints = new HashMap(); + startpointsGUID = new ArrayList<String>(); + startpoints = new HashMap<String, Startpoint>(); buffer = new StringBuffer(); startpoint = null; channel = null; @@ -165,10 +165,10 @@ public static class Attributes { - private HashMap map; + private HashMap<String, String> map; public Attributes() { - this.map = new HashMap(); + this.map = new HashMap<String, String>(); } public void setValue(String name, String value) { @@ -222,10 +222,10 @@ public static class Startpoint { - private HashMap map; + private HashMap<String, String> map; public Startpoint() { - this.map = new HashMap(); + this.map = new HashMap<String, String>(); this.map.put("guid", Long.toHexString(System.currentTimeMillis()) + ":" + guidcount++); } Modified: trunk/source/de/anomic/xml/rssReader.java =================================================================== --- trunk/source/de/anomic/xml/rssReader.java 2008-01-23 20:18:36 UTC (rev 4378) +++ trunk/source/de/anomic/xml/rssReader.java 2008-01-23 21:09:56 UTC (rev 4379) @@ -62,7 +62,7 @@ "docs" // }; - private static final HashSet tags = new HashSet(); + private static final HashSet<String> tags = new HashSet<String>(); static { for (int i = 0; i < tagsDef.length; i++) { tags.add(tagsDef[i]); @@ -74,13 +74,13 @@ private StringBuffer buffer; private boolean parsingChannel, parsingImage, parsingItem; private String imageURL; - private ArrayList itemsGUID; // a list of GUIDs, so the items can be retrieved by a specific order - private HashMap items; // a guid:Item map + private ArrayList<String> itemsGUID; // a list of GUIDs, so the items can be retrieved by a specific order + private HashMap<String, Item> items; // a guid:Item map public rssReader() { - itemsGUID = new ArrayList(); - items = new HashMap(); + itemsGUID = new ArrayList<String>(); + items = new HashMap<String, Item>(); buffer = new StringBuffer(); item = null; channel = null; @@ -215,10 +215,10 @@ public static class Item { - private HashMap map; + private HashMap<String, String> map; public Item() { - this.map = new HashMap(); + this.map = new HashMap<String, String>(); this.map.put("guid", Long.toHexString(System.currentTimeMillis()) + ":" + guidcount++); } _______________________________________________ YaCy-svn mailing list YaCy-svn@lists.berlios.de https://lists.berlios.de/mailman/listinfo/yacy-svn