From: <dam...@us...> - 2006-03-20 00:10:45
|
Revision: 973 Author: damokles Date: 2006-03-19 16:10:34 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=973&view=rev Log Message: ----------- added UpdateList Modified Paths: -------------- trunk/AZMultiUser/lbms/tools/updater/Update.java Added Paths: ----------- trunk/AZMultiUser/lbms/tools/updater/UpdateList.java Modified: trunk/AZMultiUser/lbms/tools/updater/Update.java =================================================================== --- trunk/AZMultiUser/lbms/tools/updater/Update.java 2006-03-19 13:10:39 UTC (rev 972) +++ trunk/AZMultiUser/lbms/tools/updater/Update.java 2006-03-20 00:10:34 UTC (rev 973) @@ -15,8 +15,8 @@ public static final int LV_FEATURE = 20; public static final int LV_LOW = 1; - public static final int TYPE_BETA = 1; - public static final int TYPE_STABLE = 2; + public static final int TYPE_BETA = 1; + public static final int TYPE_STABLE = 2; public static final int TYPE_MAINTENANCE = 3; private List<UpdateFile> fileList = new ArrayList<UpdateFile>(); @@ -91,6 +91,14 @@ else return true; } + public boolean isStable() { + return (type >= TYPE_STABLE); + } + + public boolean isBeta() { + return (type == TYPE_BETA); + } + public int compareTo(Update o) { return version.compareTo(o.version); } Added: trunk/AZMultiUser/lbms/tools/updater/UpdateList.java =================================================================== --- trunk/AZMultiUser/lbms/tools/updater/UpdateList.java (rev 0) +++ trunk/AZMultiUser/lbms/tools/updater/UpdateList.java 2006-03-20 00:10:34 UTC (rev 973) @@ -0,0 +1,71 @@ +package lbms.tools.updater; + +import java.util.List; +import java.util.Comparator; +import java.util.Iterator; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.jdom.Document; +import org.jdom.Element; + + + +public class UpdateList { + private SortedSet<Update> uSet = new TreeSet<Update>(new Comparator<Update>() { + public int compare(Update o1, Update o2) { + return o1.compareTo(o2)*-1; //We need Descending order to speed things up + } + }); + + public UpdateList() { + + } + + public UpdateList(Document xml) { + Element root = xml.getRootElement(); + List<Element> updates = root.getChildren("Update"); + for (Element u:updates) { + uSet.add(new Update(u)); + } + } + + public Document toDocument() { + Document doc = new Document(); + Element root = new Element ("Updates"); + Iterator<Update> it = uSet.iterator(); + Update result = null; + while (it.hasNext()) { + root.addContent(it.next().toElement()); + } + doc.addContent(root); + return doc; + } + + public Update getLatest () { + return uSet.first(); + } + + public Update getLatestStable() { + Iterator<Update> it = uSet.iterator(); + Update result = null; + while (it.hasNext()) { + result = it.next(); + if (result.isStable()) break; + result = null; + } + return result; + } + + public SortedSet<Update> getUpdateSet () { + return uSet; + } + + protected void addUpdate (Update u) { + uSet.add(u); + } + + protected void removeUpdate (Update u) { + uSet.remove(u); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |