1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.jempbox.xmp; 18 19 import java.io.IOException; 20 import java.util.Calendar; 21 import java.util.List; 22 23 import org.w3c.dom.Element; 24 25 /** 26 * Define XMP properties used with the Dublin Core specification. 27 * 28 * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a> 29 * @version $Revision: 1.3 $ 30 */ 31 public class XMPSchemaDublinCore extends XMPSchema 32 { 33 /** 34 * The namespace for this schema. 35 */ 36 public static final String NAMESPACE = "http://purl.org/dc/elements/1.1/"; 37 /** 38 * Construct a new blank Dublin Core schema. 39 * 40 * @param parent The parent metadata schema that this will be part of. 41 */ 42 public XMPSchemaDublinCore( XMPMetadata parent ) 43 { 44 super( parent, "dc", NAMESPACE ); 45 } 46 47 /** 48 * Constructor from existing XML element. 49 * 50 * @param element The existing element. 51 * @param prefix The schema prefix. 52 */ 53 public XMPSchemaDublinCore( Element element, String prefix ) 54 { 55 super( element, prefix ); 56 } 57 58 /** 59 * Remove a contributor from the list of contributors. 60 * 61 * @param contributor The contributor to remove. 62 */ 63 public void removeContributor( String contributor ) 64 { 65 removeBagValue( prefix + ":contributor", contributor ); 66 } 67 68 /** 69 * Add a contributor to the list of contributors. A contributor is someone other than an author. 70 * 71 * @param contributor The name of the contributor. 72 */ 73 public void addContributor( String contributor ) 74 { 75 addBagValue( prefix + ":contributor", contributor ); 76 } 77 78 /** 79 * Get the complete list of contributors. 80 * 81 * @return The list of contributors. 82 */ 83 public List<String> getContributors() 84 { 85 return getBagList( prefix + ":contributor" ); 86 } 87 88 /** 89 * Set the coverage property. 90 * 91 * @param coverage The extend or scope of the resource. 92 */ 93 public void setCoverage( String coverage ) 94 { 95 setTextProperty( prefix + ":coverage", coverage ); 96 } 97 98 /** 99 * Get the coverage property. 100 * 101 * @return The extent or scope of the resource. 102 */ 103 public String getCoverage() 104 { 105 return getTextProperty( prefix + ":coverage" ); 106 } 107 108 /** 109 * Remove a creator from the list of creators. 110 * 111 * @param creator The author of the resource. 112 */ 113 public void removeCreator( String creator ) 114 { 115 removeSequenceValue( prefix + ":creator", creator ); 116 } 117 118 /** 119 * Add a creator. 120 * 121 * @param creator The author of the resource. 122 */ 123 public void addCreator( String creator ) 124 { 125 addSequenceValue( prefix + ":creator", creator ); 126 } 127 128 /** 129 * Get a complete list of creators. 130 * 131 * @return A list of java.lang.String objects. 132 */ 133 public List<String> getCreators() 134 { 135 return getSequenceList( prefix + ":creator" ); 136 } 137 138 /** 139 * Remove a date from the list of 'interesting' dates. 140 * 141 * @param date The date to remove. 142 */ 143 public void removeDate( Calendar date ) 144 { 145 removeSequenceDateValue( prefix + ":date", date ); 146 } 147 148 /** 149 * Add a date of interest to this schema. 150 * 151 * @param date The date to add to the schema. 152 */ 153 public void addDate( Calendar date ) 154 { 155 addSequenceDateValue( prefix + ":date", date ); 156 } 157 158 /** 159 * Get a list of all dates of interest to this resource. 160 * 161 * @return A list of java.util.Calendar objects. 162 * 163 * @throws IOException If there is an error creating the date object. 164 */ 165 public List<Calendar> getDates() throws IOException 166 { 167 return getSequenceDateList( prefix + ":date" ); 168 } 169 170 /** 171 * Set the default value for the description. 172 * 173 * @param description The description of this resource. 174 */ 175 public void setDescription( String description ) 176 { 177 setLanguageProperty( prefix + ":description", null, description ); 178 } 179 180 /** 181 * Get the default value for the description. 182 * 183 * @return The description of this resource. 184 */ 185 public String getDescription() 186 { 187 return getLanguageProperty( prefix + ":description", null ); 188 } 189 190 /** 191 * Set the description of this resource in a specific language. 192 * 193 * @param language The language code. 194 * @param description The description in a specific language. 195 */ 196 public void setDescription( String language, String description ) 197 { 198 setLanguageProperty( prefix + ":description", language, description ); 199 } 200 201 /** 202 * Get the description in a specific language. 203 * 204 * @param language The language code to get the description for. 205 * 206 * @return The description in the specified language or null if it does not exist. 207 */ 208 public String getDescription( String language ) 209 { 210 return getLanguageProperty( prefix + ":description", language ); 211 } 212 213 /** 214 * Get a list of all languages that a description exists for. 215 * 216 * @return A non-null list of languages, potentially an empty list. 217 */ 218 public List<String> getDescriptionLanguages() 219 { 220 return getLanguagePropertyLanguages( prefix + ":description" ); 221 } 222 223 /** 224 * Set the format property. 225 * 226 * @param format The mime-type of the saved resource. 227 */ 228 public void setFormat( String format ) 229 { 230 setTextProperty( prefix + ":format", format ); 231 } 232 233 /** 234 * Get the format property. 235 * 236 * @return The mime-type of the resource. 237 */ 238 public String getFormat() 239 { 240 return getTextProperty( prefix + ":format" ); 241 } 242 243 /** 244 * Set the resource identifier. 245 * 246 * @param id An id to the resource. 247 */ 248 public void setIdentifier( String id ) 249 { 250 setTextProperty( prefix + ":identifier", id ); 251 } 252 253 /** 254 * Get the resource id. 255 * 256 * @return A key that identifies this resource. 257 */ 258 public String getIdentifier() 259 { 260 return getTextProperty( prefix + ":identifier" ); 261 } 262 263 /** 264 * Remove a language from the list of languages. 265 * 266 * @param language The language to remove. 267 */ 268 public void removeLanguage( String language ) 269 { 270 removeBagValue( prefix + ":language", language ); 271 } 272 273 /** 274 * Add a language to the list of languages. 275 * 276 * @param language The name of the language. 277 */ 278 public void addLanguage( String language ) 279 { 280 addBagValue( prefix + ":language", language ); 281 } 282 283 /** 284 * Get the complete list of languages. 285 * 286 * @return The list of languages. 287 */ 288 public List<String> getLanguages() 289 { 290 return getBagList( prefix + ":language" ); 291 } 292 293 /** 294 * Remove a publisher from the list of publishers. 295 * 296 * @param publisher The publisher to remove. 297 */ 298 public void removePublisher( String publisher ) 299 { 300 removeBagValue( prefix + ":publisher", publisher ); 301 } 302 303 /** 304 * Add a publisher to the list of publishers. 305 * 306 * @param publisher The name of the publisher. 307 */ 308 public void addPublisher( String publisher ) 309 { 310 addBagValue( prefix + ":publisher", publisher ); 311 } 312 313 /** 314 * Get the complete list of publishers. 315 * 316 * @return The list of publishers. 317 */ 318 public List<String> getPublishers() 319 { 320 return getBagList( prefix + ":publisher" ); 321 } 322 323 /** 324 * Remove a relation from the list of relationships. 325 * A relationship to another resource. 326 * 327 * @param relation The publisher to remove. 328 */ 329 public void removeRelation( String relation ) 330 { 331 removeBagValue( prefix + ":relation", relation ); 332 } 333 334 /** 335 * Add a relation to the list of relationships. 336 * A relationship to another resource. 337 * 338 * @param relation The relation to the other resource. 339 */ 340 public void addRelation( String relation ) 341 { 342 addBagValue( prefix + ":relation", relation ); 343 } 344 345 /** 346 * Get the complete list of relationships. 347 * 348 * @return The list of relationships. 349 */ 350 public List<String> getRelationships() 351 { 352 return getBagList( prefix + ":relation" ); 353 } 354 355 /** 356 * Set the default value for the rights of this document. This property 357 * specifies informal rights of the document. 358 * 359 * @param rights The rights for this resource. 360 */ 361 public void setRights( String rights ) 362 { 363 setLanguageProperty( prefix + ":rights", null, rights ); 364 } 365 366 /** 367 * Get the default value for the rights of this document. 368 * 369 * @return The informal rights for this resource. 370 */ 371 public String getRights() 372 { 373 return getLanguageProperty( prefix + ":rights", null ); 374 } 375 376 /** 377 * Set the rights for this resource in a specific language. 378 * 379 * @param language The language code. 380 * @param rights The rights in a specific language. 381 */ 382 public void setRights( String language, String rights ) 383 { 384 setLanguageProperty( prefix + ":rights", language, rights ); 385 } 386 387 /** 388 * Get the rights in a specific language. 389 * 390 * @param language The language code to get the description for. 391 * 392 * @return The rights in the specified language or null if it does not exist. 393 */ 394 public String getRights( String language ) 395 { 396 return getLanguageProperty( prefix + ":rights", language ); 397 } 398 399 /** 400 * Get a list of all languages that a rights description exists for. 401 * 402 * @return A non-null list of languages, potentially an empty list. 403 */ 404 public List<String> getRightsLanguages() 405 { 406 return getLanguagePropertyLanguages( prefix + ":rights" ); 407 } 408 409 /** 410 * Set the resource source identifier. 411 * 412 * @param id An id to the resource source. 413 */ 414 public void setSource( String id ) 415 { 416 setTextProperty( prefix + ":source", id ); 417 } 418 419 /** 420 * Get the resource source id. 421 * 422 * @return A key that identifies this source of this resource. 423 */ 424 public String getSource() 425 { 426 return getTextProperty( prefix + ":source" ); 427 } 428 429 /** 430 * Remove a subject from the list of subjects. 431 * 432 * @param subject The subject to remove. 433 */ 434 public void removeSubject( String subject ) 435 { 436 removeBagValue( prefix + ":subject", subject ); 437 } 438 439 /** 440 * Add a subject to the list of subjects. 441 * 442 * @param subject The subject of this resource. 443 */ 444 public void addSubject( String subject ) 445 { 446 addBagValue( prefix + ":subject", subject ); 447 } 448 449 /** 450 * Get the complete list of subjects. 451 * 452 * @return The list of subjects. 453 */ 454 public List<String> getSubjects() 455 { 456 return getBagList( prefix + ":subject" ); 457 } 458 459 /** 460 * Set the default value for the title. 461 * 462 * @param title The title of this resource. 463 */ 464 public void setTitle( String title ) 465 { 466 setLanguageProperty( prefix + ":title", null, title ); 467 } 468 469 /** 470 * Get the default value for the title. 471 * 472 * @return The title of this resource. 473 */ 474 public String getTitle() 475 { 476 return getLanguageProperty( prefix + ":title", null ); 477 } 478 479 /** 480 * Set the title of this resource in a specific language. 481 * 482 * @param language The language code. 483 * @param title The title in a specific language. 484 */ 485 public void setTitle( String language, String title ) 486 { 487 setLanguageProperty( prefix + ":title", language, title ); 488 } 489 490 /** 491 * Get the title in a specific language. 492 * 493 * @param language The language code to get the description for. 494 * 495 * @return The title in the specified language or null if it does not exist. 496 */ 497 public String getTitle( String language ) 498 { 499 return getLanguageProperty( prefix + ":title", language ); 500 } 501 502 /** 503 * Get a list of all languages that a title exists for. 504 * 505 * @return A non-null list of languages, potentially an empty list. 506 */ 507 public List<String> getTitleLanguages() 508 { 509 return getLanguagePropertyLanguages( prefix + ":title" ); 510 } 511 512 /** 513 * Add a type to the bag of types of this resource. 514 * 515 * @param type The type of resource to add (poem, novel). 516 */ 517 public void addType( String type ) 518 { 519 addBagValue(prefix + ":type", type ); 520 } 521 522 /** 523 * Get the list of types for this resource. 524 * 525 * @return A list of types for this resource. 526 */ 527 public List<String> getTypes() 528 { 529 return getBagList(prefix + ":type" ); 530 } 531 }