001/* 002 * $Id: DublinCoreSchema.java 4784 2011-03-15 08:33:00Z blowagie $ 003 * 004 * This file is part of the iText (R) project. 005 * Copyright (c) 1998-2011 1T3XT BVBA 006 * Authors: Bruno Lowagie, Paulo Soares, et al. 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU Affero General Public License version 3 010 * as published by the Free Software Foundation with the addition of the 011 * following permission added to Section 15 as permitted in Section 7(a): 012 * FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY 1T3XT, 013 * 1T3XT DISCLAIMS THE WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. 014 * 015 * This program is distributed in the hope that it will be useful, but 016 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 017 * or FITNESS FOR A PARTICULAR PURPOSE. 018 * See the GNU Affero General Public License for more details. 019 * You should have received a copy of the GNU Affero General Public License 020 * along with this program; if not, see http://www.gnu.org/licenses or write to 021 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 022 * Boston, MA, 02110-1301 USA, or download the license from the following URL: 023 * http://itextpdf.com/terms-of-use/ 024 * 025 * The interactive user interfaces in modified source and object code versions 026 * of this program must display Appropriate Legal Notices, as required under 027 * Section 5 of the GNU Affero General Public License. 028 * 029 * In accordance with Section 7(b) of the GNU Affero General Public License, 030 * a covered work must retain the producer line in every PDF that is created 031 * or manipulated using iText. 032 * 033 * You can be released from the requirements of the license by purchasing 034 * a commercial license. Buying such a license is mandatory as soon as you 035 * develop commercial activities involving the iText software without 036 * disclosing the source code of your own applications. 037 * These activities include: offering paid services to customers as an ASP, 038 * serving PDFs on the fly in a web application, shipping iText with a closed 039 * source product. 040 * 041 * For more information, please contact iText Software Corp. at this 042 * address: sales@itextpdf.com 043 */ 044package com.itextpdf.text.xml.xmp; 045 046 047/** 048 * An implementation of an XmpSchema. 049 */ 050public class DublinCoreSchema extends XmpSchema { 051 052 private static final long serialVersionUID = -4551741356374797330L; 053 /** default namespace identifier*/ 054 public static final String DEFAULT_XPATH_ID = "dc"; 055 /** default namespace uri*/ 056 public static final String DEFAULT_XPATH_URI = "http://purl.org/dc/elements/1.1/"; 057 058 /** External Contributors to the resource (other than the authors). */ 059 public static final String CONTRIBUTOR = "dc:contributor"; 060 /** The extent or scope of the resource. */ 061 public static final String COVERAGE = "dc:coverage"; 062 /** The authors of the resource (listed in order of precedence, if significant). */ 063 public static final String CREATOR = "dc:creator"; 064 /** Date(s) that something interesting happened to the resource. */ 065 public static final String DATE = "dc:date"; 066 /** A textual description of the content of the resource. Multiple values may be present for different languages. */ 067 public static final String DESCRIPTION = "dc:description"; 068 /** 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. */ 069 public static final String FORMAT = "dc:format"; 070 /** Unique identifier of the resource. */ 071 public static final String IDENTIFIER = "dc:identifier"; 072 /** An unordered array specifying the languages used in the resource. */ 073 public static final String LANGUAGE = "dc:language"; 074 /** Publishers. */ 075 public static final String PUBLISHER = "dc:publisher"; 076 /** Relationships to other documents. */ 077 public static final String RELATION = "dc:relation"; 078 /** Informal rights statement, selected by language. */ 079 public static final String RIGHTS = "dc:rights"; 080 /** Unique identifier of the work from which this resource was derived. */ 081 public static final String SOURCE = "dc:source"; 082 /** An unordered array of descriptive phrases or keywords that specify the topic of the content of the resource. */ 083 public static final String SUBJECT = "dc:subject"; 084 /** 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. */ 085 public static final String TITLE = "dc:title"; 086 /** A document type; for example, novel, poem, or working paper. */ 087 public static final String TYPE = "dc:type"; 088 089 090 public DublinCoreSchema() { 091 super("xmlns:" + DEFAULT_XPATH_ID + "=\"" + DEFAULT_XPATH_URI + "\""); 092 setProperty(FORMAT, "application/pdf"); 093 } 094 095 /** 096 * Adds a title. 097 * @param title 098 */ 099 public void addTitle(String title) { 100 XmpArray array = new XmpArray(XmpArray.ALTERNATIVE); 101 array.add(title); 102 setProperty(TITLE, array); 103 } 104 105 /** 106 * Adds a description. 107 * @param desc 108 */ 109 public void addDescription(String desc) { 110 XmpArray array = new XmpArray(XmpArray.ALTERNATIVE); 111 array.add(desc); 112 setProperty(DESCRIPTION, array); 113 } 114 115 /** 116 * Adds a subject. 117 * @param subject 118 */ 119 public void addSubject(String subject) { 120 XmpArray array = new XmpArray(XmpArray.UNORDERED); 121 array.add(subject); 122 setProperty(SUBJECT, array); 123 } 124 125 126 /** 127 * Adds a subject. 128 * @param subject array of subjects 129 */ 130 public void addSubject(String[] subject) { 131 XmpArray array = new XmpArray(XmpArray.UNORDERED); 132 for (int i = 0; i < subject.length; i++) { 133 array.add(subject[i]); 134 } 135 setProperty(SUBJECT, array); 136 } 137 138 /** 139 * Adds a single author. 140 * @param author 141 */ 142 public void addAuthor(String author) { 143 XmpArray array = new XmpArray(XmpArray.ORDERED); 144 array.add(author); 145 setProperty(CREATOR, array); 146 } 147 148 /** 149 * Adds an array of authors. 150 * @param author 151 */ 152 public void addAuthor(String[] author) { 153 XmpArray array = new XmpArray(XmpArray.ORDERED); 154 for (int i = 0; i < author.length; i++) { 155 array.add(author[i]); 156 } 157 setProperty(CREATOR, array); 158 } 159 160 /** 161 * Adds a single publisher. 162 * @param publisher 163 */ 164 public void addPublisher(String publisher) { 165 XmpArray array = new XmpArray(XmpArray.ORDERED); 166 array.add(publisher); 167 setProperty(PUBLISHER, array); 168 } 169 170 /** 171 * Adds an array of publishers. 172 * @param publisher 173 */ 174 public void addPublisher(String[] publisher) { 175 XmpArray array = new XmpArray(XmpArray.ORDERED); 176 for (int i = 0; i < publisher.length; i++) { 177 array.add(publisher[i]); 178 } 179 setProperty(PUBLISHER, array); 180 } 181}