001: /*
002: * $Id: DublinCoreSchema.java 2366 2006-09-14 23:10:58Z xlv $
003: * $Name$
004: *
005: * Copyright 2005 by Bruno Lowagie.
006: *
007: * The contents of this file are subject to the Mozilla Public License Version 1.1
008: * (the "License"); you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
010: *
011: * Software distributed under the License is distributed on an "AS IS" basis,
012: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
013: * for the specific language governing rights and limitations under the License.
014: *
015: * The Original Code is 'iText, a free JAVA-PDF library'.
016: *
017: * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
018: * the Initial Developer are Copyright (C) 1999-2005 by Bruno Lowagie.
019: * All Rights Reserved.
020: * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
021: * are Copyright (C) 2000-2005 by Paulo Soares. All Rights Reserved.
022: *
023: * Contributor(s): all the names of the contributors are added in the source code
024: * where applicable.
025: *
026: * Alternatively, the contents of this file may be used under the terms of the
027: * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
028: * provisions of LGPL are applicable instead of those above. If you wish to
029: * allow use of your version of this file only under the terms of the LGPL
030: * License and not to allow others to use your version of this file under
031: * the MPL, indicate your decision by deleting the provisions above and
032: * replace them with the notice and other provisions required by the LGPL.
033: * If you do not delete the provisions above, a recipient may use your version
034: * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE
035: *
036: * This library is free software; you can redistribute it and/or modify it
037: * under the terms of the MPL as stated above or under the terms of the GNU
038: * Library General Public License as published by the Free Software Foundation;
039: * either version 2 of the License, or any later version.
040: *
041: * This library is distributed in the hope that it will be useful, but WITHOUT
042: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
043: * FOR A PARTICULAR PURPOSE. See the GNU LIBRARY GENERAL PUBLIC LICENSE for more
044: * details.
045: *
046: * If you didn't download this code from the following link, you should check if
047: * you aren't using an obsolete version:
048: * http://www.lowagie.com/iText/
049: */
050:
051: package com.lowagie.text.xml.xmp;
052:
053: /**
054: * An implementation of an XmpSchema.
055: */
056: public class DublinCoreSchema extends XmpSchema {
057:
058: private static final long serialVersionUID = -4551741356374797330L;
059: /** default namespace identifier*/
060: public static final String DEFAULT_XPATH_ID = "dc";
061: /** default namespace uri*/
062: public static final String DEFAULT_XPATH_URI = "http://purl.org/dc/elements/1.1/";
063:
064: /** External Contributors to the resource (other than the authors). */
065: public static final String CONTRIBUTOR = "dc:contributor";
066: /** The extent or scope of the resource. */
067: public static final String COVERAGE = "dc:coverage";
068: /** The authors of the resource (listed in order of precedence, if significant). */
069: public static final String CREATOR = "dc:creator";
070: /** Date(s) that something interesting happened to the resource. */
071: public static final String DATE = "dc:date";
072: /** A textual description of the content of the resource. Multiple values may be present for different languages. */
073: public static final String DESCRIPTION = "dc:description";
074: /** The file format used when saving the resource. Tools and applications should set this property to the save format of the data. It may include appropriate qualifiers. */
075: public static final String FORMAT = "dc:format";
076: /** Unique identifier of the resource. */
077: public static final String IDENTIFIER = "dc:identifier";
078: /** An unordered array specifying the languages used in the resource. */
079: public static final String LANGUAGE = "dc:language";
080: /** Publishers. */
081: public static final String PUBLISHER = "dc:publisher";
082: /** Relationships to other documents. */
083: public static final String RELATION = "dc:relation";
084: /** Informal rights statement, selected by language. */
085: public static final String RIGHTS = "dc:rights";
086: /** Unique identifier of the work from which this resource was derived. */
087: public static final String SOURCE = "dc:source";
088: /** An unordered array of descriptive phrases or keywords that specify the topic of the content of the resource. */
089: public static final String SUBJECT = "dc:subject";
090: /** The title of the document, or the name given to the resource. Typically, it will be a name by which the resource is formally known. */
091: public static final String TITLE = "dc:title";
092: /** A document type; for example, novel, poem, or working paper. */
093: public static final String TYPE = "dc:type";
094:
095: public DublinCoreSchema() {
096: super ("xmlns:" + DEFAULT_XPATH_ID + "=\"" + DEFAULT_XPATH_URI
097: + "\"");
098: setProperty(FORMAT, "application/pdf");
099: }
100:
101: /**
102: * Adds a title.
103: * @param title
104: */
105: public void addTitle(String title) {
106: setProperty(TITLE, title);
107: }
108:
109: /**
110: * Adds a description.
111: * @param desc
112: */
113: public void addDescription(String desc) {
114: setProperty(DESCRIPTION, desc);
115: }
116:
117: /**
118: * Adds a subject.
119: * @param subject
120: */
121: public void addSubject(String subject) {
122: XmpArray array = new XmpArray(XmpArray.UNORDERED);
123: array.add(subject);
124: setProperty(SUBJECT, array);
125: }
126:
127: /**
128: * Adds a subject.
129: * @param subject array of subjects
130: */
131: public void addSubject(String[] subject) {
132: XmpArray array = new XmpArray(XmpArray.UNORDERED);
133: for (int i = 0; i < subject.length; i++) {
134: array.add(subject[i]);
135: }
136: setProperty(SUBJECT, array);
137: }
138:
139: /**
140: * Adds a single author.
141: * @param author
142: */
143: public void addAuthor(String author) {
144: XmpArray array = new XmpArray(XmpArray.ORDERED);
145: array.add(author);
146: setProperty(CREATOR, array);
147: }
148:
149: /**
150: * Adds an array of authors.
151: * @param author
152: */
153: public void addAuthor(String[] author) {
154: XmpArray array = new XmpArray(XmpArray.ORDERED);
155: for (int i = 0; i < author.length; i++) {
156: array.add(author[i]);
157: }
158: setProperty(CREATOR, array);
159: }
160:
161: /**
162: * Adds a single publisher.
163: * @param publisher
164: */
165: public void addPublisher(String publisher) {
166: XmpArray array = new XmpArray(XmpArray.ORDERED);
167: array.add(publisher);
168: setProperty(PUBLISHER, array);
169: }
170:
171: /**
172: * Adds an array of publishers.
173: * @param publisher
174: */
175: public void addPublisher(String[] publisher) {
176: XmpArray array = new XmpArray(XmpArray.ORDERED);
177: for (int i = 0; i < publisher.length; i++) {
178: array.add(publisher[i]);
179: }
180: setProperty(PUBLISHER, array);
181: }
182: }
|