You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2011/07/24 15:57:54 UTC

svn commit: r1150371 [1/8] - in /pdfbox/trunk/xmpbox: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/padaf/ src/main/java/org/apache/padaf/xmpbox/ src/main/java/org/apache/padaf/xmpbox/parser/ src...

Author: lehmi
Date: Sun Jul 24 13:57:39 2011
New Revision: 1150371

URL: http://svn.apache.org/viewvc?rev=1150371&view=rev
Log:
PDFBOX-1056: added xmpbox source code

Added:
    pdfbox/trunk/xmpbox/
    pdfbox/trunk/xmpbox/pom.xml   (with props)
    pdfbox/trunk/xmpbox/src/
    pdfbox/trunk/xmpbox/src/main/
    pdfbox/trunk/xmpbox/src/main/java/
    pdfbox/trunk/xmpbox/src/main/java/org/
    pdfbox/trunk/xmpbox/src/main/java/org/apache/
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFAExtensionSchemaDescriptionException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFExtensionSchemaHelper.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/CreateXMPMetadataException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/SaveMetadataHelper.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/TransformException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/DateConverter.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/NSMapping.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/PropMapping.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMLPropertiesDescriptionManager.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMLUtil.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMLValueTypeDescriptionManager.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPDocumentBuilder.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPSchemaFactory.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpExpectedRdfAboutAttribute.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpInitialXPacketParsingException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpParsingException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpPropertyFormatException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpPropertyType.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpRequiredPropertyException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpSchemaException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpUnexpectedElementException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpUnexpectedElementQualifiedNameException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpUnexpectedNamespacePrefixException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpUnexpectedNamespaceURIException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpUnexpectedTypeException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpUnknownPropertyException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpUnknownPropertyTypeException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpUnknownSchemaException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpUnknownValueTypeException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpXpacketEndException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/AdobePDFSchema.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/DublinCoreSchema.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAExtensionSchema.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAFieldDescription.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAIdentificationSchema.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAPropertyDescription.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAValueTypeDescription.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PropertyAttributesAnnotation.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PropertyExtensionDefinition.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PropertyType.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/SchemaDescription.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/SchemaExtensionDefinition.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicSchema.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementSchema.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPRightsManagementSchema.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchema.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractField.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractSimpleProperty.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Attribute.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/BadFieldValueException.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/BooleanType.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ComplexProperty.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ComplexPropertyContainer.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/DateType.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Elementable.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/FieldDescription.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/IntegerType.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PropertyDescription.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/RealType.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TextType.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ThumbnailType.java   (with props)
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ValueTypeDescription.java   (with props)
    pdfbox/trunk/xmpbox/src/test/
    pdfbox/trunk/xmpbox/src/test/java/
    pdfbox/trunk/xmpbox/src/test/java/org/
    pdfbox/trunk/xmpbox/src/test/java/org/apache/
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/BuildPDFAExtensionSchemaDescriptionTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/DoubleSameTypeSchemaTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/SaveMetadataHelperTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/XMPMetaDataTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/DeserializationTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/PropMappingTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/XMLPropertiesDescriptionManagerTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/XMLValueTypeDescriptionManagerTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractXMPSchemaTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AdobePDFErrorsTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AdobePDFTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/DublinCoreTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/PDFAExtensionTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/PDFAIdentificationOthersTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/PDFAIdentificationTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/PDFAPropertyDescriptionTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/PDFAValueTypeDescriptionTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPBasicTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XmpRightsSchemaTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AttributeTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/ComplexMetadataPropertyTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/SimpleMetadataPropertyTest.java   (with props)
    pdfbox/trunk/xmpbox/src/test/resources/
    pdfbox/trunk/xmpbox/src/test/resources/org/
    pdfbox/trunk/xmpbox/src/test/resources/org/apache/
    pdfbox/trunk/xmpbox/src/test/resources/org/apache/padaf/
    pdfbox/trunk/xmpbox/src/test/resources/org/apache/padaf/xmpbox/
    pdfbox/trunk/xmpbox/src/test/resources/org/apache/padaf/xmpbox/parser/
    pdfbox/trunk/xmpbox/src/test/resources/org/apache/padaf/xmpbox/parser/AltBagSeqTest.xml   (with props)
    pdfbox/trunk/xmpbox/src/test/resources/org/apache/padaf/xmpbox/parser/ThumbisartorStyle.xml   (with props)
    pdfbox/trunk/xmpbox/src/test/resources/org/apache/padaf/xmpbox/parser/isartorStyleXMPOK.xml   (with props)
    pdfbox/trunk/xmpbox/src/test/resources/org/apache/padaf/xmpbox/propertiesDescription.xml   (with props)
    pdfbox/trunk/xmpbox/src/test/resources/org/apache/padaf/xmpbox/valueTypeDescription.xml   (with props)

Added: pdfbox/trunk/xmpbox/pom.xml
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/pom.xml?rev=1150371&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/pom.xml (added)
+++ pdfbox/trunk/xmpbox/pom.xml Sun Jul 24 13:57:39 2011
@@ -0,0 +1,143 @@
+<!--
+  
+        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
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>xmpbox</artifactId>
+	<groupId>org.apache.pdfbox</groupId>
+	<name>xmpbox</name>
+	<description>xmpbox is an API used to parse,validate and create objects based on XMP Contents.</description>
+
+	<parent>
+		<groupId>org.apache.pdfbox</groupId>
+		<artifactId>padaf-parent</artifactId>
+		<version>0.6.2-SNAPSHOT</version>
+		<relativePath>../padaf-parent</relativePath>
+	</parent>
+
+	<properties>
+		<compileSource>1.6</compileSource>
+		<javacPath>${user.javac6}</javacPath>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.7</version>
+			<scope>test</scope>
+		</dependency>
+
+
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>1.4</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.thoughtworks.xstream</groupId>
+			<artifactId>xstream</artifactId>
+			<version>1.3.1</version>
+		</dependency>
+
+	</dependencies>
+
+
+	<reporting>
+		<plugins>
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>taglist-maven-plugin</artifactId>
+				<version>2.4</version>
+				<configuration>
+					<encoding>UTF-8</encoding>
+					<sourceFileLocale>en</sourceFileLocale>
+					<emptyComments>false</emptyComments>
+					<tagListOptions>
+						<tagClasses>
+							<tagClass>
+								<displayName>TODO List</displayName>
+								<tags>
+									<tag>
+										<matchString>TODO</matchString>
+										<matchType>exact</matchType>
+									</tag>
+									<tag>
+										<matchString>FIXME</matchString>
+										<matchType>exact</matchType>
+									</tag>
+								</tags>
+							</tagClass>
+						</tagClasses>
+					</tagListOptions>
+				</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>
+				<artifactId>cobertura-maven-plugin</artifactId>
+				<version>2.3</version>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-report-plugin</artifactId>
+				<version>2.6</version>
+				<configuration>
+					<showSuccess>true</showSuccess>
+					<aggregate>true</aggregate>
+					<outputDirectory>${project.reporting.outputDirectory}/surefire-report</outputDirectory>
+				</configuration>
+				<reportSets>
+					<reportSet>
+						<id />
+					</reportSet>
+				</reportSets>
+			</plugin>
+
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>findbugs-maven-plugin</artifactId>
+				<version>2.0.1</version>
+				<configuration>
+					<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
+				</configuration>
+			</plugin>
+		</plugins>
+
+
+
+	</reporting>
+
+
+</project>

