X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=source%2Fmir%2Frss%2FRSSData.java;h=a5e6181cefc88cbfc10de174a7bd7d0c51a6759c;hb=29da699109ce8842d02b60abcdb0dfdc4aa4f0db;hp=c5d4f1fb7a9102b3f843f41721952e6ab9c9d7d1;hpb=55d545036aa5c04676f2d20f0e98316a4679ec27;p=mir.git diff --git a/source/mir/rss/RSSData.java b/source/mir/rss/RSSData.java index c5d4f1fb..a5e6181c 100755 --- a/source/mir/rss/RSSData.java +++ b/source/mir/rss/RSSData.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001, 2002 The Mir-coders group + * Copyright (C) 2001, 2002 The Mir-coders group * * This file is part of Mir. * @@ -18,17 +18,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. + * If you do not wish to do so, delete this exception statement from your version. */ - package mir.rss; import java.util.HashMap; @@ -37,34 +35,46 @@ import java.util.Map; import java.util.Vector; public class RSSData { - private List items; - private Map item; - private RSSChannel channel; + private List resources; + private Map rdfClassToResources; + private Map identifierToResource; protected RSSData() { - items = new Vector(); - item = new HashMap(); - channel = null; + resources = new Vector(); + rdfClassToResources = new HashMap(); + identifierToResource = new HashMap(); } - protected void addItem(RSSItem anItem) { - items.add(anItem); - item.put(anItem.getIdentifier(), anItem); - }; + public List getAllResources() { + return resources; + } - public void setChannel(RSSChannel aChannel) { - channel = aChannel; + public void addResource(RDFResource aResource) { + resources.add(aResource); + List resourcesForClass = (List) rdfClassToResources.get(aResource.getRdfClass()); + if (resourcesForClass==null) { + resourcesForClass = new Vector(); + rdfClassToResources.put(aResource.getRdfClass(), resourcesForClass); + } + resourcesForClass.add(aResource); + if (aResource.getIdentifier()!=null) + identifierToResource.put(aResource.getIdentifier(), aResource); } - public RSSChannel getChannel() { - return channel; + public List getResourcesForRdfClass(String aClass) { + return (List) rdfClassToResources.get(aClass); } - public List getItems() { - return items; + public RDFResource getResourceForIdentifier(String anIdentifier) { + return (RDFResource) identifierToResource.get(anIdentifier); } - public Map getItem() { - return item; + public Object get(String aKey) { + Object result = getResourceForIdentifier(aKey); + + if (result==null) + return getResourcesForRdfClass(aKey); + else + return result; } }