You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by gb...@apache.org on 2013/03/06 16:57:52 UTC

svn commit: r1453395 [1/11] - in /pdfbox/trunk/xmpbox: ./ src/main/java/org/apache/xmpbox/ src/main/java/org/apache/xmpbox/schema/ src/main/java/org/apache/xmpbox/type/ src/main/java/org/apache/xmpbox/xml/ src/test/java/org/apache/xmpbox/ src/test/java...

Author: gbailleul
Date: Wed Mar  6 15:57:44 2013
New Revision: 1453395

URL: http://svn.apache.org/r1453395
Log:
PDFBOX-1530: Reformat xmpbox sources with the new formater

Modified:
    pdfbox/trunk/xmpbox/pom.xml
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/DateConverter.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XMPMetadata.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XmpConstants.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/AdobePDFSchema.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/DublinCoreSchema.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/PDFAExtensionSchema.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/PDFAIdentificationSchema.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/PhotoshopSchema.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPBasicJobTicketSchema.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPBasicSchema.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPMediaManagementSchema.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPRightsManagementSchema.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPSchema.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPSchemaFactory.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XmpSchemaException.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractComplexProperty.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractField.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractSimpleProperty.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractStructuredType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AgentNameType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Attribute.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/BadFieldValueException.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/BooleanType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Cardinality.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ChoiceType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ComplexPropertyContainer.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/DateType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/DefinedStructuredType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/GUIDType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/IntegerType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/JobType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/LayerType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/LocaleType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/MIMEType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFAFieldType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFAPropertyType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFASchemaType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFATypeType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PartType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ProperNameType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PropertiesDescription.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PropertyType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/RealType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/RenditionClassType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ResourceEventType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ResourceRefType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/StructuredType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TextType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ThumbnailType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TypeMapping.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Types.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/URIType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/URLType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/VersionType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/XPathType.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomHelper.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/PdfaExtensionHelper.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpParsingException.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializationException.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/DoubleSameTypeSchemaTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/SaveMetadataHelperTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/TestXMPWithDefinedSchemas.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/XMPMetaDataTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/DeserializationTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/PropMappingTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractSchemaTester.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractXMPSchemaTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AdobePDFErrorsTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AdobePDFTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/BasicJobTicketSchemaTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/DublinCoreTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationOthersTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/PhotoshopSchemaTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPBasicTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPMediaManagementTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XmpRightsSchemaTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/AbstractStructuredTypeTester.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/AttributeTest.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestAbstractStructuredType.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestDerivedType.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestJobType.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestLayerType.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestResourceEventType.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestResourceRefType.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestSimpleMetadataProperties.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestThumbnailType.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestVersionType.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TypeTestingHelper.java

Modified: pdfbox/trunk/xmpbox/pom.xml
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/pom.xml?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/pom.xml (original)
+++ pdfbox/trunk/xmpbox/pom.xml Wed Mar  6 15:57:44 2013
@@ -55,6 +55,15 @@
 				<artifactId>maven-bundle-plugin</artifactId>
 				<extensions>true</extensions>
 			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-checkstyle-plugin</artifactId>
+				<version>2.10</version>
+				<configuration>
+					<configLocation>../pdfbox-checkstyle-5.xml</configLocation>
+				</configuration>
+			</plugin>
+			
 		</plugins>
 	</build>
 
@@ -88,14 +97,6 @@
 				</configuration>
 			</plugin>
 
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-checkstyle-plugin</artifactId>
-				<version>2.2</version>
-				<configuration>
-					<configLocation>edoc-checkstyle.xml</configLocation>
-				</configuration>
-			</plugin>
 
 			<plugin>
 				<groupId>org.codehaus.mojo</groupId>

Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/DateConverter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/DateConverter.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/DateConverter.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/DateConverter.java Wed Mar  6 15:57:44 2013
@@ -30,222 +30,257 @@ import java.util.GregorianCalendar;
 import java.util.SimpleTimeZone;
 
 /**
- * This class is used to convert dates to strings and back using the PDF date
- * standards. Date are described in PDFReference1.4 section 3.8.2
+ * This class is used to convert dates to strings and back using the PDF date standards. Date are described in
+ * PDFReference1.4 section 3.8.2
  * 
  * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
  * @author <a href="mailto:chris@oezbek.net">Christopher Oezbek</a>
  * 
  * @version $Revision: 1.3 $
  */