Propchange: pdfbox/trunk/xmpbox/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFAExtensionSchemaDescriptionException.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFAExtensionSchemaDescriptionException.java?rev=1150371&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFAExtensionSchemaDescriptionException.java (added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFAExtensionSchemaDescriptionException.java Sun Jul 24 13:57:39 2011
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * 
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ ****************************************************************************/
+
+package org.apache.padaf.xmpbox;
+
+/**
+ * Throws this exception when building PDF/A Extension schema description failed
+ * 
+ * @author a183132
+ * 
+ */
+public class BuildPDFAExtensionSchemaDescriptionException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -7873503174613405379L;
+
+	/**
+	 * Create an instance of BuildPDFAExtensionSchemaDescriptionException
+	 * 
+	 * @param message
+	 *            a description of the encountered problem
+	 */
+	public BuildPDFAExtensionSchemaDescriptionException(String message) {
+		super(message);
+
+	}
+
+	/**
+	 * Create an instance of BuildPDFAExtensionSchemaDescriptionException
+	 * 
+	 * @param message
+	 *            a description of the encountered problem
+	 * @param cause
+	 *            the cause of the exception
+	 */
+	public BuildPDFAExtensionSchemaDescriptionException(String message,
+			Throwable cause) {
+		super(message, cause);
+
+	}
+
+}

