Author: gbailleul
Date: Sat Jul 28 08:29:29 2012
New Revision: 1366608

URL: http://svn.apache.org/viewvc?rev=1366608&view=rev
Log:
PDFBOX-1366: create utility classes

Added:
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XmpConstants.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeUtil.java
Modified:
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java
    
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMLUtil.java
    
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPSchemaFactory.java

Modified: 
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=1366608&r1=1366607&r2=1366608&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java 
(original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java 
Sat Jul 28 08:29:29 2012
@@ -54,16 +54,18 @@ import org.w3c.dom.Element;
  */
 public class XMPMetadata {
 
-    protected String xpacketId = "W5M0MpCehiHzreSzNTczkc9d";
-    protected String xpacketBegin = "\uFEFF";
+    private String xpacketId = "W5M0MpCehiHzreSzNTczkc9d";
+    
+    private String xpacketBegin = "\uFEFF";
 
     // DEPRECATED (SHOULD STAY NULL (Default value))
-    protected String xpacketBytes;
-    protected String xpacketEncoding;
+    private String xpacketBytes;
+    
+    private String xpacketEncoding;
 
-    protected String xpacketEndData = "end=\"w\"";
+    private String xpacketEndData = "end=\"w\"";
 
-    protected SchemasContainer schemas;
+    private SchemasContainer schemas;
 
     private Document xmpDocument;
 
@@ -502,8 +504,9 @@ public class XMPMetadata {
      */
     public class SchemasContainer implements Elementable {
 
-        protected Element element;
-        protected List<XMPSchema> schemas;
+        private Element element;
+        
+        private List<XMPSchema> schemas;
 
         /**
          * 

Added: 
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XmpConstants.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XmpConstants.java?rev=1366608&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XmpConstants.java 
(added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/XmpConstants.java 
Sat Jul 28 08:29:29 2012
@@ -0,0 +1,31 @@
+ /*****************************************************************************
+ * 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;
+
+public class XmpConstants {
+
+       public static final String RDF_NAMESPACE = 
"http://www.w3.org/1999/02/22-rdf-syntax-ns#";;
+
+       private XmpConstants () {
+               // hide constructor
+       }
+       
+}

Modified: 
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMLUtil.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMLUtil.java?rev=1366608&r1=1366607&r2=1366608&view=diff
==============================================================================
--- 
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMLUtil.java 
(original)
+++ 
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMLUtil.java 
Sat Jul 28 08:29:29 2012
@@ -363,6 +363,7 @@ public final class XMLUtil {
         Transformer transformer = TransformerFactory.newInstance()
         .newTransformer();
         transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+        
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount";, "2");
         transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
         transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
         "yes");
@@ -401,7 +402,7 @@ public final class XMLUtil {
         return writer.getBuffer().toString().getBytes();
     }
     
-    // TODO : remove this in java 6 (when constructor with message and cause 
will be added)
+    // XXX : remove this in java 6 (when constructor with message and cause 
will be added)
     private static IOException prepareIOException (String message, Throwable 
cause) {
        IOException e = new IOException(message);
        e.initCause(cause);

Modified: 
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPSchemaFactory.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPSchemaFactory.java?rev=1366608&r1=1366607&r2=1366608&view=diff
==============================================================================
--- 
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPSchemaFactory.java
 (original)
+++ 
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPSchemaFactory.java
 Sat Jul 28 08:29:29 2012
@@ -37,13 +37,17 @@ import org.apache.padaf.xmpbox.schema.XM
  */
 public class XMPSchemaFactory {
 
-       protected String namespace;
-       protected Class<? extends XMPSchema> schemaClass;
-       protected PropMapping propDef;
-       protected String nsName;
-       protected boolean isDeclarative;
+       private  String namespace;
        
-       protected List<PropMapping> importedPropertyMapping = new 
ArrayList<PropMapping>();
+       private Class<? extends XMPSchema> schemaClass;
+       
+       private PropMapping propDef;
+       
+       private String nsName;
+       
+       private boolean isDeclarative;
+       
+       private List<PropMapping> importedPropertyMapping = new 
ArrayList<PropMapping>();
        
        /**
         * Factory Constructor for basic known schemas
@@ -153,11 +157,10 @@ public class XMPSchemaFactory {
         * @throws XmpSchemaException
         *             When Instancing specified Object Schema failed
         */
-       @SuppressWarnings("unchecked")
        public XMPSchema createXMPSchema(XMPMetadata metadata, String prefix)
        throws XmpSchemaException {
                XMPSchema schema = null;
-               Class[] argsClass;
+               Class<?>[] argsClass;
                Object[] schemaArgs;
 
                if (isDeclarative) {

Added: 
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeUtil.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeUtil.java?rev=1366608&view=auto
==============================================================================
--- 
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeUtil.java 
(added)
+++ 
pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeUtil.java 
Sat Jul 28 08:29:29 2012
@@ -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.type;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+public final class TypeUtil {
+
+       private TypeUtil() {
+               // hide constructor
+       }
+       
+       /**
+        * Generic String List Builder for arrays contents
+        * 
+        * @return String list which represents content of array property
+        */
+    public static List<String> getArrayListToString(ComplexProperty array) {
+        List<String> retval = null;
+        if (array != null) {
+            retval = new ArrayList<String>();
+            Iterator<AbstractField> it = array.getContainer()
+            .getAllProperties().iterator();
+            AbstractSimpleProperty tmp;
+            while (it.hasNext()) {
+                tmp = (AbstractSimpleProperty) it.next();
+                retval.add(tmp.getStringValue());
+            }
+            retval = Collections.unmodifiableList(retval);
+        }
+        return retval;
+    }
+
+       
+}


Reply via email to