* 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 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.
+ * 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.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;
}
}