-public class DateConverter {
+public class DateConverter
+{
 
-	// The Date format is supposed to be the PDF_DATE_FORMAT, but not all PDF
-	// documents
-	// will use that date, so I have added a couple other potential formats
-	// to try if the original one does not work.
-	private static final SimpleDateFormat[] POTENTIAL_FORMATS = new SimpleDateFormat[] {
-		new SimpleDateFormat("EEEE, dd MMM yyyy hh:mm:ss a"),
-		new SimpleDateFormat("EEEE, MMM dd, yyyy hh:mm:ss a"),
-		new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"),
-		new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz") };
-
-	/**
-	 * According to check-style, Utility classes should not have a public or
-	 * default constructor.
-	 */
-	protected DateConverter() {
-	};
-
-	/**
-	 * This will convert a string to a calendar.
-	 * 
-	 * @param date
-	 *            The string representation of the calendar.
-	 * 
-	 * @return The calendar that this string represents.
-	 * 
-	 * @throws IOException
-	 *             If the date string is not in the correct format.
-	 */
-	public static Calendar toCalendar(String date) throws IOException {
-		Calendar retval = null;
-		if ((date != null) && (date.trim().length() > 0)) {
-			// these are the default values
-			int year = 0;
-			int month = 1;
-			int day = 1;
-			int hour = 0;
-			int minute = 0;
-			int second = 0;
-			// first string off the prefix if it exists
-			try {
-				SimpleTimeZone zone = null;
-				if (date.startsWith("D:")) {
-					date = date.substring(2, date.length());
-				}
-
-				date = date.replaceAll("[-:T]", "");
-
-				if (date.length() < 4) {
-					throw new IOException("Error: Invalid date format '" + date
-							+ "'");
-				}
-				year = Integer.parseInt(date.substring(0, 4));
-				if (date.length() >= 6) {
-					month = Integer.parseInt(date.substring(4, 6));
-				}
-				if (date.length() >= 8) {
-					day = Integer.parseInt(date.substring(6, 8));
-				}
-				if (date.length() >= 10) {
-					hour = Integer.parseInt(date.substring(8, 10));
-				}
-				if (date.length() >= 12) {
-					minute = Integer.parseInt(date.substring(10, 12));
-				}
-
-				int timeZonePos = 12;
-				if (date.length() - 12 > 5 ||(date.length() - 12 == 3 && date.endsWith("Z"))) {
-					if (date.length() >= 14) {
-						second = Integer.parseInt(date.substring(12, 14));
-					}
-					timeZonePos = 14;
-				} else {
-					second = 0;
-				}
-
-				if (date.length() >= (timeZonePos+1)) {
-					char sign = date.charAt(timeZonePos);
-					if (sign == 'Z') {
-						zone = new SimpleTimeZone(0, "Unknown");
-					} else {
-						int hours = 0;
-						int minutes = 0;
-						if (date.length() >= (timeZonePos+3)) {
-							if (sign == '+') {
-								// parseInt cannot handle the + sign
-								hours = Integer.parseInt(date.substring((timeZonePos+1), (timeZonePos+3)));
-							} else {
-								hours = -Integer.parseInt(date.substring(timeZonePos, (timeZonePos+2)));
-							}
-						}
-						if (sign == '+') {
-							if (date.length() >= (timeZonePos+5)) {
-								minutes = Integer.parseInt(date.substring((timeZonePos+3), (timeZonePos+5)));
-							}
-						} else {
-							if (date.length() >= (timeZonePos+4)) {
-								minutes = Integer.parseInt(date.substring((timeZonePos+2), (timeZonePos+4)));
-							}
-						}
-						zone = new SimpleTimeZone(hours * 60 * 60 * 1000
-								+ minutes * 60 * 1000, "Unknown");
-					}
-				}
-
-
-				if (zone == null) {
-					retval = new GregorianCalendar();
-				} else {
-					retval = new GregorianCalendar(zone);
-				}
-				retval.clear();
-				retval.set(year, month - 1, day, hour, minute, second);
-			} catch (NumberFormatException e) {
-
-				// remove the arbitrary : in the timezone. SimpleDateFormat
-				// can't handle it
-				if (date.substring(date.length() - 3, date.length() - 2)
-						.equals(":")
-						&& (date
-								.substring(date.length() - 6, date.length() - 5)
-								.equals("+") || date.substring(
-										date.length() - 6, date.length() - 5).equals(
-												"-"))) {
-					// thats a timezone string, remove the :
-					date = date.substring(0, date.length() - 3)
-							+ date.substring(date.length() - 2);
-				}
-				for (int i = 0; (retval == null)
-						&& (i < POTENTIAL_FORMATS.length); i++) {
-					try {
-						Date utilDate = POTENTIAL_FORMATS[i].parse(date);
-						retval = new GregorianCalendar();
-						retval.setTime(utilDate);
-					} catch (ParseException pe) {
-						// ignore and move to next potential format
-					}
-				}
-				if (retval == null) {
-					// we didn't find a valid date format so throw an exception
-					IOException ioe = new IOException("Error converting date:" + date);
-					ioe.initCause(e);
-					throw ioe;
-				}
-			}
-		}
-		return retval;
-	}
-
-	/**
-	 * Append Zero to String Buffer before number < 10 ('1' become '01')
-	 * 
-	 * @param out
-	 *            The String buffer
-	 * @param number
-	 *            The concerned number
-	 */
-	private static void zeroAppend(StringBuffer out, int number) {
-		if (number < 10) {
-			out.append("0");
-		}
-		out.append(number);
-	}
-
-	/**
-	 * Convert the date to iso 8601 string format.
-	 * 
-	 * @param cal
-	 *            The date to convert.
-	 * @return The date represented as an ISO 8601 string.
-	 */
-	public static String toISO8601(Calendar cal) {
-		StringBuffer retval = new StringBuffer();
-
-		retval.append(cal.get(Calendar.YEAR));
-		retval.append("-");
-		zeroAppend(retval, cal.get(Calendar.MONTH) + 1);
-		retval.append("-");
-		zeroAppend(retval, cal.get(Calendar.DAY_OF_MONTH));
-		retval.append("T");
-		zeroAppend(retval, cal.get(Calendar.HOUR_OF_DAY));
-		retval.append(":");
-		zeroAppend(retval, cal.get(Calendar.MINUTE));
-		retval.append(":");
-		zeroAppend(retval, cal.get(Calendar.SECOND));
-
-		int timeZone = cal.get(Calendar.ZONE_OFFSET)
-				+ cal.get(Calendar.DST_OFFSET);
-		if (timeZone < 0) {
-			retval.append("-");
-		} else {
-			retval.append("+");
-		}
-		timeZone = Math.abs(timeZone);
-		// milliseconds/1000 = seconds = seconds / 60 = minutes = minutes/60 =
-		// hours
-		int hours = timeZone / 1000 / 60 / 60;
-		int minutes = (timeZone - (hours * 1000 * 60 * 60)) / 1000 / 1000;
-		if (hours < 10) {
-			retval.append("0");
-		}
-		retval.append(Integer.toString(hours));
-		retval.append(":");
-		if (minutes < 10) {
-			retval.append("0");
-		}
-		retval.append(Integer.toString(minutes));
-		return retval.toString();
-	}
+    // The Date format is supposed to be the PDF_DATE_FORMAT, but not all PDF
+    // documents
+    // will use that date, so I have added a couple other potential formats
+    // to try if the original one does not work.
+    private static final SimpleDateFormat[] POTENTIAL_FORMATS = new SimpleDateFormat[] {
+            new SimpleDateFormat("EEEE, dd MMM yyyy hh:mm:ss a"),
+            new SimpleDateFormat("EEEE, MMM dd, yyyy hh:mm:ss a"), new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"),
+            new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz") };
+
+    /**
+     * According to check-style, Utility classes should not have a public or default constructor.
+     */
+    protected DateConverter()
+    {
+    };
+
+    /**
+     * This will convert a string to a calendar.
+     * 
+     * @param date
+     *            The string representation of the calendar.
+     * 
+     * @return The calendar that this string represents.
+     * 
+     * @throws IOException
+     *             If the date string is not in the correct format.
+     */
+    public static Calendar toCalendar(String date) throws IOException
+    {
+        Calendar retval = null;
+        if ((date != null) && (date.trim().length() > 0))
+        {
+            // these are the default values
+            int year = 0;
+            int month = 1;
+            int day = 1;
+            int hour = 0;
+            int minute = 0;
+            int second = 0;
+            // first string off the prefix if it exists
+            try
+            {
+                SimpleTimeZone zone = null;
+                if (date.startsWith("D:"))
+                {
+                    date = date.substring(2, date.length());
+                }
+
+                date = date.replaceAll("[-:T]", "");
+
+                if (date.length() < 4)
+                {
+                    throw new IOException("Error: Invalid date format '" + date + "'");
+                }
+                year = Integer.parseInt(date.substring(0, 4));
+                if (date.length() >= 6)
+                {
+                    month = Integer.parseInt(date.substring(4, 6));
+                }
+                if (date.length() >= 8)
+                {
+                    day = Integer.parseInt(date.substring(6, 8));
+                }
+                if (date.length() >= 10)
+                {
+                    hour = Integer.parseInt(date.substring(8, 10));
+                }
+                if (date.length() >= 12)
+                {
+                    minute = Integer.parseInt(date.substring(10, 12));
+                }
+
+                int timeZonePos = 12;
+                if (date.length() - 12 > 5 || (date.length() - 12 == 3 && date.endsWith("Z")))
+                {
+                    if (date.length() >= 14)
+                    {
+                        second = Integer.parseInt(date.substring(12, 14));
+                    }
+                    timeZonePos = 14;
+                }
+                else
+                {
+                    second = 0;
+                }
+
+                if (date.length() >= (timeZonePos + 1))
+                {
+                    char sign = date.charAt(timeZonePos);
+                    if (sign == 'Z')
+                    {
+                        zone = new SimpleTimeZone(0, "Unknown");
+                    }
+                    else
+                    {
+                        int hours = 0;
+                        int minutes = 0;
+                        if (date.length() >= (timeZonePos + 3))
+                        {
+                            if (sign == '+')
+                            {
+                                // parseInt cannot handle the + sign
+                                hours = Integer.parseInt(date.substring((timeZonePos + 1), (timeZonePos + 3)));
+                            }
+                            else
+                            {
+                                hours = -Integer.parseInt(date.substring(timeZonePos, (timeZonePos + 2)));
+                            }
+                        }
+                        if (sign == '+')
+                        {
+                            if (date.length() >= (timeZonePos + 5))
+                            {
+                                minutes = Integer.parseInt(date.substring((timeZonePos + 3), (timeZonePos + 5)));
+                            }
+                        }
+                        else
+                        {
+                            if (date.length() >= (timeZonePos + 4))
+                            {
+                                minutes = Integer.parseInt(date.substring((timeZonePos + 2), (timeZonePos + 4)));
+                            }
+                        }
+                        zone = new SimpleTimeZone(hours * 60 * 60 * 1000 + minutes * 60 * 1000, "Unknown");
+                    }
+                }
+
+                if (zone == null)
+                {
+                    retval = new GregorianCalendar();
+                }
+                else
+                {
+                    retval = new GregorianCalendar(zone);
+                }
+                retval.clear();
+                retval.set(year, month - 1, day, hour, minute, second);
+            }
+            catch (NumberFormatException e)
+            {
+
+                // remove the arbitrary : in the timezone. SimpleDateFormat
+                // can't handle it
+                if (date.substring(date.length() - 3, date.length() - 2).equals(":")
+                        && (date.substring(date.length() - 6, date.length() - 5).equals("+") || date.substring(
+                                date.length() - 6, date.length() - 5).equals("-")))
+                {
+                    // thats a timezone string, remove the :
+                    date = date.substring(0, date.length() - 3) + date.substring(date.length() - 2);
+                }
+                for (int i = 0; (retval == null) && (i < POTENTIAL_FORMATS.length); i++)
+                {
+                    try
+                    {
+                        Date utilDate = POTENTIAL_FORMATS[i].parse(date);
+                        retval = new GregorianCalendar();
+                        retval.setTime(utilDate);
+                    }
+                    catch (ParseException pe)
+                    {
+                        // ignore and move to next potential format
+                    }
+                }
+                if (retval == null)
+                {
+                    // we didn't find a valid date format so throw an exception
+                    IOException ioe = new IOException("Error converting date:" + date);
+                    ioe.initCause(e);
+                    throw ioe;
+                }
+            }
+        }
+        return retval;
+    }
+
+    /**
+     * Append Zero to String Buffer before number < 10 ('1' become '01')
+     * 
+     * @param out
+     *            The String buffer
+     * @param number
+     *            The concerned number
+     */
+    private static void zeroAppend(StringBuffer out, int number)
+    {
+        if (number < 10)
+        {
+            out.append("0");
+        }
+        out.append(number);
+    }
+
+    /**
+     * Convert the date to iso 8601 string format.
+     * 
+     * @param cal
+     *            The date to convert.
+     * @return The date represented as an ISO 8601 string.
+     */
+    public static String toISO8601(Calendar cal)
+    {
+        StringBuffer retval = new StringBuffer();
+
+        retval.append(cal.get(Calendar.YEAR));
+        retval.append("-");
+        zeroAppend(retval, cal.get(Calendar.MONTH) + 1);
+        retval.append("-");
+        zeroAppend(retval, cal.get(Calendar.DAY_OF_MONTH));
+        retval.append("T");
+        zeroAppend(retval, cal.get(Calendar.HOUR_OF_DAY));
+        retval.append(":");
+        zeroAppend(retval, cal.get(Calendar.MINUTE));
+        retval.append(":");
+        zeroAppend(retval, cal.get(Calendar.SECOND));
+
+        int timeZone = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
+        if (timeZone < 0)
+        {
+            retval.append("-");
+        }
+        else
+        {
+            retval.append("+");
+        }
+        timeZone = Math.abs(timeZone);
+        // milliseconds/1000 = seconds = seconds / 60 = minutes = minutes/60 =
+        // hours
+        int hours = timeZone / 1000 / 60 / 60;
+        int minutes = (timeZone - (hours * 1000 * 60 * 60)) / 1000 / 1000;
+        if (hours < 10)
+        {
+            retval.append("0");
+        }
+        retval.append(Integer.toString(hours));
+        retval.append(":");
+        if (minutes < 10)
+        {
+            retval.append("0");
+        }
+        retval.append(Integer.toString(minutes));
+        return retval.toString();
+    }
 }

Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XMPMetadata.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XMPMetadata.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XMPMetadata.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XMPMetadata.java Wed Mar  6 15:57:44 2013
@@ -40,466 +40,490 @@ import org.apache.xmpbox.type.Structured
 import org.apache.xmpbox.type.TypeMapping;
 
 /**
- * Object representation of XMPMetaData Be CAREFUL: typically, metadata should
- * contain only one schema for each type (each NSURI). Retrieval of common
- * schemas (like DublinCore) is based on this fact and take the first schema of
- * this type encountered. However, XmpBox allow you to place schemas of same
- * type with different prefix. If you do that, you must retrieve all schemas by
- * yourself with getAllSchemas or with getSchema which use prefix parameter.
+ * Object representation of XMPMetaData Be CAREFUL: typically, metadata should contain only one schema for each type
+ * (each NSURI). Retrieval of common schemas (like DublinCore) is based on this fact and take the first schema of this
+ * type encountered. However, XmpBox allow you to place schemas of same type with different prefix. If you do that, you
+ * must retrieve all schemas by yourself with getAllSchemas or with getSchema which use prefix parameter.
  * 
  * @author a183132
  * 
  */
-public class XMPMetadata {
+public class XMPMetadata
+{
 
-	private String xpacketId = null;
+    private String xpacketId = null;
 
-	private String xpacketBegin = null;
-
-	private String xpacketBytes = null;
-
-	private String xpacketEncoding = null;
-
-	private String xpacketEndData = XmpConstants.DEFAULT_XPACKET_END;
-
-	private List<XMPSchema> schemas;
-
-	private TypeMapping typeMapping;
-
-	/**
-	 * Contructor of an empty default XMPMetaData
-	 * 
-	 * @throws CreateXMPMetadataException
-	 *             If DOM Document associated could not be created
-	 */
-	protected XMPMetadata() {
-		this (
-				XmpConstants.DEFAULT_XPACKET_BEGIN,
-				XmpConstants.DEFAULT_XPACKET_ID,
-				XmpConstants.DEFAULT_XPACKET_BYTES, 
-				XmpConstants.DEFAULT_XPACKET_ENCODING
-				);
-	}
-
-	/**
-	 * creates blank XMP doc with specified parameters
-	 * 
-	 * @throws CreateXMPMetadataException
-	 * @param xpacketBegin
-	 *            Value of xpacketBegin
-	 * @param xpacketId
-	 *            Value of xpacketId
-	 * @param xpacketBytes
-	 *            Value of xpacketBytes
-	 * @param xpacketEncoding
-	 *            Value of xpacket encoding
-	 * @throws CreateXMPMetadataException
-	 *             If DOM Document associated could not be created
-	 */
-	protected XMPMetadata(String xpacketBegin, String xpacketId,
-			String xpacketBytes, String xpacketEncoding) {
-		this.schemas = new ArrayList<XMPSchema>();
-		this.typeMapping = new TypeMapping(this);
-
-		this.xpacketBegin = xpacketBegin;
-		this.xpacketId = xpacketId;
-		this.xpacketBytes = xpacketBytes;
-		this.xpacketEncoding = xpacketEncoding;
-	}
-
-	public static XMPMetadata createXMPMetadata () {
-		return new XMPMetadata();
-	}
-
-	public static XMPMetadata createXMPMetadata (String xpacketBegin, String xpacketId,
-			String xpacketBytes, String xpacketEncoding) {
-		return new XMPMetadata(xpacketBegin, xpacketId, xpacketBytes, xpacketEncoding);
-	}
-
-	public TypeMapping getTypeMapping () {
-		return this.typeMapping;
-	}
-
-	/**
-	 * Get xpacketBytes
-	 * 
-	 * @return value of xpacketBytes field
-	 */
-	public String getXpacketBytes() {
-		return xpacketBytes;
-	}
-
-	/**
-	 * Get xpacket encoding
-	 * 
-	 * @return value of xpacket Encoding field
-	 */
-	public String getXpacketEncoding() {
-		return xpacketEncoding;
-	}
-
-	/**
-	 * Get xpacket Begin
-	 * 
-	 * @return value of xpacket Begin field
-	 */
-	public String getXpacketBegin() {
-		return xpacketBegin;
-	}
-
-	/**
-	 * Get xpacket Id
-	 * 
-	 * @return value of xpacket Id field
-	 */
-	public String getXpacketId() {
-		return xpacketId;
-	}
-
-	/**
-	 * Get All Schemas declared in this metadata representation
-	 * 
-	 * @return List of declared schemas
-	 */
-	public List<XMPSchema> getAllSchemas() {
-		ArrayList<XMPSchema> schem = new ArrayList<XMPSchema>();
-		Iterator<XMPSchema> it = schemas.iterator();
-		while (it.hasNext()) {
-			schem.add((XMPSchema) it.next());
-		}
-		return schem;
-	}
-
-	/**
-	 * Set special XPACKET END PI
-	 * 
-	 * @param data
-	 *            The XPacket End value
-	 */
-	public void setEndXPacket(String data) {
-		xpacketEndData = data;
-	}
-
-	/**
-	 * get XPACKET END PI
-	 * 
-	 * @return XPACKET END Value
-	 */
-	public String getEndXPacket() {
-		return xpacketEndData;
-	}
-
-	/**
-	 * Return the schema corresponding to this nsURI BE CAREFUL: typically,
-	 * Metadata should contains one schema for each type this method return the
-	 * first schema encountered corresponding to this NSURI Return null if
-	 * unknown
-	 * 
-	 * @param nsURI
-	 *            The namespace URI corresponding to the schema wanted
-	 * @return The Class Schema representation
-	 */
-	public XMPSchema getSchema(String nsURI) {
-		Iterator<XMPSchema> it = schemas.iterator();
-		XMPSchema tmp;
-		while (it.hasNext()) {
-			tmp = it.next();
-			if (tmp.getNamespace().equals(nsURI)) {
-				return tmp;
-			}
-		}
-		return null;
-	}
-
-	
-	public XMPSchema getSchema (Class<? extends XMPSchema> clz) {
-		StructuredType st = clz.getAnnotation(StructuredType.class);
-		return getSchema(st.namespace());
-	}
-	
-	public void clearSchemas () {
-		schemas.clear();
-	}
-
-	/**
-	 * Return the schema corresponding to this nsURI and a prefix This method is
-	 * here to treat metadata which embed more than one time the same schema It
-	 * permit to retrieve a specific schema with its prefix
-	 * 
-	 * @param prefix
-	 *            The prefix fixed in the schema wanted
-	 * @param nsURI
-	 *            The namespace URI corresponding to the schema wanted
-	 * @return The Class Schema representation
-	 */
-	public XMPSchema getSchema(String prefix, String nsURI) {
-		Iterator<XMPSchema> it = getAllSchemas().iterator();
-		XMPSchema tmp;
-		while (it.hasNext()) {
-			tmp = it.next();
-			if (tmp.getNamespace().equals(nsURI)
-					&& tmp.getPrefix().equals(prefix)) {
-				return tmp;
-			}
-		}
-		return null;
-	}
-
-	/**
-	 * Set a unspecialized schema
-	 * 
-	 * @param nsPrefix
-	 *            The prefix wanted for the schema
-	 * @param nsURI
-	 *            The namespace URI wanted for the schema
-	 * @return The schema added in order to work on it
-	 */
-	public XMPSchema createAndAddDefaultSchema(String nsPrefix, String nsURI) {
-		XMPSchema schem = new XMPSchema(this, nsURI,nsPrefix);
-		schem.setAboutAsSimple("");
-		addSchema(schem);
-		return schem;
-	}
-
-	/**
-	 * Create and add a default PDFA Extension schema to this metadata This
-	 * method return the created schema to enter information This PDFAExtension
-	 * is created with all default namespaces used in PDFAExtensionSchema
-	 * 
-	 * @return PDFAExtension schema added in order to work on it
-	 */
-	public PDFAExtensionSchema createAndAddPDFAExtensionSchemaWithDefaultNS() {
-		PDFAExtensionSchema pdfAExt = new PDFAExtensionSchema(this);
-		pdfAExt.setAboutAsSimple("");
-		addSchema(pdfAExt);
-		return pdfAExt;
-	}
-
-	/**
-	 * Create and add a default XMPRights schema to this metadata This method
-	 * return the created schema to enter information
-	 * 
-	 * @return schema added in order to work on it
-	 */
-	public XMPRightsManagementSchema createAndAddXMPRightsManagementSchema() {
-		XMPRightsManagementSchema rights = new XMPRightsManagementSchema(this);
-		rights.setAboutAsSimple("");
-		addSchema(rights);
-		return rights;
-	}
-
-	/**
-	 * Create and add a default PDFA Extension schema to this metadata This
-	 * method return the created schema to enter information This PDFAExtension
-	 * is created with specified list of namespaces
-	 * 
-	 * @param namespaces
-	 *            Special namespaces list to use
-	 * @return schema added in order to work on it
-	 * @throws XmpSchemaException
-	 *             If namespaces list not contains PDF/A Extension namespace URI
-	 */
-	public PDFAExtensionSchema createAndAddPDFAExtensionSchemaWithNS(
-			Map<String, String> namespaces) throws XmpSchemaException {
-		PDFAExtensionSchema pdfAExt = new PDFAExtensionSchema(this);
-		pdfAExt.setAboutAsSimple("");
-		addSchema(pdfAExt);
-		return pdfAExt;
-	}
-
-	/**
-	 * Get the PDFA Extension schema This method return null if not found
-	 * 
-	 * @return The PDFAExtension schema or null if not declared
-	 */
-	public PDFAExtensionSchema getPDFExtensionSchema() {
-		return (PDFAExtensionSchema) getSchema(PDFAExtensionSchema.class);
-	}
-
-	/**
-	 * Create and add a default PDFA Identification schema to this metadata This
-	 * method return the created schema to enter information
-	 * 
-	 * @return schema added in order to work on it
-	 */
-	public PDFAIdentificationSchema createAndAddPFAIdentificationSchema() {
-		PDFAIdentificationSchema pdfAId = new PDFAIdentificationSchema(this);
-		pdfAId.setAboutAsSimple("");
-		addSchema(pdfAId);
-		return pdfAId;
-	}
-
-	/**
-	 * Get the PDFA Identification schema This method return null if not found
-	 * 
-	 * @return The PDFAIdentificationSchema schema or null if not declared
-	 */
-	public PDFAIdentificationSchema getPDFIdentificationSchema() {
-		return (PDFAIdentificationSchema) getSchema(PDFAIdentificationSchema.class);
-	}
-
-	/**
-	 * Create and add a default Dublin Core schema to this metadata This method
-	 * return the created schema to enter information
-	 * 
-	 * @return schema added in order to work on it
-	 */
-	public DublinCoreSchema createAndAddDublinCoreSchema() {
-		DublinCoreSchema dc = new DublinCoreSchema(this);
-		dc.setAboutAsSimple("");
-		addSchema(dc);
-		return dc;
-	}
-
-	/**
-	 * Create and add a default Basic Job Ticket schema to this metadata This method
-	 * return the created schema to enter information
-	 * 
-	 * @return schema added in order to work on it
-	 */
-	public XMPBasicJobTicketSchema createAndAddBasicJobTicketSchema () {
-		XMPBasicJobTicketSchema sc = new XMPBasicJobTicketSchema(this);
-		sc.setAboutAsSimple("");
-		addSchema(sc);
-		return sc;
-	}
-
-
-	/**
-	 * Get the Dublin Core schema This method return null if not found
-	 * 
-	 * @return The DublinCoreSchema schema or null if not declared
-	 */
-	public DublinCoreSchema getDublinCoreSchema() {
-		return (DublinCoreSchema) getSchema(DublinCoreSchema.class);
-	}
-
-	/**
-	 * Get the Basic JOb Ticket Schema schema This method return null if not found
-	 * 
-	 * @return The XMPBasicJobTicketSchema schema or null if not declared
-	 */
-	public XMPBasicJobTicketSchema getBasicJobTicketSchema() {
-		return (XMPBasicJobTicketSchema) getSchema(XMPBasicJobTicketSchema.class);
-	}
-
-
-	/**
-	 * Get the XMPRights schema This method return null if not found
-	 * 
-	 * @return The XMPRightsManagementSchema schema or null if not declared
-	 */
-	public XMPRightsManagementSchema getXMPRightsManagementSchema() {
-		return (XMPRightsManagementSchema) getSchema(XMPRightsManagementSchema.class);
-	}
-
-	/**
-	 * Get the Photoshop schema This method return null if not found
-	 * 
-	 * @return The PhotoshopSchema schema or null if not declared
-	 */
-	public PhotoshopSchema getPhotoshopSchema() {
-		return (PhotoshopSchema) getSchema(PhotoshopSchema.PHOTOSHOPURI);
-	}
-
-	/**
-	 * Create and add a XMP Basic schema to this metadata This method return the
-	 * created schema to enter information
-	 * 
-	 * @return schema added in order to work on it
-	 */
-	public XMPBasicSchema createAndAddXMPBasicSchema() {
-		XMPBasicSchema xmpB = new XMPBasicSchema(this);
-		xmpB.setAboutAsSimple("");
-		addSchema(xmpB);
-		return xmpB;
-	}
-
-	/**
-	 * Get the XMP Basic schema This method return null if not found
-	 * 
-	 * @return The XMPBasicSchema schema or null if not declared
-	 */
-	public XMPBasicSchema getXMPBasicSchema() {
-		return (XMPBasicSchema) getSchema(XMPBasicSchema.class);
-	}
-
-	/**
-	 * Create and add a XMP Media Management schema to this metadata This method
-	 * return the created schema to enter information
-	 * 
-	 * @return schema added in order to work on it
-	 */
-	public XMPMediaManagementSchema createAndAddXMPMediaManagementSchema() {
-		XMPMediaManagementSchema xmpMM = new XMPMediaManagementSchema(this);
-		xmpMM.setAboutAsSimple("");
-		addSchema(xmpMM);
-		return xmpMM;
-	}
-
-	/***
-	 * create and add Photoshop Schema to this metadata. This method return 
-	 * the created schema to enter information
-	 * @return
-	 */
-	public PhotoshopSchema createAndAddPhotoshopSchema() {
-		PhotoshopSchema photoshop = new PhotoshopSchema(this);
-		photoshop.setAboutAsSimple("");
-		addSchema(photoshop);
-		return photoshop;
-	}
-
-	/**
-	 * Get the XMP Media Management schema This method return null if not found
-	 * 
-	 * @return The XMPMediaManagementSchema schema or null if not declared
-	 */
-	public XMPMediaManagementSchema getXMPMediaManagementSchema() {
-		return (XMPMediaManagementSchema) getSchema(XMPMediaManagementSchema.class);
-	}
-
-	/**
-	 * Create and add an Adobe PDF schema to this metadata This method return
-	 * the created schema to enter information
-	 * 
-	 * @return schema added in order to work on it
-	 */
-	public AdobePDFSchema createAndAddAdobePDFSchema() {
-		AdobePDFSchema pdf = new AdobePDFSchema(this);
-		pdf.setAboutAsSimple("");
-		addSchema(pdf);
-		return pdf;
-	}
-
-	/**
-	 * Get the Adobe PDF schema This method return null if not found
-	 * 
-	 * @return The AdobePDFSchema schema or null if not declared
-	 */
-	public AdobePDFSchema getAdobePDFSchema() {
-		return (AdobePDFSchema) getSchema(AdobePDFSchema.class);
-	}
-
-	/**
-	 * Add a schema to the current structure
-	 * 
-	 * @param obj
-	 *            the schema to add
-	 */
-	public void addSchema(XMPSchema obj) {
-		schemas.add(obj);
-	}
-
-	/**
-	 * Remove a schema
-	 * 
-	 * @param schema
-	 *            The schema to remove
-	 */
-	public void removeSchema(XMPSchema schema) {
-		schemas.remove(schema);
-	}
+    private String xpacketBegin = null;
 
+    private String xpacketBytes = null;
 
+    private String xpacketEncoding = null;
+
+    private String xpacketEndData = XmpConstants.DEFAULT_XPACKET_END;
+
+    private List<XMPSchema> schemas;
+
+    private TypeMapping typeMapping;
+
+    /**
+     * Contructor of an empty default XMPMetaData
+     * 
+     * @throws CreateXMPMetadataException
+     *             If DOM Document associated could not be created
+     */
+    protected XMPMetadata()
+    {
+        this(XmpConstants.DEFAULT_XPACKET_BEGIN, XmpConstants.DEFAULT_XPACKET_ID, XmpConstants.DEFAULT_XPACKET_BYTES,
+                XmpConstants.DEFAULT_XPACKET_ENCODING);
+    }
+
+    /**
+     * creates blank XMP doc with specified parameters
+     * 
+     * @throws CreateXMPMetadataException
+     * @param xpacketBegin
+     *            Value of xpacketBegin
+     * @param xpacketId
+     *            Value of xpacketId
+     * @param xpacketBytes
+     *            Value of xpacketBytes
+     * @param xpacketEncoding
+     *            Value of xpacket encoding
+     * @throws CreateXMPMetadataException
+     *             If DOM Document associated could not be created
+     */
+    protected XMPMetadata(String xpacketBegin, String xpacketId, String xpacketBytes, String xpacketEncoding)
+    {
+        this.schemas = new ArrayList<XMPSchema>();
+        this.typeMapping = new TypeMapping(this);
+
+        this.xpacketBegin = xpacketBegin;
+        this.xpacketId = xpacketId;
+        this.xpacketBytes = xpacketBytes;
+        this.xpacketEncoding = xpacketEncoding;
+    }
+
+    public static XMPMetadata createXMPMetadata()
+    {
+        return new XMPMetadata();
+    }
+
+    public static XMPMetadata createXMPMetadata(String xpacketBegin, String xpacketId, String xpacketBytes,
+            String xpacketEncoding)
+    {
+        return new XMPMetadata(xpacketBegin, xpacketId, xpacketBytes, xpacketEncoding);
+    }
+
+    public TypeMapping getTypeMapping()
+    {
+        return this.typeMapping;
+    }
+
+    /**
+     * Get xpacketBytes
+     * 
+     * @return value of xpacketBytes field
+     */
+    public String getXpacketBytes()
+    {
+        return xpacketBytes;
+    }
+
+    /**
+     * Get xpacket encoding
+     * 
+     * @return value of xpacket Encoding field
+     */
+    public String getXpacketEncoding()
+    {
+        return xpacketEncoding;
+    }
+
+    /**
+     * Get xpacket Begin
+     * 
+     * @return value of xpacket Begin field
+     */
+    public String getXpacketBegin()
+    {
+        return xpacketBegin;
+    }
+
+    /**
+     * Get xpacket Id
+     * 
+     * @return value of xpacket Id field
+     */
+    public String getXpacketId()
+    {
+        return xpacketId;
+    }
+
+    /**
+     * Get All Schemas declared in this metadata representation
+     * 
+     * @return List of declared schemas
+     */
+    public List<XMPSchema> getAllSchemas()
+    {
+        ArrayList<XMPSchema> schem = new ArrayList<XMPSchema>();
+        Iterator<XMPSchema> it = schemas.iterator();
+        while (it.hasNext())
+        {
+            schem.add((XMPSchema) it.next());
+        }
+        return schem;
+    }
+
+    /**
+     * Set special XPACKET END PI
+     * 
+     * @param data
+     *            The XPacket End value
+     */
+    public void setEndXPacket(String data)
+    {
+        xpacketEndData = data;
+    }
+
+    /**
+     * get XPACKET END PI
+     * 
+     * @return XPACKET END Value
+     */
+    public String getEndXPacket()
+    {
+        return xpacketEndData;
+    }
+
+    /**
+     * Return the schema corresponding to this nsURI BE CAREFUL: typically, Metadata should contains one schema for each
+     * type this method return the first schema encountered corresponding to this NSURI Return null if unknown
+     * 
+     * @param nsURI
+     *            The namespace URI corresponding to the schema wanted
+     * @return The Class Schema representation
+     */
+    public XMPSchema getSchema(String nsURI)
+    {
+        Iterator<XMPSchema> it = schemas.iterator();
+        XMPSchema tmp;
+        while (it.hasNext())
+        {
+            tmp = it.next();
+            if (tmp.getNamespace().equals(nsURI))
+            {
+                return tmp;
+            }
+        }
+        return null;
+    }
+
+    public XMPSchema getSchema(Class<? extends XMPSchema> clz)
+    {
+        StructuredType st = clz.getAnnotation(StructuredType.class);
+        return getSchema(st.namespace());
+    }
+
+    public void clearSchemas()
+    {
+        schemas.clear();
+    }
+
+    /**
+     * Return the schema corresponding to this nsURI and a prefix This method is here to treat metadata which embed more
+     * than one time the same schema It permit to retrieve a specific schema with its prefix
+     * 
+     * @param prefix
+     *            The prefix fixed in the schema wanted
+     * @param nsURI
+     *            The namespace URI corresponding to the schema wanted
+     * @return The Class Schema representation
+     */
+    public XMPSchema getSchema(String prefix, String nsURI)
+    {
+        Iterator<XMPSchema> it = getAllSchemas().iterator();
+        XMPSchema tmp;
+        while (it.hasNext())
+        {
+            tmp = it.next();
+            if (tmp.getNamespace().equals(nsURI) && tmp.getPrefix().equals(prefix))
+            {
+                return tmp;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Set a unspecialized schema
+     * 
+     * @param nsPrefix
+     *            The prefix wanted for the schema
+     * @param nsURI
+     *            The namespace URI wanted for the schema
+     * @return The schema added in order to work on it
+     */
+    public XMPSchema createAndAddDefaultSchema(String nsPrefix, String nsURI)
+    {
+        XMPSchema schem = new XMPSchema(this, nsURI, nsPrefix);
+        schem.setAboutAsSimple("");
+        addSchema(schem);
+        return schem;
+    }
+
+    /**
+     * Create and add a default PDFA Extension schema to this metadata This method return the created schema to enter
+     * information This PDFAExtension is created with all default namespaces used in PDFAExtensionSchema
+     * 
+     * @return PDFAExtension schema added in order to work on it
+     */
+    public PDFAExtensionSchema createAndAddPDFAExtensionSchemaWithDefaultNS()
+    {
+        PDFAExtensionSchema pdfAExt = new PDFAExtensionSchema(this);
+        pdfAExt.setAboutAsSimple("");
+        addSchema(pdfAExt);
+        return pdfAExt;
+    }
+
+    /**
+     * Create and add a default XMPRights schema to this metadata This method return the created schema to enter
+     * information
+     * 
+     * @return schema added in order to work on it
+     */
+    public XMPRightsManagementSchema createAndAddXMPRightsManagementSchema()
+    {
+        XMPRightsManagementSchema rights = new XMPRightsManagementSchema(this);
+        rights.setAboutAsSimple("");
+        addSchema(rights);
+        return rights;
+    }
+
+    /**
+     * Create and add a default PDFA Extension schema to this metadata This method return the created schema to enter
+     * information This PDFAExtension is created with specified list of namespaces
+     * 
+     * @param namespaces
+     *            Special namespaces list to use
+     * @return schema added in order to work on it
+     * @throws XmpSchemaException
+     *             If namespaces list not contains PDF/A Extension namespace URI
+     */
+    public PDFAExtensionSchema createAndAddPDFAExtensionSchemaWithNS(Map<String, String> namespaces)
+            throws XmpSchemaException
+    {
+        PDFAExtensionSchema pdfAExt = new PDFAExtensionSchema(this);
+        pdfAExt.setAboutAsSimple("");
+        addSchema(pdfAExt);
+        return pdfAExt;
+    }
+
+    /**
+     * Get the PDFA Extension schema This method return null if not found
+     * 
+     * @return The PDFAExtension schema or null if not declared
+     */
+    public PDFAExtensionSchema getPDFExtensionSchema()
+    {
+        return (PDFAExtensionSchema) getSchema(PDFAExtensionSchema.class);
+    }
+
+    /**
+     * Create and add a default PDFA Identification schema to this metadata This method return the created schema to
+     * enter information
+     * 
+     * @return schema added in order to work on it
+     */
+    public PDFAIdentificationSchema createAndAddPFAIdentificationSchema()
+    {
+        PDFAIdentificationSchema pdfAId = new PDFAIdentificationSchema(this);
+        pdfAId.setAboutAsSimple("");
+        addSchema(pdfAId);
+        return pdfAId;
+    }
+
+    /**
+     * Get the PDFA Identification schema This method return null if not found
+     * 
+     * @return The PDFAIdentificationSchema schema or null if not declared
+     */
+    public PDFAIdentificationSchema getPDFIdentificationSchema()
+    {
+        return (PDFAIdentificationSchema) getSchema(PDFAIdentificationSchema.class);
+    }
+
+    /**
+     * Create and add a default Dublin Core schema to this metadata This method return the created schema to enter
+     * information
+     * 
+     * @return schema added in order to work on it
+     */
+    public DublinCoreSchema createAndAddDublinCoreSchema()
+    {
+        DublinCoreSchema dc = new DublinCoreSchema(this);
+        dc.setAboutAsSimple("");
+        addSchema(dc);
+        return dc;
+    }
+
+    /**
+     * Create and add a default Basic Job Ticket schema to this metadata This method return the created schema to enter
+     * information
+     * 
+     * @return schema added in order to work on it
+     */
+    public XMPBasicJobTicketSchema createAndAddBasicJobTicketSchema()
+    {
+        XMPBasicJobTicketSchema sc = new XMPBasicJobTicketSchema(this);
+        sc.setAboutAsSimple("");
+        addSchema(sc);
+        return sc;
+    }
+
+    /**
+     * Get the Dublin Core schema This method return null if not found
+     * 
+     * @return The DublinCoreSchema schema or null if not declared
+     */
+    public DublinCoreSchema getDublinCoreSchema()
+    {
+        return (DublinCoreSchema) getSchema(DublinCoreSchema.class);
+    }
+
+    /**
+     * Get the Basic JOb Ticket Schema schema This method return null if not found
+     * 
+     * @return The XMPBasicJobTicketSchema schema or null if not declared
+     */
+    public XMPBasicJobTicketSchema getBasicJobTicketSchema()
+    {
+        return (XMPBasicJobTicketSchema) getSchema(XMPBasicJobTicketSchema.class);
+    }
+
+    /**
+     * Get the XMPRights schema This method return null if not found
+     * 
+     * @return The XMPRightsManagementSchema schema or null if not declared
+     */
+    public XMPRightsManagementSchema getXMPRightsManagementSchema()
+    {
+        return (XMPRightsManagementSchema) getSchema(XMPRightsManagementSchema.class);
+    }
+
+    /**
+     * Get the Photoshop schema This method return null if not found
+     * 
+     * @return The PhotoshopSchema schema or null if not declared
+     */
+    public PhotoshopSchema getPhotoshopSchema()
+    {
+        return (PhotoshopSchema) getSchema(PhotoshopSchema.PHOTOSHOPURI);
+    }
+
+    /**
+     * Create and add a XMP Basic schema to this metadata This method return the created schema to enter information
+     * 
+     * @return schema added in order to work on it
+     */
+    public XMPBasicSchema createAndAddXMPBasicSchema()
+    {
+        XMPBasicSchema xmpB = new XMPBasicSchema(this);
+        xmpB.setAboutAsSimple("");
+        addSchema(xmpB);
+        return xmpB;
+    }
+
+    /**
+     * Get the XMP Basic schema This method return null if not found
+     * 
+     * @return The XMPBasicSchema schema or null if not declared
+     */
+    public XMPBasicSchema getXMPBasicSchema()
+    {
+        return (XMPBasicSchema) getSchema(XMPBasicSchema.class);
+    }
+
+    /**
+     * Create and add a XMP Media Management schema to this metadata This method return the created schema to enter
+     * information
+     * 
+     * @return schema added in order to work on it
+     */
+    public XMPMediaManagementSchema createAndAddXMPMediaManagementSchema()
+    {
+        XMPMediaManagementSchema xmpMM = new XMPMediaManagementSchema(this);
+        xmpMM.setAboutAsSimple("");
+        addSchema(xmpMM);
+        return xmpMM;
+    }
+
+    /***
+     * create and add Photoshop Schema to this metadata. This method return the created schema to enter information
+     * 
+     * @return
+     */
+    public PhotoshopSchema createAndAddPhotoshopSchema()
+    {
+        PhotoshopSchema photoshop = new PhotoshopSchema(this);
+        photoshop.setAboutAsSimple("");
+        addSchema(photoshop);
+        return photoshop;
+    }
+
+    /**
+     * Get the XMP Media Management schema This method return null if not found
+     * 
+     * @return The XMPMediaManagementSchema schema or null if not declared
+     */
+    public XMPMediaManagementSchema getXMPMediaManagementSchema()
+    {
+        return (XMPMediaManagementSchema) getSchema(XMPMediaManagementSchema.class);
+    }
+
+    /**
+     * Create and add an Adobe PDF schema to this metadata This method return the created schema to enter information
+     * 
+     * @return schema added in order to work on it
+     */
+    public AdobePDFSchema createAndAddAdobePDFSchema()
+    {
+        AdobePDFSchema pdf = new AdobePDFSchema(this);
+        pdf.setAboutAsSimple("");
+        addSchema(pdf);
+        return pdf;
+    }
+
+    /**
+     * Get the Adobe PDF schema This method return null if not found
+     * 
+     * @return The AdobePDFSchema schema or null if not declared
+     */
+    public AdobePDFSchema getAdobePDFSchema()
+    {
+        return (AdobePDFSchema) getSchema(AdobePDFSchema.class);
+    }
+
+    /**
+     * Add a schema to the current structure
+     * 
+     * @param obj
+     *            the schema to add
+     */
+    public void addSchema(XMPSchema obj)
+    {
+        schemas.add(obj);
+    }
+
+    /**
+     * Remove a schema
+     * 
+     * @param schema
+     *            The schema to remove
+     */
+    public void removeSchema(XMPSchema schema)
+    {
+        schemas.remove(schema);
+    }
 
 }

Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XmpConstants.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XmpConstants.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XmpConstants.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XmpConstants.java Wed Mar  6 15:57:44 2013
@@ -1,4 +1,4 @@
- /*****************************************************************************
+/*****************************************************************************
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -20,40 +20,42 @@
 
 package org.apache.xmpbox;
 
-public final class XmpConstants {
+public final class XmpConstants
+{
+
+    public static final String RDF_NAMESPACE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+
+    public static final String DEFAULT_XPACKET_BEGIN = "\uFEFF";
+
+    public static final String DEFAULT_XPACKET_ID = "W5M0MpCehiHzreSzNTczkc9d";
+
+    public static final String DEFAULT_XPACKET_ENCODING = "UTF-8";
+
+    public static final String DEFAULT_XPACKET_BYTES = null;
+
+    public static final String DEFAULT_XPACKET_END = "w";
+
+    public static final String DEFAULT_RDF_PREFIX = "rdf";
+
+    public static final String DEFAULT_RDF_LOCAL_NAME = "RDF";
+
+    public static final String LIST_NAME = "li";
+
+    public static final String LANG_NAME = "lang";
+
+    public static final String ABOUT_NAME = "about";
+
+    public static final String DESCRIPTION_NAME = "Description";
+
+    public static final String RESOURCE_NAME = "Resource";
+
+    public static final String PARSE_TYPE = "parseType";
+
+    public static final String X_DEFAULT = "x-default";
+
+    private XmpConstants()
+    {
+        // hide constructor
+    }
 
-	public static final String RDF_NAMESPACE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-	
-	public static final String DEFAULT_XPACKET_BEGIN = "\uFEFF";
-	
-	public static final String DEFAULT_XPACKET_ID = "W5M0MpCehiHzreSzNTczkc9d";
-	
-	public static final String DEFAULT_XPACKET_ENCODING = "UTF-8";
-	
-	public static final String DEFAULT_XPACKET_BYTES = null;
-	
-	public static final String DEFAULT_XPACKET_END = "w";
-	
-	public static final String DEFAULT_RDF_PREFIX = "rdf";
-
-	public static final String DEFAULT_RDF_LOCAL_NAME = "RDF";
-	
-	public static final String LIST_NAME = "li";
-	
-	public static final String LANG_NAME = "lang";
-	
-	public static final String ABOUT_NAME = "about";
-	
-	public static final String DESCRIPTION_NAME = "Description";
-	
-	public static final String RESOURCE_NAME = "Resource";
-	
-	public static final String PARSE_TYPE = "parseType";
-	
-	public static final String X_DEFAULT = "x-default";
-
-	private XmpConstants () {
-		// hide constructor
-	}
-	
 }

Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/AdobePDFSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/AdobePDFSchema.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/AdobePDFSchema.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/AdobePDFSchema.java Wed Mar  6 15:57:44 2013
@@ -35,183 +35,204 @@ import org.apache.xmpbox.type.Types;
  * @author a183132
  * 
  */
-@StructuredType(preferedPrefix="pdf",namespace="http://ns.adobe.com/pdf/1.3/")
-public class AdobePDFSchema extends XMPSchema {
-
-	@PropertyType(type = Types.Text, card = Cardinality.Simple)
-	public static final String KEYWORDS = "Keywords";
-
-	@PropertyType(type = Types.Text, card = Cardinality.Simple)
-	public static final String PDF_VERSION = "PDFVersion";
-
-	@PropertyType(type = Types.Text, card = Cardinality.Simple)
-	public static final String PRODUCER = "Producer";
-
-	/**
-	 * Constructor of an Adobe PDF schema with preferred prefix
-	 * 
-	 * @param metadata
-	 *            The metadata to attach this schema
-	 */
-	public AdobePDFSchema(XMPMetadata metadata) {
-		super(metadata);
-	}
-
-	/**
-	 * Constructor of an Adobe PDF schema with specified prefix
-	 * 
-	 * @param metadata
-	 *            The metadata to attach this schema
-	 * @param ownPrefix
-	 *            The prefix to assign
-	 */
-	public AdobePDFSchema(XMPMetadata metadata, String ownPrefix) {
-		super(metadata, ownPrefix);
-	}
-
-	/**
-	 * Set the PDF keywords
-	 * 
-	 * @param value
-	 *            Value to set
-	 */
-	public void setKeywords(String value) {
-		TextType keywords;
-		keywords = createTextType ( KEYWORDS, value);
-		addProperty(keywords);
-	}
-
-	/**
-	 * Set the PDF keywords
-	 * 
-	 * @param keywords
-	 *            Property to set
-	 */
-	public void setKeywordsProperty(TextType keywords) {
-		addProperty(keywords);
-	}
-
-	/**
-	 * Set the PDFVersion
-	 * 
-	 * @param value
-	 *            Value to set
-	 */
-	public void setPDFVersion(String value) {
-		TextType version;
-		version = createTextType ( PDF_VERSION, value);
-		addProperty(version);
-
-	}
-
-	/**
-	 * Set the PDFVersion
-	 * 
-	 * @param version
-	 *            Property to set
-	 */
-	public void setPDFVersionProperty(TextType version) {
-		addProperty(version);
-	}
-
-	/**
-	 * Set the PDFProducer
-	 * 
-	 * @param value
-	 *            Value to set
-	 */
-	public void setProducer(String value) {
-		TextType producer;
-		producer = createTextType ( PRODUCER, value);
-		addProperty(producer);
-	}
-
-	/**
-	 * Set the PDFProducer
-	 * 
-	 * @param producer
-	 *            Property to set
-	 */
-	public void setProducerProperty(TextType producer) {
-		addProperty(producer);
-	}
-
-	/**
-	 * Give the PDF Keywords property
-	 * 
-	 * @return The property object
-	 */
-	public TextType getKeywordsProperty() {
-		AbstractField tmp = getProperty(KEYWORDS);
-		if (tmp instanceof TextType) {
-			return (TextType) tmp;
-		}
-		return null;
-	}
-
-	/**
-	 * Give the PDF Keywords property value (string)
-	 * 
-	 * @return The property value
-	 */
-	public String getKeywords() {
-		AbstractField tmp = getProperty(KEYWORDS);
-		if (tmp instanceof TextType) {
-			return ((TextType) tmp).getStringValue();
-		}
-		return null;
-	}
-
-	/**
-	 * Give the PDFVersion property
-	 * 
-	 * @return The property object
-	 */
-	public TextType getPDFVersionProperty() {
-		AbstractField tmp = getProperty(PDF_VERSION);
-		if (tmp instanceof TextType) {
-			return (TextType) tmp;
-		}
-		return null;
-	}
-
-	/**
-	 * Give the PDFVersion property value (string)
-	 * 
-	 * @return The property value
-	 */
-	public String getPDFVersion() {
-		AbstractField tmp = getProperty(PDF_VERSION);
-		if (tmp instanceof TextType) {
-			return ((TextType) tmp).getStringValue();
-		}
-		return null;
-	}
-
-	/**
-	 * Give the producer property
-	 * 
-	 * @return The property object
-	 */
-	public TextType getProducerProperty() {
-		AbstractField tmp = getProperty(PRODUCER);
-		if (tmp instanceof TextType) {
-			return (TextType) tmp;
-		}
-		return null;
-	}
-
-	/**
-	 * Give the producer property value (string)
-	 * 
-	 * @return The property value
-	 */
-	public String getProducer() {
-		AbstractField tmp = getProperty(PRODUCER);
-		if (tmp instanceof TextType) {
-			return ((TextType) tmp).getStringValue();
-		}
-		return null;
-	}
+@StructuredType(preferedPrefix = "pdf", namespace = "http://ns.adobe.com/pdf/1.3/")
+public class AdobePDFSchema extends XMPSchema
+{
+
+    @PropertyType(type = Types.Text, card = Cardinality.Simple)
+    public static final String KEYWORDS = "Keywords";
+
+    @PropertyType(type = Types.Text, card = Cardinality.Simple)
+    public static final String PDF_VERSION = "PDFVersion";
+
+    @PropertyType(type = Types.Text, card = Cardinality.Simple)
+    public static final String PRODUCER = "Producer";
+
+    /**
+     * Constructor of an Adobe PDF schema with preferred prefix
+     * 
+     * @param metadata
+     *            The metadata to attach this schema
+     */
+    public AdobePDFSchema(XMPMetadata metadata)
+    {
+        super(metadata);
+    }
+
+    /**
+     * Constructor of an Adobe PDF schema with specified prefix
+     * 
+     * @param metadata
+     *            The metadata to attach this schema
+     * @param ownPrefix
+     *            The prefix to assign
+     */
+    public AdobePDFSchema(XMPMetadata metadata, String ownPrefix)
+    {
+        super(metadata, ownPrefix);
+    }
+
+    /**
+     * Set the PDF keywords
+     * 
+     * @param value
+     *            Value to set
+     */
+    public void setKeywords(String value)
+    {
+        TextType keywords;
+        keywords = createTextType(KEYWORDS, value);
+        addProperty(keywords);
+    }
+
+    /**
+     * Set the PDF keywords
+     * 
+     * @param keywords
+     *            Property to set
+     */
+    public void setKeywordsProperty(TextType keywords)
+    {
+        addProperty(keywords);
+    }
+
+    /**
+     * Set the PDFVersion
+     * 
+     * @param value
+     *            Value to set
+     */
+    public void setPDFVersion(String value)
+    {
+        TextType version;
+        version = createTextType(PDF_VERSION, value);
+        addProperty(version);
+
+    }
+
+    /**
+     * Set the PDFVersion
+     * 
+     * @param version
+     *            Property to set
+     */
+    public void setPDFVersionProperty(TextType version)
+    {
+        addProperty(version);
+    }
+
+    /**
+     * Set the PDFProducer
+     * 
+     * @param value
+     *            Value to set
+     */
+    public void setProducer(String value)
+    {
+        TextType producer;
+        producer = createTextType(PRODUCER, value);
+        addProperty(producer);
+    }
+
+    /**
+     * Set the PDFProducer
+     * 
+     * @param producer
+     *            Property to set
+     */
+    public void setProducerProperty(TextType producer)
+    {
+        addProperty(producer);
+    }
+
+    /**
+     * Give the PDF Keywords property
+     * 
+     * @return The property object
+     */
+    public TextType getKeywordsProperty()
+    {
+        AbstractField tmp = getProperty(KEYWORDS);
+        if (tmp instanceof TextType)
+        {
+            return (TextType) tmp;
+        }
+        return null;
+    }
+
+    /**
+     * Give the PDF Keywords property value (string)
+     * 
+     * @return The property value
+     */
+    public String getKeywords()
+    {
+        AbstractField tmp = getProperty(KEYWORDS);
+        if (tmp instanceof TextType)
+        {
+            return ((TextType) tmp).getStringValue();
+        }
+        return null;
+    }
+
+    /**
+     * Give the PDFVersion property
+     * 
+     * @return The property object
+     */
+    public TextType getPDFVersionProperty()
+    {
+        AbstractField tmp = getProperty(PDF_VERSION);
+        if (tmp instanceof TextType)
+        {
+            return (TextType) tmp;
+        }
+        return null;
+    }
+
+    /**
+     * Give the PDFVersion property value (string)
+     * 
+     * @return The property value
+     */
+    public String getPDFVersion()
+    {
+        AbstractField tmp = getProperty(PDF_VERSION);
+        if (tmp instanceof TextType)
+        {
+            return ((TextType) tmp).getStringValue();
+        }
+        return null;
+    }
+
+    /**
+     * Give the producer property
+     * 
+     * @return The property object
+     */
+    public TextType getProducerProperty()
+    {
+        AbstractField tmp = getProperty(PRODUCER);
+        if (tmp instanceof TextType)
+        {
+            return (TextType) tmp;
+        }
+        return null;
+    }
+
+    /**
+     * Give the producer property value (string)
+     * 
+     * @return The property value
+     */
+    public String getProducer()
+    {
+        AbstractField tmp = getProperty(PRODUCER);
+        if (tmp instanceof TextType)
+        {
+            return ((TextType) tmp).getStringValue();
+        }
+        return null;
+    }
 
 }