1 // ================================================================================================= 2 // ADOBE SYSTEMS INCORPORATED 3 // Copyright 2006 Adobe Systems Incorporated 4 // All Rights Reserved 5 // 6 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms 7 // of the Adobe license agreement accompanying it. 8 // ================================================================================================= 9 10 package com.adobe.xmp; 11 12 import java.util.Calendar; 13 14 import com.adobe.xmp.options.IteratorOptions; 15 import com.adobe.xmp.options.ParseOptions; 16 import com.adobe.xmp.options.PropertyOptions; 17 import com.adobe.xmp.properties.XMPProperty; 18 19 20 /** 21 * This class represents the set of XMP metadata as a DOM representation. It has methods to read and 22 * modify all kinds of properties, create an iterator over all properties and serialize the metadata 23 * to a String, byte-array or <code>OutputStream</code>. 24 * 25 * @since 20.01.2006 26 */ 27 public interface XMPMeta extends Cloneable 28 { 29 // --------------------------------------------------------------------------------------------- 30 // Basic property manipulation functions 31 32 /** 33 * The property value getter-methods all take a property specification: the first two parameters 34 * are always the top level namespace URI (the "schema" namespace) and the basic name 35 * of the property being referenced. See the introductory discussion of path expression usage 36 * for more information. 37 * <p> 38 * All of the functions return an object inherited from <code>PropertyBase</code> or 39 * <code>null</code> if the property does not exists. The result object contains the value of 40 * the property and option flags describing the property. Arrays and the non-leaf levels of 41 * nodes do not have values. 42 * <p> 43 * See {@link PropertyOptions} for detailed information about the options. 44 * <p> 45 * This is the simplest property getter, mainly for top level simple properties or after using 46 * the path composition functions in XMPPathFactory. 47 * 48 * @param schemaNS The namespace URI for the property. May be <code>null</code> or the empty 49 * string if the first component of the propName path contains a namespace prefix. The 50 * URI must be for a registered namespace. 51 * @param propName The name of the property. May be a general path expression, must not be 52 * <code>null</code> or the empty string. Using a namespace prefix on the first 53 * component is optional. If present without a schemaNS value then the prefix specifies 54 * the namespace. The prefix must be for a registered namespace. If both a schemaNS URI 55 * and propName prefix are present, they must be corresponding parts of a registered 56 * namespace. 57 * @return Returns a <code>XMPProperty</code> containing the value and the options or 58 * <code>null</code> if the property does not exist. 59 * @throws XMPException Wraps all errors and exceptions that may occur. 60 */ 61 XMPProperty getProperty(String schemaNS, String propName) throws XMPException; 62 63 64 /** 65 * Provides access to items within an array. The index is passed as an integer, you need not 66 * worry about the path string syntax for array items, convert a loop index to a string, etc. 67 * 68 * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. 69 * @param arrayName The name of the array. May be a general path expression, must not be 70 * <code>null</code> or the empty string. Has the same namespace prefix usage as 71 * propName in <code>getProperty()</code>. 72 * @param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. The 73 * constant {@link XMPConst#ARRAY_LAST_ITEM} always refers to the last existing array 74 * item. 75 * @return Returns a <code>XMPProperty</code> containing the value and the options or 76 * <code>null</code> if the property does not exist. 77 * @throws XMPException Wraps all errors and exceptions that may occur. 78 */ 79 XMPProperty getArrayItem(String schemaNS, String arrayName, int itemIndex) throws XMPException; 80 81 82 /** 83 * Returns the number of items in the array. 84 * 85 * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. 86 * @param arrayName The name of the array. May be a general path expression, must not be 87 * <code>null</code> or the empty string. Has the same namespace prefix usage as 88 * propName in <code>getProperty()</code>. 89 * @return Returns the number of items in the array. 90 * @throws XMPException Wraps all errors and exceptions that may occur. 91 */ 92 int countArrayItems(String schemaNS, String arrayName) throws XMPException; 93 94 95 /** 96 * Provides access to fields within a nested structure. The namespace for the field is passed as 97 * a URI, you need not worry about the path string syntax. 98 * <p> 99 * The names of fields should be XML qualified names, that is within an XML namespace. The path 100 * syntax for a qualified name uses the namespace prefix. This is unreliable since the prefix is 101 * never guaranteed. The URI is the formal name, the prefix is just a local shorthand in a given 102 * sequence of XML text. 103 * 104 * @param schemaNS The namespace URI for the struct. Has the same usage as in getProperty. 105 * @param structName The name of the struct. May be a general path expression, must not be 106 * <code>null</code> or the empty string. Has the same namespace prefix usage as 107 * propName in <code>getProperty()</code>. 108 * @param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the 109 * schemaNS parameter. 110 * @param fieldName The name of the field. Must be a single XML name, must not be 111 * <code>null</code> or the empty string. Has the same namespace prefix usage as the 112 * structName parameter. 113 * @return Returns a <code>XMPProperty</code> containing the value and the options or 114 * <code>null</code> if the property does not exist. Arrays and non-leaf levels of 115 * structs do not have values. 116 * @throws XMPException Wraps all errors and exceptions that may occur. 117 */ 118 XMPProperty getStructField( 119 String schemaNS, 120 String structName, 121 String fieldNS, 122 String fieldName) throws XMPException; 123 124 125 /** 126 * Provides access to a qualifier attached to a property. The namespace for the qualifier is 127 * passed as a URI, you need not worry about the path string syntax. In many regards qualifiers 128 * are like struct fields. See the introductory discussion of qualified properties for more 129 * information. 130 * <p> 131 * The names of qualifiers should be XML qualified names, that is within an XML namespace. The 132 * path syntax for a qualified name uses the namespace prefix. This is unreliable since the 133 * prefix is never guaranteed. The URI is the formal name, the prefix is just a local shorthand 134 * in a given sequence of XML text. 135 * <p> 136 * <em>Note:</em> Qualifiers are only supported for simple leaf properties at this time. 137 * 138 * @param schemaNS The namespace URI for the struct. Has the same usage as in getProperty. 139 * @param propName The name of the property to which the qualifier is attached. May be a general 140 * path expression, must not be <code>null</code> or the empty string. Has the same 141 * namespace prefix usage as in <code>getProperty()</code>. 142 * @param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the 143 * schemaNS parameter. 144 * @param qualName The name of the qualifier. Must be a single XML name, must not be 145 * <code>null</code> or the empty string. Has the same namespace prefix usage as the 146 * propName parameter. 147 * @return Returns a <code>XMPProperty</code> containing the value and the options of the 148 * qualifier or <code>null</code> if the property does not exist. The name of the 149 * qualifier must be a single XML name, must not be <code>null</code> or the empty 150 * string. Has the same namespace prefix usage as the propName parameter. 151 * <p> 152 * The value of the qualifier is only set if it has one (Arrays and non-leaf levels of 153 * structs do not have values). 154 * @throws XMPException Wraps all errors and exceptions that may occur. 155 */ 156 XMPProperty getQualifier( 157 String schemaNS, 158 String propName, 159 String qualNS, 160 String qualName) throws XMPException; 161 162 163 164 // --------------------------------------------------------------------------------------------- 165 // Functions for setting property values 166 167 /** 168 * The property value <code>setters</code> all take a property specification, their 169 * differences are in the form of this. The first two parameters are always the top level 170 * namespace URI (the <code>schema</code> namespace) and the basic name of the property being 171 * referenced. See the introductory discussion of path expression usage for more information. 172 * <p> 173 * All of the functions take a string value for the property and option flags describing the 174 * property. The value must be Unicode in UTF-8 encoding. Arrays and non-leaf levels of structs 175 * do not have values. Empty arrays and structs may be created using appropriate option flags. 176 * All levels of structs that is assigned implicitly are created if necessary. appendArayItem 177 * implicitly creates the named array if necessary. 178 * <p> 179 * See {@link PropertyOptions} for detailed information about the options. 180 * <p> 181 * This is the simplest property setter, mainly for top level simple properties or after using 182 * the path composition functions in {@link XMPPathFactory}. 183 * 184 * @param schemaNS The namespace URI for the property. Has the same usage as in getProperty. 185 * @param propName The name of the property. 186 * Has the same usage as in <code>getProperty()</code>. 187 * @param propValue the value for the property (only leaf properties have a value). 188 * Arrays and non-leaf levels of structs do not have values. 189 * Must be <code>null</code> if the value is not relevant.<br/> 190 * The value is automatically detected: Boolean, Integer, Long, Double, XMPDateTime and 191 * byte[] are handled, on all other <code>toString()</code> is called. 192 * 193 * @param options Option flags describing the property. See the earlier description. 194 * @throws XMPException Wraps all errors and exceptions that may occur. 195 */ 196 void setProperty( 197 String schemaNS, 198 String propName, 199 Object propValue, 200 PropertyOptions options) throws XMPException; 201 202 203 /** 204 * @see XMPMeta#setProperty(String, String, Object, PropertyOptions) 205 * 206 * @param schemaNS The namespace URI 207 * @param propName The name of the property 208 * @param propValue the value for the property 209 * @throws XMPException Wraps all errors and exceptions 210 */ 211 void setProperty( 212 String schemaNS, 213 String propName, 214 Object propValue) throws XMPException; 215 216 217 /** 218 * Replaces an item within an array. The index is passed as an integer, you need not worry about 219 * the path string syntax for array items, convert a loop index to a string, etc. The array 220 * passed must already exist. In normal usage the selected array item is modified. A new item is 221 * automatically appended if the index is the array size plus 1. 222 * 223 * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. 224 * @param arrayName The name of the array. May be a general path expression, must not be 225 * <code>null</code> or the empty string. Has the same namespace prefix usage as 226 * propName in getProperty. 227 * @param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. To address 228 * the last existing item, use {@link XMPMeta#countArrayItems(String, String)} to find 229 * out the length of the array. 230 * @param itemValue the new value of the array item. Has the same usage as propValue in 231 * <code>setProperty()</code>. 232 * @param options the set options for the item. 233 * @throws XMPException Wraps all errors and exceptions that may occur. 234 */ 235 void setArrayItem( 236 String schemaNS, 237 String arrayName, 238 int itemIndex, 239 String itemValue, 240 PropertyOptions options) throws XMPException; 241 242 243 /** 244 * @see XMPMeta#setArrayItem(String, String, int, String, PropertyOptions) 245 * 246 * @param schemaNS The namespace URI 247 * @param arrayName The name of the array 248 * @param itemIndex The index to insert the new item 249 * @param itemValue the new value of the array item 250 * @throws XMPException Wraps all errors and exceptions 251 */ 252 void setArrayItem( 253 String schemaNS, 254 String arrayName, 255 int itemIndex, 256 String itemValue) throws XMPException; 257 258 259 /** 260 * Inserts an item into an array previous to the given index. The index is passed as an integer, 261 * you need not worry about the path string syntax for array items, convert a loop index to a 262 * string, etc. The array passed must already exist. In normal usage the selected array item is 263 * modified. A new item is automatically appended if the index is the array size plus 1. 264 * 265 * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. 266 * @param arrayName The name of the array. May be a general path expression, must not be 267 * <code>null</code> or the empty string. Has the same namespace prefix usage as 268 * propName in getProperty. 269 * @param itemIndex The index to insert the new item. Arrays in XMP are indexed from 1. Use 270 * <code>XMPConst.ARRAY_LAST_ITEM</code> to append items. 271 * @param itemValue the new value of the array item. Has the same usage as 272 * propValue in <code>setProperty()</code>. 273 * @param options the set options that decide about the kind of the node. 274 * @throws XMPException Wraps all errors and exceptions that may occur. 275 */ 276 void insertArrayItem( 277 String schemaNS, 278 String arrayName, 279 int itemIndex, 280 String itemValue, 281 PropertyOptions options) throws XMPException; 282 283 284 /** 285 * @see XMPMeta#insertArrayItem(String, String, int, String, PropertyOptions) 286 * 287 * @param schemaNS The namespace URI for the array 288 * @param arrayName The name of the array 289 * @param itemIndex The index to insert the new item 290 * @param itemValue the value of the array item 291 * @throws XMPException Wraps all errors and exceptions 292 */ 293 void insertArrayItem( 294 String schemaNS, 295 String arrayName, 296 int itemIndex, 297 String itemValue) throws XMPException; 298 299 300 /** 301 * Simplifies the construction of an array by not requiring that you pre-create an empty array. 302 * The array that is assigned is created automatically if it does not yet exist. Each call to 303 * appendArrayItem() appends an item to the array. The corresponding parameters have the same 304 * use as setArrayItem(). The arrayOptions parameter is used to specify what kind of array. If 305 * the array exists, it must have the specified form. 306 * 307 * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. 308 * @param arrayName The name of the array. May be a general path expression, must not be null or 309 * the empty string. Has the same namespace prefix usage as propPath in getProperty. 310 * @param arrayOptions Option flags describing the array form. The only valid options are 311 * <ul> 312 * <li> {@link PropertyOptions#ARRAY}, 313 * <li> {@link PropertyOptions#ARRAY_ORDERED}, 314 * <li> {@link PropertyOptions#ARRAY_ALTERNATE} or 315 * <li> {@link PropertyOptions#ARRAY_ALT_TEXT}. 316 * </ul> 317 * <em>Note:</em> the array options only need to be provided if the array is not 318 * already existing, otherwise you can set them to <code>null</code> or use 319 * {@link XMPMeta#appendArrayItem(String, String, String)}. 320 * @param itemValue the value of the array item. Has the same usage as propValue in getProperty. 321 * @param itemOptions Option flags describing the item to append ({@link PropertyOptions}) 322 * @throws XMPException Wraps all errors and exceptions that may occur. 323 */ 324 void appendArrayItem( 325 String schemaNS, 326 String arrayName, 327 PropertyOptions arrayOptions, 328 String itemValue, 329 PropertyOptions itemOptions) throws XMPException; 330 331 332 /** 333 * @see XMPMeta#appendArrayItem(String, String, PropertyOptions, String, PropertyOptions) 334 * 335 * @param schemaNS The namespace URI for the array 336 * @param arrayName The name of the array 337 * @param itemValue the value of the array item 338 * @throws XMPException Wraps all errors and exceptions 339 */ 340 void appendArrayItem( 341 String schemaNS, 342 String arrayName, 343 String itemValue) throws XMPException; 344 345 346 /** 347 * Provides access to fields within a nested structure. The namespace for the field is passed as 348 * a URI, you need not worry about the path string syntax. The names of fields should be XML 349 * qualified names, that is within an XML namespace. The path syntax for a qualified name uses 350 * the namespace prefix, which is unreliable because the prefix is never guaranteed. The URI is 351 * the formal name, the prefix is just a local shorthand in a given sequence of XML text. 352 * 353 * @param schemaNS The namespace URI for the struct. Has the same usage as in getProperty. 354 * @param structName The name of the struct. May be a general path expression, must not be null 355 * or the empty string. Has the same namespace prefix usage as propName in getProperty. 356 * @param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the 357 * schemaNS parameter. 358 * @param fieldName The name of the field. Must be a single XML name, must not be null or the 359 * empty string. Has the same namespace prefix usage as the structName parameter. 360 * @param fieldValue the value of thefield, if the field has a value. 361 * Has the same usage as propValue in getProperty. 362 * @param options Option flags describing the field. See the earlier description. 363 * @throws XMPException Wraps all errors and exceptions that may occur. 364 */ 365 void setStructField( 366 String schemaNS, 367 String structName, 368 String fieldNS, 369 String fieldName, 370 String fieldValue, 371 PropertyOptions options) throws XMPException; 372 373 374 /** 375 * @see XMPMeta#setStructField(String, String, String, String, String, PropertyOptions) 376 * 377 * @param schemaNS The namespace URI for the struct 378 * @param structName The name of the struct 379 * @param fieldNS The namespace URI for the field 380 * @param fieldName The name of the field 381 * @param fieldValue the value of the field 382 * @throws XMPException Wraps all errors and exceptions 383 */ 384 void setStructField( 385 String schemaNS, 386 String structName, 387 String fieldNS, 388 String fieldName, 389 String fieldValue) throws XMPException; 390 391 392 /** 393 * Provides access to a qualifier attached to a property. The namespace for the qualifier is 394 * passed as a URI, you need not worry about the path string syntax. In many regards qualifiers 395 * are like struct fields. See the introductory discussion of qualified properties for more 396 * information. The names of qualifiers should be XML qualified names, that is within an XML 397 * namespace. The path syntax for a qualified name uses the namespace prefix, which is 398 * unreliable because the prefix is never guaranteed. The URI is the formal name, the prefix is 399 * just a local shorthand in a given sequence of XML text. The property the qualifier 400 * will be attached has to exist. 401 * 402 * @param schemaNS The namespace URI for the struct. Has the same usage as in getProperty. 403 * @param propName The name of the property to which the qualifier is attached. Has the same 404 * usage as in getProperty. 405 * @param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the 406 * schemaNS parameter. 407 * @param qualName The name of the qualifier. Must be a single XML name, must not be 408 * <code>null</code> or the empty string. Has the same namespace prefix usage as the 409 * propName parameter. 410 * @param qualValue A pointer to the <code>null</code> terminated UTF-8 string that is the 411 * value of the qualifier, if the qualifier has a value. Has the same usage as propValue 412 * in getProperty. 413 * @param options Option flags describing the qualifier. See the earlier description. 414 * @throws XMPException Wraps all errors and exceptions that may occur. 415 */ 416 void setQualifier( 417 String schemaNS, 418 String propName, 419 String qualNS, 420 String qualName, 421 String qualValue, 422 PropertyOptions options) throws XMPException; 423 424 425 /** 426 * @see XMPMeta#setQualifier(String, String, String, String, String, PropertyOptions) 427 * 428 * @param schemaNS The namespace URI for the struct 429 * @param propName The name of the property to which the qualifier is attached 430 * @param qualNS The namespace URI for the qualifier 431 * @param qualName The name of the qualifier 432 * @param qualValue the value of the qualifier 433 * @throws XMPException Wraps all errors and exceptions 434 */ 435 void setQualifier( 436 String schemaNS, 437 String propName, 438 String qualNS, 439 String qualName, 440 String qualValue) throws XMPException; 441 442 443 444 // --------------------------------------------------------------------------------------------- 445 // Functions for deleting and detecting properties. These should be obvious from the 446 // descriptions of the getters and setters. 447 448 /** 449 * Deletes the given XMP subtree rooted at the given property. It is not an error if the 450 * property does not exist. 451 * 452 * @param schemaNS The namespace URI for the property. Has the same usage as in 453 * <code>getProperty()</code>. 454 * @param propName The name of the property. Has the same usage as in getProperty. 455 */ 456 void deleteProperty(String schemaNS, String propName); 457 458 459 /** 460 * Deletes the given XMP subtree rooted at the given array item. It is not an error if the array 461 * item does not exist. 462 * 463 * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. 464 * @param arrayName The name of the array. May be a general path expression, must not be 465 * <code>null</code> or the empty string. Has the same namespace prefix usage as 466 * propName in <code>getProperty()</code>. 467 * @param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. The 468 * constant <code>XMPConst.ARRAY_LAST_ITEM</code> always refers to the last 469 * existing array item. 470 */ 471 void deleteArrayItem(String schemaNS, String arrayName, int itemIndex); 472 473 474 /** 475 * Deletes the given XMP subtree rooted at the given struct field. It is not an error if the 476 * field does not exist. 477 * 478 * @param schemaNS The namespace URI for the struct. Has the same usage as in 479 * <code>getProperty()</code>. 480 * @param structName The name of the struct. May be a general path expression, must not be 481 * <code>null</code> or the empty string. Has the same namespace prefix usage as 482 * propName in getProperty. 483 * @param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the 484 * schemaNS parameter. 485 * @param fieldName The name of the field. Must be a single XML name, must not be 486 * <code>null</code> or the empty string. Has the same namespace prefix usage as the 487 * structName parameter. 488 */ 489 void deleteStructField(String schemaNS, String structName, String fieldNS, String fieldName); 490 491 492 /** 493 * Deletes the given XMP subtree rooted at the given qualifier. It is not an error if the 494 * qualifier does not exist. 495 * 496 * @param schemaNS The namespace URI for the struct. Has the same usage as in 497 * <code>getProperty()</code>. 498 * @param propName The name of the property to which the qualifier is attached. Has the same 499 * usage as in getProperty. 500 * @param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the 501 * schemaNS parameter. 502 * @param qualName The name of the qualifier. Must be a single XML name, must not be 503 * <code>null</code> or the empty string. Has the same namespace prefix usage as the 504 * propName parameter. 505 */ 506 void deleteQualifier(String schemaNS, String propName, String qualNS, String qualName); 507 508 509 /** 510 * Returns whether the property exists. 511 * 512 * @param schemaNS The namespace URI for the property. Has the same usage as in 513 * <code>getProperty()</code>. 514 * @param propName The name of the property. 515 * Has the same usage as in <code>getProperty()</code>. 516 * @return Returns true if the property exists. 517 */ 518 boolean doesPropertyExist(String schemaNS, String propName); 519 520 521 /** 522 * Tells if the array item exists. 523 * 524 * @param schemaNS The namespace URI for the array. Has the same usage as in 525 * <code>getProperty()</code>. 526 * @param arrayName The name of the array. May be a general path expression, must not be 527 * <code>null</code> or the empty string. Has the same namespace prefix usage as 528 * propName in <code>getProperty()</code>. 529 * @param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. The 530 * constant <code>XMPConst.ARRAY_LAST_ITEM</code> always refers to the last 531 * existing array item. 532 * @return Returns <code>true</code> if the array exists, <code>false</code> otherwise. 533 */ 534 boolean doesArrayItemExist(String schemaNS, String arrayName, int itemIndex); 535 536 537 /** 538 * DoesStructFieldExist tells if the struct field exists. 539 * 540 * @param schemaNS The namespace URI for the struct. Has the same usage as in 541 * <code>getProperty()</code>. 542 * @param structName The name of the struct. May be a general path expression, must not be 543 * <code>null</code> or the empty string. Has the same namespace prefix usage as 544 * propName in <code>getProperty()</code>. 545 * @param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the 546 * schemaNS parameter. 547 * @param fieldName The name of the field. Must be a single XML name, must not be 548 * <code>null</code> or the empty string. Has the same namespace prefix usage as the 549 * structName parameter. 550 * @return Returns true if the field exists. 551 */ 552 boolean doesStructFieldExist( 553 String schemaNS, 554 String structName, 555 String fieldNS, 556 String fieldName); 557 558 559 /** 560 * DoesQualifierExist tells if the qualifier exists. 561 * 562 * @param schemaNS The namespace URI for the struct. Has the same usage as in 563 * <code>getProperty()</code>. 564 * @param propName The name of the property to which the qualifier is attached. Has the same 565 * usage as in <code>getProperty()</code>. 566 * @param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the 567 * schemaNS parameter. 568 * @param qualName The name of the qualifier. Must be a single XML name, must not be 569 * <code>null</code> or the empty string. Has the same namespace prefix usage as the 570 * propName parameter. 571 * @return Returns true if the qualifier exists. 572 */ 573 boolean doesQualifierExist(String schemaNS, String propName, String qualNS, String qualName); 574 575 576 // --------------------------------------------------------------------------------------------- 577 // Specialized Get and Set functions 578 579 /** 580 * These functions provide convenient support for localized text properties, including a number 581 * of special and obscure aspects. Localized text properties are stored in alt-text arrays. They 582 * allow multiple concurrent localizations of a property value, for example a document title or 583 * copyright in several languages. The most important aspect of these functions is that they 584 * select an appropriate array item based on one or two RFC 3066 language tags. One of these 585 * languages, the "specific" language, is preferred and selected if there is an exact match. For 586 * many languages it is also possible to define a "generic" language that may be used if there 587 * is no specific language match. The generic language must be a valid RFC 3066 primary subtag, 588 * or the empty string. For example, a specific language of "en-US" should be used in the US, 589 * and a specific language of "en-UK" should be used in England. It is also appropriate to use 590 * "en" as the generic language in each case. If a US document goes to England, the "en-US" 591 * title is selected by using the "en" generic language and the "en-UK" specific language. It is 592 * considered poor practice, but allowed, to pass a specific language that is just an RFC 3066 593 * primary tag. For example "en" is not a good specific language, it should only be used as a 594 * generic language. Passing "i" or "x" as the generic language is also considered poor practice 595 * but allowed. Advice from the W3C about the use of RFC 3066 language tags can be found at: 596 * http://www.w3.org/International/articles/language-tags/ 597 * <p> 598 * <em>Note:</em> RFC 3066 language tags must be treated in a case insensitive manner. The XMP 599 * Toolkit does this by normalizing their capitalization: 600 * <ul> 601 * <li> The primary subtag is lower case, the suggested practice of ISO 639. 602 * <li> All 2 letter secondary subtags are upper case, the suggested practice of ISO 3166. 603 * <li> All other subtags are lower case. The XMP specification defines an artificial language, 604 * <li>"x-default", that is used to explicitly denote a default item in an alt-text array. 605 * </ul> 606 * The XMP toolkit normalizes alt-text arrays such that the x-default item is the first item. 607 * The SetLocalizedText function has several special features related to the x-default item, see 608 * its description for details. The selection of the array item is the same for GetLocalizedText 609 * and SetLocalizedText: 610 * <ul> 611 * <li> Look for an exact match with the specific language. 612 * <li> If a generic language is given, look for a partial match. 613 * <li> Look for an x-default item. 614 * <li> Choose the first item. 615 * </ul> 616 * A partial match with the generic language is where the start of the item's language matches 617 * the generic string and the next character is '-'. An exact match is also recognized as a 618 * degenerate case. It is fine to pass x-default as the specific language. In this case, 619 * selection of an x-default item is an exact match by the first rule, not a selection by the 620 * 3rd rule. The last 2 rules are fallbacks used when the specific and generic languages fail to 621 * produce a match. <code>getLocalizedText</code> returns information about a selected item in 622 * an alt-text array. The array item is selected according to the rules given above. 623 * 624 * <em>Note:</em> In a future version of this API a method 625 * using Java <code>java.lang.Locale</code> will be added. 626 * 627 * @param schemaNS The namespace URI for the alt-text array. Has the same usage as in 628 * <code>getProperty()</code>. 629 * @param altTextName The name of the alt-text array. May be a general path expression, must not 630 * be <code>null</code> or the empty string. Has the same namespace prefix usage as 631 * propName in <code>getProperty()</code>. 632 * @param genericLang The name of the generic language as an RFC 3066 primary subtag. May be 633 * <code>null</code> or the empty string if no generic language is wanted. 634 * @param specificLang The name of the specific language as an RFC 3066 tag. Must not be 635 * <code>null</code> or the empty string. 636 * @return Returns an <code>XMPProperty</code> containing the value, the actual language and 637 * the options if an appropriate alternate collection item exists, <code>null</code> 638 * if the property. 639 * does not exist. 640 * @throws XMPException Wraps all errors and exceptions that may occur. 641 */ 642 XMPProperty getLocalizedText( 643 String schemaNS, 644 String altTextName, 645 String genericLang, 646 String specificLang) throws XMPException; 647 648 649 /** 650 * Modifies the value of a selected item in an alt-text array. Creates an appropriate array item 651 * if necessary, and handles special cases for the x-default item. If the selected item is from 652 * a match with the specific language, the value of that item is modified. If the existing value 653 * of that item matches the existing value of the x-default item, the x-default item is also 654 * modified. If the array only has 1 existing item (which is not x-default), an x-default item 655 * is added with the given value. If the selected item is from a match with the generic language 656 * and there are no other generic matches, the value of that item is modified. If the existing 657 * value of that item matches the existing value of the x-default item, the x-default item is 658 * also modified. If the array only has 1 existing item (which is not x-default), an x-default 659 * item is added with the given value. If the selected item is from a partial match with the 660 * generic language and there are other partial matches, a new item is created for the specific 661 * language. The x-default item is not modified. If the selected item is from the last 2 rules 662 * then a new item is created for the specific language. If the array only had an x-default 663 * item, the x-default item is also modified. If the array was empty, items are created for the 664 * specific language and x-default. 665 * 666 * <em>Note:</em> In a future version of this API a method 667 * using Java <code>java.lang.Locale</code> will be added. 668 * 669 * 670 * @param schemaNS The namespace URI for the alt-text array. Has the same usage as in 671 * <code>getProperty()</code>. 672 * @param altTextName The name of the alt-text array. May be a general path expression, must not 673 * be <code>null</code> or the empty string. Has the same namespace prefix usage as 674 * propName in <code>getProperty()</code>. 675 * @param genericLang The name of the generic language as an RFC 3066 primary subtag. May be 676 * <code>null</code> or the empty string if no generic language is wanted. 677 * @param specificLang The name of the specific language as an RFC 3066 tag. Must not be 678 * <code>null</code> or the empty string. 679 * @param itemValue A pointer to the <code>null</code> terminated UTF-8 string that is the new 680 * value for the appropriate array item. 681 * @param options Option flags, none are defined at present. 682 * @throws XMPException Wraps all errors and exceptions that may occur. 683 */ 684 void setLocalizedText( 685 String schemaNS, 686 String altTextName, 687 String genericLang, 688 String specificLang, 689 String itemValue, 690 PropertyOptions options) throws XMPException; 691 692 693 /** 694 * @see XMPMeta#setLocalizedText(String, String, String, String, String, PropertyOptions) 695 * 696 * @param schemaNS The namespace URI for the alt-text array 697 * @param altTextName The name of the alt-text array 698 * @param genericLang The name of the generic language 699 * @param specificLang The name of the specific language 700 * @param itemValue the new value for the appropriate array item 701 * @throws XMPException Wraps all errors and exceptions 702 */ 703 void setLocalizedText( 704 String schemaNS, 705 String altTextName, 706 String genericLang, 707 String specificLang, 708 String itemValue) throws XMPException; 709 710 711 712 // --------------------------------------------------------------------------------------------- 713 // Functions accessing properties as binary values. 714 715 716 /** 717 * These are very similar to <code>getProperty()</code> and <code>SetProperty()</code> above, 718 * but the value is returned or provided in a literal form instead of as a UTF-8 string. 719 * The path composition functions in <code>XMPPathFactory</code> may be used to compose an path 720 * expression for fields in nested structures, items in arrays, or qualifiers. 721 * 722 * @param schemaNS The namespace URI for the property. Has the same usage as in 723 * <code>getProperty()</code>. 724 * @param propName The name of the property. 725 * Has the same usage as in <code>getProperty()</code>. 726 * @return Returns a <code>Boolean</code> value or <code>null</code> 727 * if the property does not exist. 728 * @throws XMPException Wraps all exceptions that may occur, 729 * especially conversion errors. 730 */ 731 Boolean getPropertyBoolean(String schemaNS, String propName) throws XMPException; 732 733 734 /** 735 * Convenience method to retrieve the literal value of a property. 736 * 737 * @param schemaNS The namespace URI for the property. Has the same usage as in 738 * <code>getProperty()</code>. 739 * @param propName The name of the property. 740 * Has the same usage as in <code>getProperty()</code>. 741 * @return Returns an <code>Integer</code> value or <code>null</code> 742 * if the property does not exist. 743 * @throws XMPException Wraps all exceptions that may occur, 744 * especially conversion errors. 745 */ 746 Integer getPropertyInteger(String schemaNS, String propName) throws XMPException; 747 748 749 /** 750 * Convenience method to retrieve the literal value of a property. 751 * 752 * @param schemaNS The namespace URI for the property. Has the same usage as in 753 * <code>getProperty()</code>. 754 * @param propName The name of the property. 755 * Has the same usage as in <code>getProperty()</code>. 756 * @return Returns a <code>Long</code> value or <code>null</code> 757 * if the property does not exist. 758 * @throws XMPException Wraps all exceptions that may occur, 759 * especially conversion errors. 760 */ 761 Long getPropertyLong(String schemaNS, String propName) throws XMPException; 762 763 764 /** 765 * Convenience method to retrieve the literal value of a property. 766 * 767 * @param schemaNS The namespace URI for the property. Has the same usage as in 768 * <code>getProperty()</code>. 769 * @param propName The name of the property. 770 * Has the same usage as in <code>getProperty()</code>. 771 * @return Returns a <code>Double</code> value or <code>null</code> 772 * if the property does not exist. 773 * @throws XMPException Wraps all exceptions that may occur, 774 * especially conversion errors. 775 */ 776 Double getPropertyDouble(String schemaNS, String propName) throws XMPException; 777 778 779 /** 780 * Convenience method to retrieve the literal value of a property. 781 * 782 * @param schemaNS The namespace URI for the property. Has the same usage as in 783 * <code>getProperty()</code>. 784 * @param propName The name of the property. 785 * Has the same usage as in <code>getProperty()</code>. 786 * @return Returns a <code>XMPDateTime</code>-object or <code>null</code> 787 * if the property does not exist. 788 * @throws XMPException Wraps all exceptions that may occur, 789 * especially conversion errors. 790 */ 791 XMPDateTime getPropertyDate(String schemaNS, String propName) throws XMPException; 792 793 794 /** 795 * Convenience method to retrieve the literal value of a property. 796 * 797 * @param schemaNS The namespace URI for the property. Has the same usage as in 798 * <code>getProperty()</code>. 799 * @param propName The name of the property. 800 * Has the same usage as in <code>getProperty()</code>. 801 * @return Returns a Java <code>Calendar</code>-object or <code>null</code> 802 * if the property does not exist. 803 * @throws XMPException Wraps all exceptions that may occur, 804 * especially conversion errors. 805 */ 806 Calendar getPropertyCalendar(String schemaNS, String propName) throws XMPException; 807 808 809 /** 810 * Convenience method to retrieve the literal value of a property. 811 * 812 * @param schemaNS The namespace URI for the property. Has the same usage as in 813 * <code>getProperty()</code>. 814 * @param propName The name of the property. 815 * Has the same usage as in <code>getProperty()</code>. 816 * @return Returns a <code>byte[]</code>-array contained the decoded base64 value 817 * or <code>null</code> if the property does not exist. 818 * @throws XMPException Wraps all exceptions that may occur, 819 * especially conversion errors. 820 */ 821 byte[] getPropertyBase64(String schemaNS, String propName) throws XMPException; 822 823 824 /** 825 * Convenience method to retrieve the literal value of a property. 826 * <em>Note:</em> There is no <code>setPropertyString()</code>, 827 * because <code>setProperty()</code> sets a string value. 828 * 829 * @param schemaNS The namespace URI for the property. Has the same usage as in 830 * <code>getProperty()</code>. 831 * @param propName The name of the property. 832 * Has the same usage as in <code>getProperty()</code>. 833 * @return Returns a <code>String</code> value or <code>null</code> 834 * if the property does not exist. 835 * @throws XMPException Wraps all exceptions that may occur, 836 * especially conversion errors. 837 */ 838 String getPropertyString(String schemaNS, String propName) throws XMPException; 839 840 841 /** 842 * Convenience method to set a property to a literal <code>boolean</code> value. 843 * 844 * @param schemaNS The namespace URI for the property. Has the same usage as in 845 * <code>setProperty()</code>. 846 * @param propName The name of the property. 847 * Has the same usage as in <code>getProperty()</code>. 848 * @param propValue the literal property value as <code>boolean</code>. 849 * @param options options of the property to set (optional). 850 * @throws XMPException Wraps all exceptions that may occur. 851 */ 852 void setPropertyBoolean( 853 String schemaNS, 854 String propName, 855 boolean propValue, 856 PropertyOptions options) throws XMPException; 857 858 859 /** 860 * @see XMPMeta#setPropertyBoolean(String, String, boolean, PropertyOptions) 861 * 862 * @param schemaNS The namespace URI for the property 863 * @param propName The name of the property 864 * @param propValue the literal property value as <code>boolean</code> 865 * @throws XMPException Wraps all exceptions 866 */ 867 void setPropertyBoolean( 868 String schemaNS, 869 String propName, 870 boolean propValue) throws XMPException; 871 872 873 /** 874 * Convenience method to set a property to a literal <code>int</code> value. 875 * 876 * @param schemaNS The namespace URI for the property. Has the same usage as in 877 * <code>setProperty()</code>. 878 * @param propName The name of the property. 879 * Has the same usage as in <code>getProperty()</code>. 880 * @param propValue the literal property value as <code>int</code>. 881 * @param options options of the property to set (optional). 882 * @throws XMPException Wraps all exceptions that may occur. 883 */ 884 void setPropertyInteger( 885 String schemaNS, 886 String propName, 887 int propValue, 888 PropertyOptions options) throws XMPException; 889 890 891 /** 892 * @see XMPMeta#setPropertyInteger(String, String, int, PropertyOptions) 893 * 894 * @param schemaNS The namespace URI for the property 895 * @param propName The name of the property 896 * @param propValue the literal property value as <code>int</code> 897 * @throws XMPException Wraps all exceptions 898 */ 899 void setPropertyInteger( 900 String schemaNS, 901 String propName, 902 int propValue) throws XMPException; 903 904 905 /** 906 * Convenience method to set a property to a literal <code>long</code> value. 907 * 908 * @param schemaNS The namespace URI for the property. Has the same usage as in 909 * <code>setProperty()</code>. 910 * @param propName The name of the property. 911 * Has the same usage as in <code>getProperty()</code>. 912 * @param propValue the literal property value as <code>long</code>. 913 * @param options options of the property to set (optional). 914 * @throws XMPException Wraps all exceptions that may occur. 915 */ 916 void setPropertyLong( 917 String schemaNS, 918 String propName, 919 long propValue, 920 PropertyOptions options) throws XMPException; 921 922 923 /** 924 * @see XMPMeta#setPropertyLong(String, String, long, PropertyOptions) 925 * 926 * @param schemaNS The namespace URI for the property 927 * @param propName The name of the property 928 * @param propValue the literal property value as <code>long</code> 929 * @throws XMPException Wraps all exceptions 930 */ 931 void setPropertyLong( 932 String schemaNS, 933 String propName, 934 long propValue) throws XMPException; 935 936 937 /** 938 * Convenience method to set a property to a literal <code>double</code> value. 939 * 940 * @param schemaNS The namespace URI for the property. Has the same usage as in 941 * <code>setProperty()</code>. 942 * @param propName The name of the property. 943 * Has the same usage as in <code>getProperty()</code>. 944 * @param propValue the literal property value as <code>double</code>. 945 * @param options options of the property to set (optional). 946 * @throws XMPException Wraps all exceptions that may occur. 947 */ 948 void setPropertyDouble( 949 String schemaNS, 950 String propName, 951 double propValue, 952 PropertyOptions options) throws XMPException; 953 954 955 /** 956 * @see XMPMeta#setPropertyDouble(String, String, double, PropertyOptions) 957 * 958 * @param schemaNS The namespace URI for the property 959 * @param propName The name of the property 960 * @param propValue the literal property value as <code>double</code> 961 * @throws XMPException Wraps all exceptions 962 */ 963 void setPropertyDouble( 964 String schemaNS, 965 String propName, 966 double propValue) throws XMPException; 967 968 969 /** 970 * Convenience method to set a property with an XMPDateTime-object, 971 * which is serialized to an ISO8601 date. 972 * 973 * @param schemaNS The namespace URI for the property. Has the same usage as in 974 * <code>setProperty()</code>. 975 * @param propName The name of the property. 976 * Has the same usage as in <code>getProperty()</code>. 977 * @param propValue the property value as <code>XMPDateTime</code>. 978 * @param options options of the property to set (optional). 979 * @throws XMPException Wraps all exceptions that may occur. 980 */ 981 void setPropertyDate( 982 String schemaNS, 983 String propName, 984 XMPDateTime propValue, 985 PropertyOptions options) throws XMPException; 986 987 988 /** 989 * @see XMPMeta#setPropertyDate(String, String, XMPDateTime, PropertyOptions) 990 * 991 * @param schemaNS The namespace URI for the property 992 * @param propName The name of the property 993 * @param propValue the property value as <code>XMPDateTime</code> 994 * @throws XMPException Wraps all exceptions 995 */ 996 void setPropertyDate( 997 String schemaNS, 998 String propName, 999 XMPDateTime propValue) throws XMPException; 1000 1001 1002 /** 1003 * Convenience method to set a property with a Java Calendar-object, 1004 * which is serialized to an ISO8601 date. 1005 * 1006 * @param schemaNS The namespace URI for the property. Has the same usage as in 1007 * <code>setProperty()</code>. 1008 * @param propName The name of the property. 1009 * Has the same usage as in <code>getProperty()</code>. 1010 * @param propValue the property value as Java <code>Calendar</code>. 1011 * @param options options of the property to set (optional). 1012 * @throws XMPException Wraps all exceptions that may occur. 1013 */ 1014 void setPropertyCalendar( 1015 String schemaNS, 1016 String propName, 1017 Calendar propValue, 1018 PropertyOptions options) throws XMPException; 1019 1020 1021 /** 1022 * @see XMPMeta#setPropertyCalendar(String, String, Calendar, PropertyOptions) 1023 * 1024 * @param schemaNS The namespace URI for the property 1025 * @param propName The name of the property 1026 * @param propValue the property value as <code>Calendar</code> 1027 * @throws XMPException Wraps all exceptions 1028 */ 1029 void setPropertyCalendar( 1030 String schemaNS, 1031 String propName, 1032 Calendar propValue) throws XMPException; 1033 1034 1035 /** 1036 * Convenience method to set a property from a binary <code>byte[]</code>-array, 1037 * which is serialized as base64-string. 1038 * 1039 * @param schemaNS The namespace URI for the property. Has the same usage as in 1040 * <code>setProperty()</code>. 1041 * @param propName The name of the property. 1042 * Has the same usage as in <code>getProperty()</code>. 1043 * @param propValue the literal property value as byte array. 1044 * @param options options of the property to set (optional). 1045 * @throws XMPException Wraps all exceptions that may occur. 1046 */ 1047 void setPropertyBase64( 1048 String schemaNS, 1049 String propName, 1050 byte[] propValue, 1051 PropertyOptions options) throws XMPException; 1052 1053 1054 /** 1055 * @see XMPMeta#setPropertyBase64(String, String, byte[], PropertyOptions) 1056 * 1057 * @param schemaNS The namespace URI for the property 1058 * @param propName The name of the property 1059 * @param propValue the literal property value as byte array 1060 * @throws XMPException Wraps all exceptions 1061 */ 1062 void setPropertyBase64( 1063 String schemaNS, 1064 String propName, 1065 byte[] propValue) throws XMPException; 1066 1067 1068 /** 1069 * Constructs an iterator for the properties within this XMP object. 1070 * 1071 * @return Returns an <code>XMPIterator</code>. 1072 * @see XMPMeta#iterator(String, String, IteratorOptions) 1073 * @throws XMPException Wraps all errors and exceptions that may occur. 1074 */ 1075 XMPIterator iterator() throws XMPException; 1076 1077 1078 /** 1079 * Constructs an iterator for the properties within this XMP object using some options. 1080 * 1081 * @param options Option flags to control the iteration. 1082 * @return Returns an <code>XMPIterator</code>. 1083 * @see XMPMeta#iterator(String, String, IteratorOptions) 1084 * @throws XMPException Wraps all errors and exceptions that may occur. 1085 */ 1086 XMPIterator iterator(IteratorOptions options) throws XMPException; 1087 1088 1089 /** 1090 * Construct an iterator for the properties within an XMP object. The general operation of an 1091 * XMP object iterator was. According to the parameters it iterates the entire data tree, 1092 * properties within a specific schema, or a subtree rooted at a specific node. 1093 * 1094 * @param schemaNS Optional schema namespace URI to restrict the iteration. Omitted (visit all 1095 * schema) by passing <code>null</code> or empty String. 1096 * @param propName Optional property name to restrict the iteration. May be an arbitrary path 1097 * expression. Omitted (visit all properties) by passing <code>null</code> or empty 1098 * String. If no schema URI is given, it is ignored. 1099 * @param options Option flags to control the iteration. See {@link IteratorOptions} for 1100 * details. 1101 * @return Returns an <code>XMPIterator</code> for this <code>XMPMeta</code>-object 1102 * considering the given options. 1103 * @throws XMPException Wraps all errors and exceptions that may occur. 1104 */ 1105 XMPIterator iterator( 1106 String schemaNS, 1107 String propName, 1108 IteratorOptions options) throws XMPException; 1109 1110 1111 /** 1112 * This correlates to the about-attribute, 1113 * returns the empty String if no name is set. 1114 * 1115 * @return Returns the name of the XMP object. 1116 */ 1117 String getObjectName(); 1118 1119 1120 /** 1121 * @param name Sets the name of the XMP object. 1122 */ 1123 void setObjectName(String name); 1124 1125 1126 /** 1127 * @return Returns the unparsed content of the <?xpacket> processing instruction. 1128 * This contains normally the attribute-like elements 'begin="<BOM>" 1129 * id="W5M0MpCehiHzreSzNTczkc9d"' and possibly the deprecated elements 'bytes="1234"' or 1130 * 'encoding="XXX"'. If the parsed packet has not been wrapped into an xpacket, 1131 * <code>null</code> is returned. 1132 */ 1133 String getPacketHeader(); 1134 1135 1136 /** 1137 * Clones the complete metadata tree. 1138 * 1139 * @return Returns a deep copy of this instance. 1140 */ 1141 Object clone(); 1142 1143 1144 /** 1145 * Sorts the complete datamodel according to the following rules: 1146 * <ul> 1147 * <li>Schema nodes are sorted by prefix. 1148 * <li>Properties at top level and within structs are sorted by full name, that is 1149 * prefix + local name. 1150 * <li>Array items are not sorted, even if they have no certain order such as bags. 1151 * <li>Qualifier are sorted, with the exception of "xml:lang" and/or "rdf:type" 1152 * that stay at the top of the list in that order. 1153 * </ul> 1154 */ 1155 void sort(); 1156 1157 1158 /** 1159 * Perform the normalization as a separate parsing step. 1160 * Normally it is done during parsing, unless the parsing option 1161 * {@link ParseOptions#OMIT_NORMALIZATION} is set to <code>true</code>. 1162 * <em>Note:</em> It does no harm to call this method to an already normalized xmp object. 1163 * It was a PDF/A requirement to get hand on the unnormalized <code>XMPMeta</code> object. 1164 * 1165 * @param options optional parsing options. 1166 * @throws XMPException Wraps all errors and exceptions that may occur. 1167 */ 1168 void normalize(ParseOptions options) throws XMPException; 1169 1170 1171 /** 1172 * Renders this node and the tree unter this node in a human readable form. 1173 * @return Returns a multiline string containing the dump. 1174 */ 1175 String dumpObject(); 1176 }