001: //$Id: RSSObject.java,v 1.6 2004/03/25 10:09:10 taganaka Exp $
002: package org.gnu.stealthp.rsslib;
003:
004: import java.util.Hashtable;
005:
006: /**
007: * Handler for all common informations about rss elements.
008: *
009: * <blockquote>
010: * <em>This module, both source code and documentation, is in the
011: * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
012: * </blockquote>
013: *
014: * @since RSSLIB4J 0.1
015: * @author Francesco aka 'Stealthp' stealthp[@]stealthp.org
016: * @version 0.2
017: */
018:
019: public abstract class RSSObject {
020:
021: protected String about;
022: protected String title;
023: protected String link;
024: protected String description;
025: protected String pdate;
026: protected RSSDoublinCoreModule dc;
027: protected Hashtable dc_container;
028:
029: public RSSObject() {
030: dc_container = new Hashtable();
031: }
032:
033: /**
034: * Set the element title
035: * @param t The title
036: */
037: public void setTitle(String t) {
038: this .title = t;
039: }
040:
041: /**
042: * Set about attribute of the element (if have)
043: * @param ab The about content
044: */
045: public void setAboutAttribute(String ab) {
046: this .about = ab;
047: }
048:
049: /**
050: * Set the link of the resource
051: * @param l The link
052: */
053: public void setLink(String l) {
054: this .link = l;
055: }
056:
057: /**
058: * Set the descriprion of the element
059: * @param des The description
060: */
061: public void setDescription(String des) {
062: this .description = des;
063: }
064:
065: /**
066: * The publication date for the content in the channel or in the items
067: * @param pubDate The date
068: */
069: public void setPubDate(String pubDate) {
070: pdate = pubDate;
071: }
072:
073: public void setRSSDoublinCoreModule(RSSDoublinCoreModule m) {
074: dc = m;
075: }
076:
077: /**
078: * Get about attribute of element
079: * @return The attribute value
080: */
081: public String getAboutAttribute() {
082: return this .about;
083: }
084:
085: /**
086: * Get the element's title
087: * @return the title
088: */
089: public String getTitle() {
090: return this .title;
091: }
092:
093: /**
094: * Get the publication date of the channel or of an item
095: * @return The publication date for the content in the channel
096: */
097: public String getPubDate() {
098: return pdate;
099: }
100:
101: /**
102: * Get the element's link
103: * @return the link
104: */
105: public String getLink() {
106: return this .link;
107: }
108:
109: /**
110: * Get the element's description
111: * @return the descricption
112: */
113: public String getDescription() {
114: return this .description;
115: }
116:
117: /**
118: * Get the Roubin Core object from the RSS object
119: * @return The object or null
120: */
121: public RSSDoublinCoreModule getRSSDoublinCoreModule() {
122: if (dc != null)
123: return dc;
124: return RSSDoublinCoreModule.buildDcModule(dc_container);
125:
126: }
127:
128: /**
129: * Add a doublin core element to the object
130: * @param tag The dc tag
131: * @param data the dc value
132: */
133: public void addDoublinCoreElement(String tag, String data) {
134: //Remove old value
135: if (dc_container.containsKey(tag)) {
136: dc_container.remove(tag);
137: }
138: dc_container.put(tag, data);
139: }
140:
141: /**
142: * Get DC element by hashtable
143: * @return the hashtable with key as tag and value as tag's value
144: */
145: public Hashtable getDoublinCoreElements() {
146:
147: if (dc_container.size() == 0)
148: return null;
149:
150: return dc_container;
151: }
152:
153: /**
154: * Each class have to implement this information method
155: * @return An information about element
156: */
157: public abstract String toString();
158: }
|