KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snipsnap > semanticweb > DublinCore


1 /*
2  * This file is part of "SnipSnap Wiki/Weblog".
3  *
4  * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
5  * All Rights Reserved.
6  *
7  * Please visit http://snipsnap.org/ for updates and contact.
8  *
9  * --LICENSE NOTICE--
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  * --LICENSE NOTICE--
24  */

25
26 package org.snipsnap.semanticweb;
27
28 import org.snipsnap.app.Application;
29 import org.snipsnap.config.Configuration;
30 import org.snipsnap.snip.Snip;
31
32 import java.text.SimpleDateFormat JavaDoc;
33 import java.util.HashMap JavaDoc;
34 import java.util.Map JavaDoc;
35 import java.util.TimeZone JavaDoc;
36
37 /**
38  * Generates a map with dublin core entries
39  * see http://www.ietf.org/rfc/rfc2731.txt and
40  * http://dublincore.org/documents/dces/
41  *
42  * @author Stephan J. Schmidt
43  * @version $Id: DublinCore.java 1841 2005-11-17 12:03:54Z leo $
44  */

45
46 public class DublinCore {
47   // For date and time see http://www.w3.org/TR/NOTE-datetime
48
private static SimpleDateFormat JavaDoc sf = new SimpleDateFormat JavaDoc("yyyy-MM-dd'T'HH:mm:ss");
49   private static SimpleDateFormat JavaDoc year = new SimpleDateFormat JavaDoc("yyyy");
50
51   public static Map JavaDoc generate(Snip snip) {
52     Configuration conf = Application.get().getConfiguration();
53     sf.setTimeZone(TimeZone.getTimeZone(conf.getTimezone()));
54
55     Map JavaDoc dublinCore = new HashMap JavaDoc();
56     //@TODO add support for dc:subject, this is best read from a category label
57
dublinCore.put("creator", snip.getCUser());
58     dublinCore.put("title", snip.getName());
59     String JavaDoc date = sf.format(snip.getModified().getmTime());
60     String JavaDoc timeZone = conf.getTimezone();
61     if (timeZone != null && timeZone.length() > 3) {
62       if(timeZone.startsWith("GMT")) { timeZone = timeZone.substring(3); }
63       date = date + timeZone;
64     }
65     dublinCore.put("date", date);
66     dublinCore.put("type", "Text");
67     dublinCore.put("identifier", Application.get().getConfiguration().getSnipUrl(snip.getNameEncoded()));
68 // dublinCore.put("copyright", "Copyright " + year.format(snip.getModified().getmTime()));
69
dublinCore.put("language", conf.getLocale().getLanguage());
70     return dublinCore;
71   }
72
73   /**
74    * Identifier: Title
75    * Definition: A name given to the resource.
76    * Comment: Typically, a Title will be a name by which the resource is
77    * formally known.
78    *
79    * Identifier: Creator
80    * Definition: An entity primarily responsible for making the content of
81    * the resource.
82    * Comment: Examples of a Creator include a person, an organisation,
83    * or a service.
84    * Typically, the name of a Creator should be used to
85    * indicate the entity.
86    *
87    * Identifier: Subject
88    * Definition: The topic of the content of the resource.
89    * Comment: Typically, a Subject will be expressed as keywords,
90    * key phrases or classification codes that describe a topic
91    * of the resource.
92    * Recommended best practice is to select a value from a
93    * controlled vocabulary or formal classification scheme.
94    *
95    * Identifier: Description
96    * Definition: An account of the content of the resource.
97    * Comment: Description may include but is not limited to: an abstract,
98    * table of contents, reference to a graphical representation
99    * of content or a free-text account of the content.
100    *
101    * Identifier: Publisher
102    * Definition: An entity responsible for making the resource available
103    * Comment: Examples of a Publisher include a person, an organisation,
104    * or a service.
105    * Typically, the name of a Publisher should be used to
106    * indicate the entity.
107    *
108    * Identifier: Contributor
109    * Definition: An entity responsible for making contributions to the
110    * content of the resource.
111    * Comment: Examples of a Contributor include a person, an organisation,
112    * or a service.
113    * Typically, the name of a Contributor should be used to
114    * indicate the entity.
115    *
116    * Identifier: Date
117    * Definition: A date associated with an event in the life cycle of the
118    * resource.
119    * Comment: Typically, Date will be associated with the creation or
120    * availability of the resource. Recommended best practice
121    * for encoding the date value is defined in a profile of
122    * ISO 8601 [W3CDTF] and follows the YYYY-MM-DD format.
123    *
124    * Identifier: Type
125    * Definition: The nature or genre of the content of the resource.
126    * Comment: Type includes terms describing general categories, functions,
127    * genres, or aggregation levels for content. Recommended best
128    * practice is to select a value from a controlled vocabulary
129    * (for example, the working draft list of Dublin Core Types
130    * [c]). To describe the physical or digital manifestation
131    * of the resource, use the FORMAT element.
132    * http://dublincore.org/documents/dcmi-type-vocabulary/
133    *
134    * Identifier: Format
135    * Definition: The physical or digital manifestation of the resource.
136    * Comment: Typically, Format may include the media-type or dimensions of
137    * the resource. Format may be used to determine the software,
138    * hardware or other equipment needed to display or operate the
139    * resource. Examples of dimensions include size and duration.
140    * Recommended best practice is to select a value from a
141    * controlled vocabulary (for example, the list of Internet Media
142    * Types [MIME] defining computer media formats).
143    *
144    * Identifier: Identifier
145    * Definition: An unambiguous reference to the resource within a given context.
146    * Comment: Recommended best practice is to identify the resource by means
147    * of a string or number conforming to a formal identification
148    * system.
149    * Example formal identification systems include the Uniform
150    * Resource Identifier (URI) (including the Uniform Resource
151    * Locator (URL)), the Digital Object Identifier (DOI) and the
152    * International Standard Book Number (ISBN).
153    *
154    * Identifier: Source
155    * Definition: A Reference to a resource from which the present resource
156    * is derived.
157    * Comment: The present resource may be derived from the Source resource
158    * in whole or in part. Recommended best practice is to reference
159    * the resource by means of a string or number conforming to a
160    * formal identification system.
161    *
162    * Identifier: Language
163    * Definition: A language of the intellectual content of the resource.
164    * Comment: Recommended best practice for the values of the Language
165    * element is defined by RFC 1766 [RFC1766] which includes
166    * a two-letter Language Code (taken from the ISO 639
167    * standard [ISO639]), followed optionally, by a two-letter
168    * Country Code (taken from the ISO 3166 standard [ISO3166]).
169    * For example, 'en' for English, 'fr' for French, or
170    * 'en-uk' for English used in the United Kingdom.
171    *
172    * Identifier: Relation
173    * Definition: A reference to a related resource.
174    * Comment: Recommended best practice is to reference the resource by means
175    * of a string or number conforming to a formal identification
176    * system.
177    *
178    * Identifier: Coverage
179    * Definition: The extent or scope of the content of the resource.
180    * Comment: Coverage will typically include spatial location (a place name
181    * or geographic coordinates), temporal period (a period label,
182    * date, or date range) or jurisdiction (such as a named
183    * administrative entity).
184    * Recommended best practice is to select a value from a
185    * controlled vocabulary (for example, the Thesaurus of Geographic
186    * Names [TGN]) and that, where appropriate, named places or time
187    * periods be used in preference to numeric identifiers such as
188    * sets of coordinates or date ranges.
189    *
190    * Identifier: Rights
191    * Definition: Information about rights held in and over the resource.
192    * Comment: Typically, a Rights element will contain a rights
193    * management statement for the resource, or reference
194    * a service providing such information. Rights information
195    * often encompasses Intellectual Property Rights (IPR),
196    * Copyright, and various Property Rights.
197    * If the Rights element is absent, no assumptions can be made
198    * about the status of these and other rights with respect to
199    * the resource.
200    *
201    */

202 }
203
Popular Tags