Propchange: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFAExtensionSchemaDescriptionException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFExtensionSchemaHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFExtensionSchemaHelper.java?rev=1150371&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFExtensionSchemaHelper.java (added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFExtensionSchemaHelper.java Sun Jul 24 13:57:39 2011
@@ -0,0 +1,235 @@
+/*****************************************************************************
+ * 
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ ****************************************************************************/
+
+package org.apache.padaf.xmpbox;
+
+import java.lang.reflect.Field;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.padaf.xmpbox.parser.XMLPropertiesDescriptionManager;
+import org.apache.padaf.xmpbox.parser.XMLValueTypeDescriptionManager;
+import org.apache.padaf.xmpbox.schema.PDFAExtensionSchema;
+import org.apache.padaf.xmpbox.schema.PropertyExtensionDefinition;
+import org.apache.padaf.xmpbox.schema.PropertyType;
+import org.apache.padaf.xmpbox.schema.SchemaDescription;
+import org.apache.padaf.xmpbox.schema.SchemaExtensionDefinition;
+import org.apache.padaf.xmpbox.schema.XMPSchema;
+import org.apache.padaf.xmpbox.type.BadFieldValueException;
+import org.apache.padaf.xmpbox.type.PropertyDescription;
+import org.apache.padaf.xmpbox.type.ValueTypeDescription;
+
+
+/**
+ * 
+ * This class help you to build a PDF/A extension schema description thanks to
+ * annotation present in annotations included in the schema class representation
+ * 
+ * @author a183132
+ * 
+ */
+public class BuildPDFExtensionSchemaHelper {
+
+	/**
+	 * According to check-style, Utility classes should not have a public or
+	 * default constructor.
+	 */
+	protected BuildPDFExtensionSchemaHelper() {
+	};
+
+	/**
+	 * Build automatically Schema description with annotations and data present
+	 * in schema class and include it in the PDF/A Extension Schema NOTE : If
+	 * metadata given not contains a PDF/A Extension Schema, this function add
+	 * one automatically.
+	 * 
+	 * @param metadata
+	 *            The concerned metadata in which include Schema Description
+	 *            inside the PDF/A Extension Schema
+	 * @param schema
+	 *            The specific schema concerned by the description building
+	 * @throws BuildPDFAExtensionSchemaDescriptionException
+	 *             When failed to load or treat data from XML Descriptions files
+	 *             or in Schema Class
+	 */
+	public static void includePDFAExtensionDefinition(XMPMetadata metadata,
+			XMPSchema schema)
+			throws BuildPDFAExtensionSchemaDescriptionException {
+		PDFAExtensionSchema ext = metadata.getPDFExtensionSchema();
+		Class<? extends XMPSchema> classSchem = schema.getClass();
+		if (ext == null) {
+			ext = metadata.createAndAddPDFAExtensionSchemaWithDefaultNS();
+		}
+		Field[] fields;
+		fields = classSchem.getFields();
+		SchemaExtensionDefinition schemDefAnnot;
+		PropertyExtensionDefinition propExtDefAnnot;
+		PropertyType propTypeAnnot;
+		String propName = null;
+		String propDesc;
+		List<PropertyDescription> xmlPropDesc = null;
+		if (classSchem.isAnnotationPresent(SchemaExtensionDefinition.class)) {
+			schemDefAnnot = classSchem
+					.getAnnotation(SchemaExtensionDefinition.class);
+			// Try to find and load XML Properties Descriptions file path
+			if (!schemDefAnnot.property_descriptions().equals("")) {
+				XMLPropertiesDescriptionManager propManag = new XMLPropertiesDescriptionManager();
+				propManag.loadListFromXML(classSchem, schemDefAnnot
+						.property_descriptions());
+				xmlPropDesc = propManag.getPropertiesDescriptionList();
+			}
+			SchemaDescription desc = ext.createSchemaDescription();
+			desc.setSchemaValue(schemDefAnnot.schema());
+			desc.setNameSpaceURIValue(schema.getNamespaceValue());
+			desc.setPrefixValue(schema.getPrefix());
+			ext.addSchemaDescription(desc);
+			// Try to find and load XML ValueType Description file path
+			if (!schemDefAnnot.valueType_description().equals("")) {
+				XMLValueTypeDescriptionManager valTypesManag = new XMLValueTypeDescriptionManager();
+				valTypesManag.loadListFromXML(classSchem, schemDefAnnot
+						.valueType_description());
+				addValueTypesToSchem(metadata, desc, valTypesManag
+						.getValueTypesDescriptionList());
+			}
+			for (Field field : fields) {
+				if (field
+						.isAnnotationPresent(PropertyExtensionDefinition.class)
+						&& field.isAnnotationPresent(PropertyType.class)) {
+					try {
+						propName = (String) field.get(propName);
+					} catch (Exception e) {
+						throw propertyDescriptionError(
+								classSchem.getName(),
+								field.getName(),
+								"Couldn't read content, please check accessibility and declaration of field associated",
+								e.getCause());
+					}
+					propExtDefAnnot = field
+							.getAnnotation(PropertyExtensionDefinition.class);
+					propTypeAnnot = field.getAnnotation(PropertyType.class);
+					try {
+						if (xmlPropDesc != null) {
+							Iterator<PropertyDescription> it = xmlPropDesc
+									.iterator();
+							PropertyDescription tmp;
+							propDesc = null;
+							while (it.hasNext() && (propDesc == null)) {
+								tmp = it.next();
+								if (tmp.getPropertyName().equals(propName)) {
+									propDesc = tmp.getDescription();
+								}
+							}
+
+						} else {
+							propDesc = propExtDefAnnot.propertyDescription();
+						}
+						if ((propDesc == null) || propDesc.equals("")) {
+							propDesc = "Not documented description";
+						}
+						desc.addProperty(propName,
+								propTypeAnnot.propertyType(), propExtDefAnnot
+										.propertyCategory(), propDesc);
+					} catch (BadFieldValueException e) {
+						throw propertyDescriptionError(classSchem.getName(),
+								propName, "Wrong value for property Category",
+								e.getCause());
+					}
+				}
+			}
+		} else {
+			throw schemaDescriptionError(classSchem.getName(),
+					"Couldn't find SchemaExtensionDefinition annotation.");
+		}
+		/*
+		 * try { SaveMetadataHelper.serialize(ext, System.out); } catch
+		 * (TransformException e) { e.printStackTrace(); }
+		 */
+	}
+
+	/**
+	 * Add Value Types description which must be associated to the Schema
+	 * Description
+	 * 
+	 * @param metadata
+	 *            Metadata concerned by this Schema Declaration
+	 * @param desc
+	 *            The Description Schema under construction
+	 * @param vTypes
+	 *            The Value Types list which must be added
+	 */
+	protected static void addValueTypesToSchem(XMPMetadata metadata,
+			SchemaDescription desc, List<ValueTypeDescription> vTypes) {
+		for (ValueTypeDescription valueTypeDescription : vTypes) {
+			desc.addValueType(valueTypeDescription.getType(),
+					valueTypeDescription.getNamespaceURI(),
+					valueTypeDescription.getPrefix(), valueTypeDescription
+							.getDescription(), valueTypeDescription
+							.getPDFAFieldsAssocied(metadata));
+
+		}
+	}
+
+	/**
+	 * An helper to build a formated error message for schema Description errors
+	 * 
+	 * @param classSchem
+	 *            Name of schema where errors are occured
+	 * @param details
+	 *            Error details
+	 * @return Exception with formated error message
+	 */
+	protected static BuildPDFAExtensionSchemaDescriptionException schemaDescriptionError(
+			String classSchem, String details) {
+		StringBuilder sb = new StringBuilder(80);
+		sb
+				.append(
+						"Error while building PDF/A Extension Schema description for '")
+				.append(classSchem).append("' schema : ").append(details);
+		return new BuildPDFAExtensionSchemaDescriptionException(sb.toString());
+	}
+
+	/**
+	 * An helper to build a formated error message for properties Description
+	 * errors
+	 * 
+	 * @param classSchem
+	 *            Name of schema which include the bad property description
+	 * @param propName
+	 *            Name of property where a problem has occured
+	 * @param details
+	 *            Error details
+	 * @param e
+	 *            Original thrown Exception
+	 * @return Exception with formated error message
+	 */
+	protected static BuildPDFAExtensionSchemaDescriptionException propertyDescriptionError(
+			String classSchem, String propName, String details, Throwable e) {
+		StringBuilder sb = new StringBuilder(80);
+		sb
+				.append(
+						"Error while building PDF/A Extension Schema description for '")
+				.append(classSchem).append("' schema, Failed to treat '")
+				.append(propName).append("' property : ").append(details);
+		return new BuildPDFAExtensionSchemaDescriptionException(sb.toString(),
+				e);
+	}
+
+}

Propchange: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/BuildPDFExtensionSchemaHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/CreateXMPMetadataException.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/CreateXMPMetadataException.java?rev=1150371&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/CreateXMPMetadataException.java (added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/CreateXMPMetadataException.java Sun Jul 24 13:57:39 2011
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * 
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ ****************************************************************************/
+package org.apache.padaf.xmpbox;
+
+import org.apache.padaf.xmpbox.parser.XmpParsingException;
+
+/**
+ * This exception is thrown when a problem is encountered during the creation of
+ * XMPMetadata Document
+ * 
+ * @author a183132
+ * 
+ */
+public class CreateXMPMetadataException extends XmpParsingException {
+
+	/**
+	 * serial version id
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Create an instance of CreateXMPMetadataException
+	 * 
+	 * @param message
+	 *            a description of the encountered problem
+	 * @param cause
+	 *            the cause of the exception
+	 */
+	public CreateXMPMetadataException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	/**
+	 * Create an instance of CreateXMPMetadataException
+	 * 
+	 * @param message
+	 *            a description of the encountered problem
+	 */
+	public CreateXMPMetadataException(String message) {
+		super(message);
+	}
+
+}

Propchange: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/CreateXMPMetadataException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/SaveMetadataHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/SaveMetadataHelper.java?rev=1150371&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/SaveMetadataHelper.java (added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/SaveMetadataHelper.java Sun Jul 24 13:57:39 2011
@@ -0,0 +1,211 @@
+/*****************************************************************************
+ * 
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ ****************************************************************************/
+
+package org.apache.padaf.xmpbox;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.xml.transform.TransformerException;
+
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.padaf.xmpbox.parser.XMLUtil;
+import org.apache.padaf.xmpbox.schema.XMPSchema;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.ProcessingInstruction;
+
+/**
+ * This class represents tools to save metadata and schema in serialized way
+ * (RDF/XML Format)
+ * 
+ * @author a183132
+ * 
+ */
+public class SaveMetadataHelper {
+
+	/**
+	 * According to check-style, Utility classes should not have a public or
+	 * default constructor.
+	 */
+	protected SaveMetadataHelper() {
+	};
+
+	/**
+	 * Prepare XMP Saving Put data necessary to make a well-formed XMP
+	 * 
+	 * @param metadata
+	 *            metadata concerned by the serialization processing
+	 * @param intoXPacket
+	 *            true if Processing instruction must be embedded
+	 * @return The DOM Document which will represent the serialized metadata
+	 */
+	protected static Document prepareSaving(XMPMetadata metadata,
+			boolean intoXPacket) {
+		Document newdoc = (Document) metadata.getFuturOwner().cloneNode(true);
+		if (intoXPacket) {
+			ProcessingInstruction beginXPacket = newdoc
+					.createProcessingInstruction("xpacket", "begin=\""
+							+ metadata.getXpacketBegin() + "\" id=\""
+							+ metadata.getXpacketId() + "\"");
+			newdoc.appendChild(beginXPacket);
+		}
+
+		Element xmpMeta = newdoc.createElementNS("adobe:ns:meta/", "x:xmpmeta");
+		xmpMeta.setAttributeNS(XMPSchema.NS_NAMESPACE, "xmlns:x",
+				"adobe:ns:meta/");
+
+		newdoc.appendChild(xmpMeta);
+		Element elem = (Element) metadata.getContainerElement().cloneNode(true);
+		newdoc.adoptNode(elem);
+		xmpMeta.appendChild(elem);
+
+		if (intoXPacket) {
+			ProcessingInstruction endXPacket = newdoc
+					.createProcessingInstruction("xpacket", metadata
+							.getEndXPacket());
+			newdoc.appendChild(endXPacket);
+		}
+		return newdoc;
+	}
+
+	/**
+	 * Serialize metadata into an output stream with XPacket PI
+	 * 
+	 * @param metadata
+	 *            Metadata concerned by the serialization processing
+	 * @param os
+	 *            Stream to save serialized metadata
+	 * @throws TransformException
+	 *             When couldn't parse data to XML/RDF
+	 */
+	public static void serialize(XMPMetadata metadata, OutputStream os)
+			throws TransformException {
+		serialize(metadata, true, os);
+
+	}
+
+	/**
+	 * Serialize metadata into an output stream
+	 * 
+	 * @param metadata
+	 *            Metadata concerned by the serialization processing
+	 * @param intoXPacket
+	 *            True to put XPacket Processing Information
+	 * @param os
+	 *            Stream to save serialized metadata
+	 * @throws TransformException
+	 *             When couldn't parse data to XML/RDF
+	 */
+	public static void serialize(XMPMetadata metadata, boolean intoXPacket,
+			OutputStream os) throws TransformException {
+		Document doc = prepareSaving(metadata, intoXPacket);
+		try {
+			XMLUtil.save(doc, os, "UTF-8");
+		} catch (TransformerException e) {
+			throw new TransformException("Failed to parse defined XMP");
+		}
+
+	}
+
+	/**
+	 * Serialize metadata into the byte array returned
+	 * 
+	 * @param metadata
+	 *            Metadata concerned by the serialization processing
+	 * @param intoXPacket
+	 *            True to put XPacket Processing Information
+	 * @return ByteArray which contains serialized metadata
+	 * @throws TransformException
+	 *             When couldn't parse data to XML/RDF
+	 */
+	public static byte[] serialize(XMPMetadata metadata, boolean intoXPacket)
+			throws TransformException {
+		ByteArrayOutputStream bos = new ByteArrayOutputStream();
+		serialize(metadata, intoXPacket, bos);
+		IOUtils.closeQuietly(bos);
+		return bos.toByteArray();
+	}
+
+	/**
+	 * Serialize metadata with XPacket PI into the byte array returned
+	 * 
+	 * @param metadata
+	 *            Metadata concerned by the serialization processing
+	 * @return ByteArray which contains serialized metadata
+	 * @throws TransformException
+	 *             When couldn't parse data to XML/RDF
+	 */
+	public static byte[] serialize(XMPMetadata metadata)
+			throws TransformException {
+		return serialize(metadata, true);
+	}
+
+	/**
+	 * Serialize a schema into an Output stream
+	 * 
+	 * @param schema
+	 *            Schema concerned by the serialization processing
+	 * @param os
+	 *            Stream to save serialized schema
+	 * @throws TransformException
+	 *             When couldn't parse data to XML/RDF
+	 */
+	public static void serialize(XMPSchema schema, OutputStream os)
+			throws TransformException {
+		try {
+			Document doc = XMLUtil.newDocument();
+			Element rdf = doc.createElementNS(
+					"http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:RDF");
+			Node schemContent = schema.getElement().cloneNode(true);
+			doc.adoptNode(schemContent);
+			rdf.appendChild(schemContent);
+			XMLUtil.save(rdf, os, "UTF-8");
+		} catch (TransformerException e) {
+			throw new TransformException("Failed to parse defined XMP");
+		} catch (IOException e) {
+			throw new TransformException(
+					"Failed to create Document to contain Schema representation ",
+					e.getCause());
+		}
+
+	}
+
+	/**
+	 * Serialize a schema into a Byte Array
+	 * 
+	 * @param schema
+	 *            Schema concerned by the serialization processing
+	 * @return a ByteArray which contains serialized schema
+	 * @throws TransformException
+	 *             When couldn't parse data to XML/RDF
+	 */
+	public static byte[] serialize(XMPSchema schema) throws TransformException {
+		ByteArrayOutputStream bos = new ByteArrayOutputStream();
+		serialize(schema, bos);
+		IOUtils.closeQuietly(bos);
+		return bos.toByteArray();
+	}
+
+}

Propchange: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/SaveMetadataHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/TransformException.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/TransformException.java?rev=1150371&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/TransformException.java (added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/TransformException.java Sun Jul 24 13:57:39 2011
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * 
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ ****************************************************************************/
+
+package org.apache.padaf.xmpbox;
+
+/**
+ * Exception when Parsing cannot be made
+ * 
+ * @author a183132
+ * 
+ */
+public class TransformException extends Exception {
+
+	private static final long serialVersionUID = -3495894314480173555L;
+
+	/**
+	 * Create an instance of TransformException
+	 * 
+	 * @param message
+	 *            a description of the encountered problem
+	 */
+	public TransformException(String message) {
+		super(message);
+	}
+
+	/**
+	 * Create an instance of TransformException
+	 * 
+	 * @param message
+	 *            a description of the encountered problem
+	 * @param cause
+	 *            the cause of the exception
+	 */
+	public TransformException(String message, Throwable cause) {
+		super(message, cause);
+
+	}
+
+}

Propchange: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/TransformException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java?rev=1150371&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java (added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java Sun Jul 24 13:57:39 2011
@@ -0,0 +1,559 @@
+/*****************************************************************************
+ * 
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ ****************************************************************************/
+package org.apache.padaf.xmpbox;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+
+import org.apache.padaf.xmpbox.parser.XmpSchemaException;
+import org.apache.padaf.xmpbox.schema.AdobePDFSchema;
+import org.apache.padaf.xmpbox.schema.DublinCoreSchema;
+import org.apache.padaf.xmpbox.schema.PDFAExtensionSchema;
+import org.apache.padaf.xmpbox.schema.PDFAIdentificationSchema;
+import org.apache.padaf.xmpbox.schema.XMPBasicSchema;
+import org.apache.padaf.xmpbox.schema.XMPMediaManagementSchema;
+import org.apache.padaf.xmpbox.schema.XMPRightsManagementSchema;
+import org.apache.padaf.xmpbox.schema.XMPSchema;
+import org.apache.padaf.xmpbox.type.Elementable;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * 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 {
+
+	protected String xpacketId = "W5M0MpCehiHzreSzNTczkc9d";
+	protected String xpacketBegin = "\uFEFF";
+
+	// DEPRECATED (SHOULD STAY NULL (Default value))
+	protected String xpacketBytes;
+	protected String xpacketEncoding;
+
+	protected String xpacketEndData = "end=\"w\"";
+
+	protected SchemasContainer schemas;
+
+	private Document xmpDocument;
+
+	/**
+	 * Contructor of an empty default XMPMetaData
+	 * 
+	 * @throws CreateXMPMetadataException
+	 *             If DOM Document associated could not be created
+	 */
+	public XMPMetadata() throws CreateXMPMetadataException {
+		try {
+			xmpDocument = org.apache.padaf.xmpbox.parser.XMLUtil.newDocument();
+			schemas = new SchemasContainer();
+		} catch (IOException e) {
+			throw new CreateXMPMetadataException(
+					"Failed to create Dom Document");
+		}
+
+	}
+
+	/**
+	 * 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
+	 */
+	public XMPMetadata(String xpacketBegin, String xpacketId,
+			String xpacketBytes, String xpacketEncoding)
+			throws CreateXMPMetadataException {
+		this.xpacketBegin = xpacketBegin;
+		this.xpacketId = xpacketId;
+		this.xpacketBytes = xpacketBytes;
+		this.xpacketEncoding = xpacketEncoding;
+		try {
+			xmpDocument = org.apache.padaf.xmpbox.parser.XMLUtil.newDocument();
+			schemas = new SchemasContainer();
+		} catch (IOException e) {
+			throw new CreateXMPMetadataException(
+					"Failed to create Dom Document");
+		}
+	}
+
+	/**
+	 * 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;
+	}
+
+	/**
+	 * Add schema given to this metadata representation
+	 * 
+	 * @param schema
+	 *            The Schema to add
+	 */
+	public void addSchema(XMPSchema schema) {
+		schemas.addSchema(schema);
+	}
+
+	/**
+	 * 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.getAllSchemas();
+		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;
+	}
+
+	/**
+	 * Get element associated to all schemas contained in this Metadata
+	 * 
+	 * @return Dom Element representing serialized metadata
+	 */
+	public Element getContainerElement() {
+		return schemas.getElement();
+	}
+
+	/**
+	 * Give the DOM Document to build metadata content
+	 * 
+	 * @return The XML Document which is serialized metadata
+	 */
+	public Document getFuturOwner() {
+		return xmpDocument;
+	}
+
+	/**
+	 * 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 = getAllSchemas().iterator();
+		XMPSchema tmp;
+		while (it.hasNext()) {
+			tmp = it.next();
+			if (tmp.getNamespaceValue().equals(nsURI)) {
+				return tmp;
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * 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.getNamespaceValue().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, nsPrefix, nsURI);
+		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(
+			HashMap<String, String> namespaces) throws XmpSchemaException {
+		PDFAExtensionSchema pdfAExt = new PDFAExtensionSchema(this, namespaces);
+		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.PDFAEXTENSIONURI);
+	}
+
+	/**
+	 * 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.IDURI);
+	}
+
+	/**
+	 * 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;
+	}
+
+	/**
+	 * 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.DCURI);
+	}
+
+	/**
+	 * 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.XMPRIGHTSURI);
+	}
+
+	/**
+	 * 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.XMPBASICURI);
+	}
+
+	/**
+	 * 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;
+	}
+
+	/**
+	 * 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.XMPMMURI);
+	}
+
+	/**
+	 * 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.PDFURI);
+	}
+
+	/**
+	 * Class which represent a container for schemas associated to a metadata
+	 * representation
+	 * 
+	 * @author a183132
+	 * 
+	 */
+	public class SchemasContainer implements Elementable {
+
+		protected Element element;
+		protected List<XMPSchema> schemas;
+
+		/**
+		 * 
+		 * Schemas Container constructor
+		 */
+		public SchemasContainer() {
+			element = xmpDocument.createElement("rdf:RDF");
+			element.setAttributeNS(XMPSchema.NS_NAMESPACE, "xmlns:rdf",
+					"http://www.w3.org/1999/02/22-rdf-syntax-ns#");
+			schemas = new ArrayList<XMPSchema>();
+		}
+
+		/**
+		 * Add a schema to the current structure
+		 * 
+		 * @param obj
+		 *            the schema to add
+		 */
+		public void addSchema(XMPSchema obj) {
+			if (containsSchema(obj)) {
+				removeSchema(obj);
+			}
+			schemas.add(obj);
+			element.appendChild(obj.getElement());
+		}
+
+		/**
+		 * Return all schemas contained in the container
+		 * 
+		 * @return Iterator of declared schemas in order to be used in
+		 *         XMPMetadata functions
+		 */
+		public Iterator<XMPSchema> getAllSchemas() {
+			return schemas.iterator();
+		}
+
+		/**
+		 * Check if two schemas are similar
+		 * 
+		 * @param prop1
+		 *            The first schema to compare
+		 * @param prop2
+		 *            The second schema to compare
+		 * @return The comparison result
+		 */
+		public boolean isSameSchema(XMPSchema prop1, XMPSchema prop2) {
+			if (prop1.getClass().equals(prop2.getClass())) {
+				if (prop1.getPrefix().equals(prop2.getPrefix())) {
+					return true;
+				}
+			}
+
+			return false;
+		}
+
+		/**
+		 * Check if a specified schema is embedded
+		 * 
+		 * @param schema
+		 *            The schema checked
+		 * @return True if schema is present
+		 */
+		public boolean containsSchema(XMPSchema schema) {
+			Iterator<XMPSchema> it = getAllSchemas();
+			XMPSchema tmp;
+			while (it.hasNext()) {
+				tmp = it.next();
+				if (isSameSchema(tmp, schema)) {
+					return true;
+				}
+			}
+			return false;
+		}
+
+		/**
+		 * Remove a schema
+		 * 
+		 * @param schema
+		 *            The schema to remove
+		 */
+		public void removeSchema(XMPSchema schema) {
+			if (containsSchema(schema)) {
+				schemas.remove(schema);
+				element.removeChild(schema.getElement());
+			}
+		}
+
+		/**
+		 * Get The Dom Element in order to build serialized metadata
+		 * 
+		 * @return Dom Element
+		 */
+		public Element getElement() {
+			return element;
+		}
+
+	}
+
+}

Propchange: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/DateConverter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/DateConverter.java?rev=1150371&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/DateConverter.java (added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/DateConverter.java Sun Jul 24 13:57:39 2011
@@ -0,0 +1,243 @@
+/*****************************************************************************
+ * 
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ ****************************************************************************/
+
+package org.apache.padaf.xmpbox.parser;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+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
+ * 
+ * @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 {
+
+	// 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));
+				}
+				if (date.length() >= 14) {
+					second = Integer.parseInt(date.substring(12, 14));
+				}
+				if (date.length() >= 15) {
+					char sign = date.charAt(14);
+					if (sign == 'Z') {
+						zone = new SimpleTimeZone(0, "Unknown");
+					} else {
+						int hours = 0;
+						int minutes = 0;
+						if (date.length() >= 17) {
+							if (sign == '+') {
+								// parseInt cannot handle the + sign
+								hours = Integer
+										.parseInt(date.substring(15, 17));
+							} else {
+								hours = -Integer.parseInt(date
+										.substring(14, 16));
+							}
+						}
+						if (sign == '+') {
+							if (date.length() >= 19) {
+								minutes = Integer.parseInt(date.substring(17,
+										19));
+							}
+						} else {
+							if (date.length() >= 18) {
+								minutes = Integer.parseInt(date.substring(16,
+										18));
+							}
+						}
+						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
+					throw new IOException("Error converting date:" + date);
+				}
+			}
+		}
+		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();
+	}
+}

Propchange: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/DateConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/NSMapping.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/NSMapping.java?rev=1150371&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/NSMapping.java (added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/NSMapping.java Sun Jul 24 13:57:39 2011
@@ -0,0 +1,472 @@
+/*****************************************************************************
+ * 
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ ****************************************************************************/
+
+package org.apache.padaf.xmpbox.parser;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.padaf.xmpbox.XMPMetadata;
+import org.apache.padaf.xmpbox.schema.AdobePDFSchema;
+import org.apache.padaf.xmpbox.schema.DublinCoreSchema;
+import org.apache.padaf.xmpbox.schema.PDFAExtensionSchema;
+import org.apache.padaf.xmpbox.schema.PDFAFieldDescription;
+import org.apache.padaf.xmpbox.schema.PDFAIdentificationSchema;
+import org.apache.padaf.xmpbox.schema.PDFAPropertyDescription;
+import org.apache.padaf.xmpbox.schema.PDFAValueTypeDescription;
+import org.apache.padaf.xmpbox.schema.PropertyAttributesAnnotation;
+import org.apache.padaf.xmpbox.schema.PropertyType;
+import org.apache.padaf.xmpbox.schema.SchemaDescription;
+import org.apache.padaf.xmpbox.schema.XMPBasicSchema;
+import org.apache.padaf.xmpbox.schema.XMPMediaManagementSchema;
+import org.apache.padaf.xmpbox.schema.XMPRightsManagementSchema;
+import org.apache.padaf.xmpbox.schema.XMPSchema;
+
+
+/**
+ * Retrieve information about schemas
+ * 
+ * @author a183132
+ * 
+ */
+public class NSMapping {
+
+	public static final List<String> BASIC_TYPES;
+	public static final HashMap<String, String> COMPLEX_BASIC_TYPES;
+
+	static {
+		BASIC_TYPES = new ArrayList<String>();
+		BASIC_TYPES.add("Text");
+		BASIC_TYPES.add("Integer");
+		BASIC_TYPES.add("Boolean");
+		BASIC_TYPES.add("Date");
+		BASIC_TYPES.add("URI");
+		BASIC_TYPES.add("URL");
+		BASIC_TYPES.add("bag Text");
+		BASIC_TYPES.add("bag ProperName");
+		BASIC_TYPES.add("bag Job");
+		BASIC_TYPES.add("bag Xpath");
+		BASIC_TYPES.add("seq Text");
+		BASIC_TYPES.add("seq Field");
+		BASIC_TYPES.add("seq Date");
+		BASIC_TYPES.add("Lang Alt");
+
+		COMPLEX_BASIC_TYPES = new HashMap<String, String>();
+		COMPLEX_BASIC_TYPES.put("http://ns.adobe.com/xap/1.0/g/img/",
+				"Thumbnail");
+	}
+
+	protected Map<String, XMPSchemaFactory> nsMaps;
+	protected Map<String, String> complexBasicTypesDeclarationEntireXMPLevel;
+	protected Map<String, String> complexBasicTypesDeclarationSchemaLevel;
+	protected Map<String, String> complexBasicTypesDeclarationPropertyLevel;
+
+	/**
+	 * Constructor of the NameSpace mapping
+	 * 
+	 * @throws XmpSchemaException
+	 *             When could not read a property data in a Schema Class given
+	 */
+	public NSMapping() throws XmpSchemaException {
+		nsMaps = new HashMap<String, XMPSchemaFactory>();
+		complexBasicTypesDeclarationEntireXMPLevel = new HashMap<String, String>();
+		complexBasicTypesDeclarationSchemaLevel = new HashMap<String, String>();
+		complexBasicTypesDeclarationPropertyLevel = new HashMap<String, String>();
+		init();
+
+	}
+
+	/**
+	 * Add mapping of common schemas
+	 * 
+	 * @throws XmpSchemaException
+	 *             When could not read a property data in a Schema Class given
+	 */
+	private void init() throws XmpSchemaException {
+		addNameSpace("http://ns.adobe.com/xap/1.0/", XMPBasicSchema.class);
+		addNameSpace("http://purl.org/dc/elements/1.1/", DublinCoreSchema.class);
+		addNameSpace("http://www.aiim.org/pdfa/ns/extension/", PDFAExtensionSchema.class);
+		addNameSpace("http://ns.adobe.com/xap/1.0/mm/",	XMPMediaManagementSchema.class);
+		addNameSpace("http://ns.adobe.com/pdf/1.3/", AdobePDFSchema.class);
+		addNameSpace("http://www.aiim.org/pdfa/ns/id/",	PDFAIdentificationSchema.class);
+		addNameSpace("http://ns.adobe.com/xap/1.0/rights/",	XMPRightsManagementSchema.class);
+	}
+
+	/**
+	 * Add a namespace declaration and Schema factory associated
+	 * 
+	 * @param ns
+	 *            the Namespace URI
+	 * @param classSchem
+	 *            The class representation of the schema linked to the namespace
+	 * @throws XmpSchemaException
+	 *             When could not read property name in Schema Class given
+	 */
+	protected void addNameSpace(String ns, Class<? extends XMPSchema> classSchem)
+			throws XmpSchemaException {
+		nsMaps.put(ns, new XMPSchemaFactory(ns, classSchem,	initializePropMapping(ns, classSchem)));
+	}
+
+	/**
+	 * Initialize the Property Mapping for a given schema
+	 * 
+	 * @param ns
+	 *            Namespace URI
+	 * @param classSchem
+	 *            The class representation of the schema linked to the namespace
+	 * @return Construct expected properties types representation
+	 * @throws XmpSchemaException
+	 *             When could not read property name in field with properties
+	 *             annotations
+	 */
+	private PropMapping initializePropMapping(String ns,
+			Class<? extends XMPSchema> classSchem) throws XmpSchemaException {
+		PropertyType propType;
+		PropertyAttributesAnnotation propAtt;
+		Field[] fields;
+		PropMapping propMap = new PropMapping(ns);
+		fields = classSchem.getFields();
+		String propName = null;
+		for (Field field : fields) {
+			if (field.isAnnotationPresent(PropertyType.class)) {
+				try {
+					propName = (String) field.get(propName);
+				} catch (Exception e) {
+					throw new XmpSchemaException(
+							"couldn't read one type declaration, please check accessibility and declaration of fields annoted in "
+									+ classSchem.getName(), e.getCause());
+				}
+				// System.out.println("nameField:"+propName);
+				propType = field.getAnnotation(PropertyType.class);
+				// System.out.println("Type '"+propInfo.propertyType()+"' defined for "+propName);
+				if (!field
+						.isAnnotationPresent(PropertyAttributesAnnotation.class)) {
+					propMap.addNewProperty(propName, propType.propertyType(),
+							null);
+				} else {
+					// TODO Case where a special annotation is used to specify
+					// attributes
+					// NOT IMPLEMENTED YET, JUST TO GIVE A CLUE TO MAKE THIS
+					propAtt = field
+							.getAnnotation(PropertyAttributesAnnotation.class);
+					List<String> attributes = new ArrayList<String>();
+					for (String att : propAtt.expectedAttributes()) {
+						attributes.add(att);
+					}
+					propMap.addNewProperty(propName, propType.propertyType(),
+							attributes);
+				}
+			}
+		}
+		return propMap;
+	}
+
+	/**
+	 * see if a specific type is known as a basic XMP type
+	 * 
+	 * @param type
+	 *            Type to check
+	 * @return True if type is a simple basic type
+	 */
+	private boolean isBasicType(String type) {
+		return BASIC_TYPES.contains(type);
+
+	}
+
+	/**
+	 * Say if a specific namespace is known
+	 * 
+	 * @param namespace
+	 *            The namespace URI checked
+	 * @return True if namespace URI is known
+	 */
+	public boolean isContainedNamespace(String namespace) {
+		return nsMaps.containsKey(namespace);
+	}
+
+	/**
+	 * Give type of specified property in specified schema (given by its
+	 * namespaceURI)
+	 * 
+	 * @param namespace
+	 *            The namespaceURI to explore
+	 * @param prop
+	 *            the property Qualified Name
+	 * @return Property type declared for namespace specified, null if unknown
+	 */
+	public String getSpecifiedPropertyType(String namespace, QName prop) {
+		if (nsMaps.containsKey(namespace)) {
+			return nsMaps.get(namespace).getPropertyType(prop.getLocalPart());
+		}
+		// check if its a complexbasicValueType and if it's has been declared
+		return getComplexBasicValueTypeEffectiveType(prop.getPrefix());
+
+	}
+
+	/**
+	 * Check if a non basic value type used is describes in the schema which
+	 * inlude a property with a such type
+	 * 
+	 * @param desc
+	 *            The schema description associated to the schema which declare
+	 *            a property with specific value type
+	 * @param definedValueType
+	 *            The value type name to find in value types descriptions
+	 * @return The description of this specific value type
+	 * @throws XmpUnknownValueTypeException
+	 *             If no declaration found
+	 */
+	private PDFAValueTypeDescription findValueTypeDescription(
+			SchemaDescription desc, String definedValueType)
+			throws XmpUnknownValueTypeException {
+		List<PDFAValueTypeDescription> values = desc.getValueTypes();
+		for (PDFAValueTypeDescription val : values) {
+			if (definedValueType.equals(val.getTypeNameValue())) {
+				return val;
+			}
+		}
+		throw new XmpUnknownValueTypeException("ValueType '" + definedValueType
+				+ "' is unknown. no declaration found in this schema");
+	}
+
+	/**
+	 * Check if valueType used for a specified property description is known (in
+	 * case where it's a normal value type or if a value type which has been
+	 * defined in PDF/A Extension schema)
+	 * 
+	 * @param desc
+	 *            The schema description associated to the schema which declare
+	 *            a property with specific value type
+	 * @param definedValueType
+	 *            The value type name to find in value types descriptions
+	 * @return value type equivalence (value type which can be treat (orginal
+	 *         basic value type or specific value type decomposed to find basic
+	 *         types)
+	 * @throws XmpUnknownValueTypeException
+	 *             When Value Type is unknown
+	 * 
+	 */
+	private String getValueTypeEquivalence(SchemaDescription desc,
+			String definedValueType) throws XmpUnknownValueTypeException {
+		if (isBasicType(definedValueType)) {
+			return definedValueType;
+		}
+		PDFAValueTypeDescription val = findValueTypeDescription(desc,
+				definedValueType);
+		if (val.getFields().isEmpty()) {
+			// if fields value are note defined we suppose the property is a
+			// Text type
+			return "Text";
+		}
+		return "Field";
+	}
+
+	/**
+	 * . For a specific valuetype declared in this schema. This method decompose
+	 * it if field are present. and add types expected
+	 * 
+	 * @param desc
+	 *            The schema description associated to the schema which declare
+	 *            a property with specific value type
+	 * @param valueType
+	 *            valueType to analyze
+	 * @param prop
+	 *            Expected properties types representation
+	 * @throws XmpUnknownValueTypeException
+	 *             When a Value Type associated is unknown
+	 */
+	private void declareAssociatedFieldType(SchemaDescription desc,
+			String valueType, PropMapping prop)
+			throws XmpUnknownValueTypeException {
+
+		PDFAValueTypeDescription val = findValueTypeDescription(desc, valueType);
+		for (PDFAFieldDescription field : val.getFields()) {
+			// TODO case where a field call another nspace property ???
+			String fieldType = getValueTypeEquivalence(desc, field
+					.getValueTypeValue());
+			if (fieldType.equals("Field")) {
+				throw new XmpUnknownValueTypeException(
+						"ValueType Field reference a valuetype unknown");
+			}
+			prop.addNewProperty(field.getNameValue(), fieldType, null);
+
+		}
+	}
+
+	/**
+	 * Add a new namespace Mapping for specific schema declared in PDF/A
+	 * Extension schema
+	 * 
+	 * @param desc
+	 *            The schemaDescription associated to the schema
+	 * @throws XmpUnknownValueTypeException
+	 *             When a Value Type associated is unknown
+	 */
+	public void setNamespaceDefinition(SchemaDescription desc)
+			throws XmpUnknownValueTypeException {
+		PropMapping propMap = new PropMapping(desc.getNameSpaceURI());
+		List<PDFAPropertyDescription> props = desc.getProperties();
+		for (int i = 0; i < props.size(); i++) {
+			String type = getValueTypeEquivalence(desc, props.get(i).getValueTypeValue());
+			propMap.addNewProperty(props.get(i).getNameValue(), type, null);
+			if (type.equals("Field")) {
+				declareAssociatedFieldType(desc, props.get(i).getValueTypeValue(), propMap);
+			}
+		}
+		String nsName = desc.getPrefix();
+		String ns = desc.getNameSpaceURI();
+		nsMaps.put(ns, new XMPSchemaFactory(nsName, ns, XMPSchema.class, propMap));
+	}
+
+	/**
+	 * Return the specialized schema class representation if it's known (create
+	 * and add it to metadata). In other cases, return null
+	 * 
+	 * @param metadata
+	 *            Metadata to link the new schema
+	 * @param namespace
+	 *            The namespace URI
+	 * @return Schema representation
+	 * @throws XmpSchemaException
+	 *             When Instancing specified Object Schema failed
+	 */
+	public XMPSchema getAssociatedSchemaObject(XMPMetadata metadata, String namespace, String prefix) throws XmpSchemaException {
+		if (!nsMaps.containsKey(namespace)) {
+			return null;
+		}
+		XMPSchemaFactory factory = nsMaps.get(namespace);
+		return factory.createXMPSchema(metadata, prefix);
+	}
+
+	/**
+	 * Check if a namespace used reference a complex basic types (like
+	 * Thumbnails)
+	 * 
+	 * @param namespace
+	 *            The namespace URI to check
+	 * @return True if namespace URI is a reference for a complex basic type
+	 */
+	public boolean isComplexBasicTypes(String namespace) {
+		return COMPLEX_BASIC_TYPES.containsKey(namespace);
+	}
+
+	/**
+	 * Check if a namespace declaration for a complex basic type has been found
+	 * and if its valid for the entire XMP stream
+	 * 
+	 * @param namespace
+	 *            the namespace URI
+	 * @param prefix
+	 *            the prefix associated to this namespace
+	 */
+	public void setComplexBasicTypesDeclarationForLevelXMP(String namespace,
+			String prefix) {
+		if (isComplexBasicTypes(namespace)) {
+			complexBasicTypesDeclarationEntireXMPLevel.put(prefix, namespace);
+		}
+	}
+
+	/**
+	 * Check if a namespace declaration for a complex basic type has been found
+	 * and if its valid for the current schema description (at level of
+	 * rdf:Description)
+	 * 
+	 * @param namespace
+	 *            the namespace URI
+	 * @param prefix
+	 *            the prefix associated to this namespace
+	 */
+	public void setComplexBasicTypesDeclarationForLevelSchema(String namespace,
+			String prefix) {
+		if (isComplexBasicTypes(namespace)) {
+			complexBasicTypesDeclarationSchemaLevel.put(prefix, namespace);
+		}
+
+	}
+
+	/**
+	 * Check if a namespace declaration for a complex basic type has been found
+	 * and if its valid for the current property description
+	 * 
+	 * @param namespace
+	 *            the namespace URI
+	 * @param prefix
+	 *            the prefix associated to this namespace
+	 */
+	public void setComplexBasicTypesDeclarationForLevelProperty(
+			String namespace, String prefix) {
+		if (isComplexBasicTypes(namespace)) {
+			complexBasicTypesDeclarationPropertyLevel.put(prefix, namespace);
+		}
+	}
+
+	/**
+	 * Check for all XMP level if a complexBasicValueType prefix has been
+	 * declared
+	 * 
+	 * @param prefix
+	 *            The prefix which may design the namespace URI of the complex
+	 *            basic type
+	 * @return The type if it is known, else null.
+	 */
+	public String getComplexBasicValueTypeEffectiveType(String prefix) {
+		if (complexBasicTypesDeclarationPropertyLevel.containsKey(prefix)) {
+			return COMPLEX_BASIC_TYPES
+					.get(complexBasicTypesDeclarationPropertyLevel.get(prefix));
+		}
+		if (complexBasicTypesDeclarationSchemaLevel.containsKey(prefix)) {
+			return COMPLEX_BASIC_TYPES
+					.get(complexBasicTypesDeclarationSchemaLevel.get(prefix));
+		}
+		if (complexBasicTypesDeclarationEntireXMPLevel.containsKey(prefix)) {
+			return COMPLEX_BASIC_TYPES
+					.get(complexBasicTypesDeclarationEntireXMPLevel.get(prefix));
+		}
+		return null;
+	}
+
+	/**
+	 * Reset complex Basic types declaration for property level
+	 */
+	public void resetComplexBasicTypesDeclarationInPropertyLevel() {
+		complexBasicTypesDeclarationPropertyLevel.clear();
+	}
+
+	/**
+	 * Reset complex Basic types declaration for schema level
+	 */
+	public void resetComplexBasicTypesDeclarationInSchemaLevel() {
+		complexBasicTypesDeclarationSchemaLevel.clear();
+	}
+
+	/**
+	 * Reset complex Basic types declaration for Entire XMP level
+	 */
+	public void resetComplexBasicTypesDeclarationInEntireXMPLevel() {
+		complexBasicTypesDeclarationEntireXMPLevel.clear();
+	}
+
+}

Propchange: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/NSMapping.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/PropMapping.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/PropMapping.java?rev=1150371&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/PropMapping.java (added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/PropMapping.java Sun Jul 24 13:57:39 2011
@@ -0,0 +1,116 @@
+/*****************************************************************************
+ * 
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ ****************************************************************************/
+
+package org.apache.padaf.xmpbox.parser;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents all properties known for a specific namespace Type and attributes
+ * associated to each properties are saved If a specific type well declared is
+ * used, this class map it to a basic type
+ * 
+ * @author a183132
+ * 
+ *         Attribute management pre-implemented in order to give clues to make
+ *         an attribute management system
+ */
+public class PropMapping {
+
+	private String namespace;
+	private Map<String, String> types;
+	private Map<String, List<String>> attributes;
+
+	/**
+	 * Build PropMapping for specified namespace
+	 * 
+	 * @param namespace
+	 *            namespace URI concerned by this PropMapping
+	 */
+	public PropMapping(String namespace) {
+		this.namespace = namespace;
+		types = new HashMap<String, String>();
+		attributes = new HashMap<String, List<String>>();
+
+	}
+
+	/**
+	 * Give the NS URI associated to this Property Description
+	 * 
+	 * @return the namespace URI concerned by this PropMapping
+	 */
+	public String getConcernedNamespace() {
+		return namespace;
+	}
+
+	/**
+	 * Get All Properties Name
+	 * 
+	 * @return a list of properties qualifiedName
+	 */
+	public List<String> getPropertiesName() {
+		return new ArrayList<String>(types.keySet());
+	}
+
+	/**
+	 * Add a new property, an attributes list can be given or can be null
+	 * 
+	 * @param name
+	 *            new property name
+	 * @param type
+	 *            Valuetype of the new property
+	 * @param attr
+	 *            A list of attribute (put null while attribute management is
+	 *            not implemented)
+	 */
+	public void addNewProperty(String name, String type, List<String> attr) {
+		types.put(name, type);
+		if (attr != null) {
+			attributes.put(name, attr);
+		}
+	}
+
+	/**
+	 * Return a type of a property from its qualifiedName
+	 * 
+	 * @param name
+	 *            The name of the property concerned
+	 * @return Type of property or null
+	 */
+	public String getPropertyType(String name) {
+		return types.get(name);
+	}
+
+	/**
+	 * Return an unmodifiable list of property attributes from its qualifiedName
+	 * 
+	 * @param name
+	 *            LocalName of the property
+	 * @return List of all attributes declared for this property
+	 */
+	public List<String> getPropertyAttributes(String name) {
+		return attributes.get(name);
+	}
+
+}

Propchange: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/PropMapping.java
------------------------------------------------------------------------------
    svn:eol-style = native