From: <the...@us...> - 2003-12-17 23:07:03
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/controller In directory sc8-pr-cvs1:/tmp/cvs-serv7465 Modified Files: WhoIsOnlineAction.java Log Message: sorting and hard coded rows, but slow.... Index: WhoIsOnlineAction.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/controller/WhoIsOnlineAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WhoIsOnlineAction.java 17 Dec 2003 16:59:12 -0000 1.1 --- WhoIsOnlineAction.java 17 Dec 2003 23:06:59 -0000 1.2 *************** *** 23,26 **** --- 23,30 ---- package junk.controller; + import java.util.ArrayList; + import java.util.Iterator; + import java.util.TreeSet; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; *************** *** 28,32 **** --- 32,38 ---- import junk.plugin.scanner.ScannerPlugin; + import junk.util.Computer; import junk.util.HostMap; + import junk.util.NameOnline; import org.apache.struts.action.Action; *************** *** 51,75 **** .getAttribute(ScannerPlugin.KEY_HOSTS_MAP); ! java.util.Iterator i = hosts.keySet().iterator(); ! ! java.util.TreeSet l = new java.util.TreeSet(); while (i.hasNext()) { String ip = (String) i.next(); ! junk.util.NameOnline no = (junk.util.NameOnline) hosts.get(ip); ! junk.util.Computer c = new junk.util.Computer(); ! c.setIp(ip); ! c.setName(no.getName()); ! c.setNetFiles(null); ! c.setOnline(no.getOnline()); ! l.add(c); } //free mem as soon as possible hosts = null; i = null; ! httpServletRequest.setAttribute(KEY_ONLINE_ITERATOR, l); return actionMapping.findForward("wio"); --- 57,114 ---- .getAttribute(ScannerPlugin.KEY_HOSTS_MAP); ! Iterator i = hosts.keySet().iterator(); ! TreeSet sortedOnline = new TreeSet(); while (i.hasNext()) { String ip = (String) i.next(); ! NameOnline no = (NameOnline) hosts.get(ip); ! ! if (no.getOnline().equals(Boolean.TRUE)) { ! Computer c = new Computer(); ! ! c.setIp(ip); ! c.setName(no.getName()); ! c.setNetFiles(null); ! c.setOnline(no.getOnline()); ! sortedOnline.add(c); ! } ! } ! ! i = sortedOnline.iterator(); ! ! int w = 4; //this will be a parameter ! ! //modulo stuff to get even values (yes... i know) ! int h = ((sortedOnline.size() % w) + sortedOnline.size()) / w; ! ! ArrayList col = new ArrayList(); ! ! for (int x = 0; x < h; x++) { ! ArrayList row = new ArrayList(); ! ! for (int j = 0; j < w; j++) { ! if (i.hasNext()) { ! Computer c = (Computer) i.next(); ! ! row.add(c); ! } else { ! break; ! } ! } ! ! if (i.hasNext()) { ! col.add(row); ! } else { ! break; ! } } //free mem as soon as possible + sortedOnline = null; hosts = null; i = null; ! httpServletRequest.setAttribute(KEY_ONLINE_ITERATOR, col); return actionMapping.findForward("wio"); |