001: //$Id: RSSDoublinCoreModule.java,v 1.5 2004/03/25 10:09:10 taganaka Exp $
002: package org.gnu.stealthp.rsslib;
003:
004: import java.util.*;
005:
006: /**
007: * Handler for doublin core information.
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: * <b>Namespace Declarations</b><br>
015: * <ul>
016: * <li><b>xmlns:dc="http://purl.org/dc/elements/1.1/"</b></li>
017: * </ul>
018: * <h2><a name="model">Model</a></h2>
019: * <p>
020: * <em><channel>, <item>, <image>, and <textinput> Elements:</em> </p>
021: * <ul>
022: * <li><b><dc:title></b> ( #PCDATA )</li>
023: * <li><b><dc:creator></b> ( #PCDATA )</li>
024: * <li><b><dc:subject></b> ( #PCDATA )</li>
025: * <li><b><dc:description></b> ( #PCDATA )</li>
026: * <li><b><dc:publisher></b> ( #PCDATA )</li>
027: * <li><b><dc:contributor></b> ( #PCDATA )</li>
028: * <li><b><dc:date></b> ( #PCDATA ) [<a href="http://www.w3.org/TR/NOTE-datetime">W3CDTF</a>]</li>
029: * <li><b><dc:type></b> ( #PCDATA )</li>
030: * <li><b><dc:format></b> ( #PCDATA )</li>
031: * <li><b><dc:identifier></b> ( #PCDATA )</li>
032: * <li><b><dc:source></b> ( #PCDATA )</li>
033: * <li><b><dc:language></b> ( #PCDATA )</li>
034: * <li><b><dc:relation></b> ( #PCDATA )</li>
035: * <li><b><dc:coverage></b> ( #PCDATA )</li>
036: * <li><b><dc:rights></b> ( #PCDATA )</li>
037: * </ul>
038: *
039: * </p>
040: *
041: * </blockquote>
042: *
043: *
044: *
045: * @since RSSLIB4J 0.1
046: * @author Francesco aka 'Stealthp' stealthp[@]stealthp.org
047: * @version 0.2
048: */
049:
050: public class RSSDoublinCoreModule {
051: private String title;
052: private String creator;
053: private String subject;
054: private String description;
055: private String publisher;
056: private String contributor;
057: private String date;
058: private String type;
059: private String format;
060: private String identifier;
061: private String source;
062: private String language;
063: private String relation;
064: private String coverage;
065: private String rights;
066:
067: /**
068: * Set the title
069: * @param t title
070: */
071: public void setDcTitle(String t) {
072: title = t;
073: }
074:
075: /**
076: * Set the creator
077: * @param t creator
078: */
079: public void setDcCreator(String t) {
080: creator = t;
081: }
082:
083: /**
084: * Set subject
085: * @param t subject
086: */
087: public void setDcSubject(String t) {
088: subject = t;
089: }
090:
091: /**
092: * Set the description
093: * @param t description
094: */
095: public void setDcDescription(String t) {
096: description = t;
097: }
098:
099: /**
100: * Set the publiscer
101: * @param t publisher
102: */
103: public void setDcPublisher(String t) {
104: publisher = t;
105: }
106:
107: /**
108: * Set the Contributor
109: * @param t contributor
110: */
111: public void setDcContributor(String t) {
112: contributor = t;
113: }
114:
115: /**
116: * Set the date
117: * @param t date
118: */
119: public void setDcDate(String t) {
120: date = t;
121: }
122:
123: /**
124: * Set the type
125: * @param t typr
126: */
127: public void setDcType(String t) {
128: type = t;
129: }
130:
131: /**
132: * Set the format
133: * @param t format
134: */
135: public void setDcFormat(String t) {
136: format = t;
137: }
138:
139: /**
140: * Set the identifier
141: * @param t identifier
142: */
143: public void setDcIdentifier(String t) {
144: identifier = t;
145: }
146:
147: /**
148: * Set the source
149: * @param t source
150: */
151: public void setDcSource(String t) {
152: source = t;
153: }
154:
155: /**
156: * Set the language
157: * @param t language
158: */
159: public void setDcLanguage(String t) {
160: language = t;
161: }
162:
163: /**
164: * Set declaration
165: * @param t declaration
166: */
167: public void setDcRelation(String t) {
168: relation = t;
169: }
170:
171: /**
172: * Set coverage
173: * @param t coverage
174: */
175: public void setDcCoverage(String t) {
176: coverage = t;
177: }
178:
179: /**
180: * Set copy rights
181: * @param t rights
182: */
183: public void setDcRights(String t) {
184: rights = t;
185: }
186:
187: /**
188: * Get the title
189: * @return title
190: */
191: public String getDcTitle() {
192: return title;
193: }
194:
195: /**
196: * Get the creator
197: * @return creator
198: */
199: public String getDcCreator() {
200: return creator;
201: }
202:
203: /**
204: * Get the subject
205: * @return subject
206: */
207: public String getDcSubject() {
208: return subject;
209: }
210:
211: /**
212: * Get description
213: * @return description
214: */
215: public String getDcDescription() {
216: return description;
217: }
218:
219: /**
220: * Get the publischer
221: * @return the publischer
222: */
223: public String getDcPublisher() {
224: return publisher;
225: }
226:
227: /**
228: * Get the contributor
229: * @return contributor
230: */
231: public String getDcContributor() {
232: return contributor;
233: }
234:
235: /**
236: * Get the date
237: * @return date
238: */
239: public String getDcDate() {
240: return date;
241: }
242:
243: /**
244: * Get the type
245: * @return the type
246: */
247: public String getDcType() {
248: return type;
249: }
250:
251: /**
252: * The format
253: * @return format
254: */
255: public String getDcFormat() {
256: return format;
257: }
258:
259: /**
260: * Get the identifier
261: * @return the identifier
262: */
263: public String getDcIdentifier() {
264: return identifier;
265: }
266:
267: /**
268: * Get the source
269: * @return the source
270: */
271: public String getDcSource() {
272: return source;
273: }
274:
275: /**
276: * Get the language
277: * @return language
278: */
279: public String getDcLanguage() {
280: return language;
281: }
282:
283: /**
284: * Get the declaration
285: * @return declaration
286: */
287: public String getDcRelation() {
288: return relation;
289: }
290:
291: /**
292: * Get the coverage
293: * @return coverage
294: */
295: public String getDcCoverage() {
296: return coverage;
297: }
298:
299: /**
300: * The Right
301: * @return right
302: */
303: public String getDcRight() {
304: return title;
305: }
306:
307: /**
308: * A poor informational string
309: * @return info
310: */
311: public String toString() {
312: String info = "DC SUBJECT: " + subject + "\nDC CREATOR: "
313: + creator;
314: return info;
315: }
316:
317: /**
318: * Build a RSSDoublinCoreModule object from an Hashtable
319: * @param t The Hashtable with key as dc tag and value as tag's value
320: * @return the RSSDoublinCoreModule object
321: */
322: protected static RSSDoublinCoreModule buildDcModule(Hashtable t) {
323:
324: if (t == null || t.size() == 0)
325: return null;
326:
327: RSSDoublinCoreModule dc = new RSSDoublinCoreModule();
328:
329: Hashtable tbl = t;
330:
331: Enumeration en = t.keys();
332:
333: while (en.hasMoreElements()) {
334:
335: String qName = (String) en.nextElement();
336: String data = (String) tbl.get(qName);
337:
338: if (data == null)
339: continue;
340:
341: if (RSSHandler.tagIsEqual(RSSHandler.DC_TITLE_TAG, qName))
342: dc.setDcTitle(data);
343:
344: if (RSSHandler.tagIsEqual(RSSHandler.DC_CREATOR_TAG, qName))
345: dc.setDcCreator(data);
346:
347: if (RSSHandler.tagIsEqual(RSSHandler.DC_SUBJECT_TAG, qName))
348: dc.setDcSubject(data);
349:
350: if (RSSHandler.tagIsEqual(RSSHandler.DC_DESCRIPTION_TAG,
351: qName))
352: dc.setDcDescription(data);
353:
354: if (RSSHandler.tagIsEqual(RSSHandler.DC_PUBLISHER_TAG,
355: qName))
356: dc.setDcPublisher(data);
357:
358: if (RSSHandler.tagIsEqual(RSSHandler.DC_CONTRIBUTOR_TAG,
359: qName))
360: dc.setDcContributor(data);
361:
362: if (RSSHandler.tagIsEqual(RSSHandler.DC_DATE_TAG, qName))
363: dc.setDcDate(data);
364:
365: if (RSSHandler.tagIsEqual(RSSHandler.DC_TYPE_TAG, qName))
366: dc.setDcType(data);
367:
368: if (RSSHandler.tagIsEqual(RSSHandler.DC_FORMAT_TAG, qName))
369: dc.setDcFormat(data);
370:
371: if (RSSHandler.tagIsEqual(RSSHandler.DC_IDENTIFIER_TAG,
372: qName))
373: dc.setDcIdentifier(data);
374:
375: if (RSSHandler.tagIsEqual(RSSHandler.DC_SOURCE_TAG, qName))
376: dc.setDcSource(data);
377:
378: if (RSSHandler
379: .tagIsEqual(RSSHandler.DC_LANGUAGE_TAG, qName))
380: dc.setDcLanguage(data);
381:
382: if (RSSHandler
383: .tagIsEqual(RSSHandler.DC_RELATION_TAG, qName))
384: dc.setDcRelation(data);
385:
386: if (RSSHandler
387: .tagIsEqual(RSSHandler.DC_COVERAGE_TAG, qName))
388: dc.setDcCoverage(data);
389:
390: if (RSSHandler.tagIsEqual(RSSHandler.DC_RIGHTS_TAG, qName))
391: dc.setDcRights(data);
392: }
393:
394: return dc;
395: }
396:
397: }
|