pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r887689 - in /pdfbox/jempbox/trunk/src: main/java/org/apache/jempbox/xmp/ test/java/org/apache/jempbox/xmp/
Date Sun, 06 Dec 2009 15:09:55 GMT
Author: lehmi
Date: Sun Dec  6 15:09:55 2009
New Revision: 887689

URL: http://svn.apache.org/viewvc?rev=887689&view=rev
Log:
PDFBOX-572: using generics after upgrading to java5

Modified:
    pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPMetadata.java
    pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchema.java
    pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaBasic.java
    pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaDublinCore.java
    pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaIptc4xmpCore.java
    pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaMediaManagement.java
    pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaPhotoshop.java
    pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaRightsManagement.java
    pdfbox/jempbox/trunk/src/test/java/org/apache/jempbox/xmp/XMPSchemaTest.java

Modified: pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPMetadata.java
URL: http://svn.apache.org/viewvc/pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPMetadata.java?rev=887689&r1=887688&r2=887689&view=diff
==============================================================================
--- pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPMetadata.java (original)
+++ pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPMetadata.java Sun Dec  6
15:09:55 2009
@@ -75,7 +75,7 @@
     /**
      * A mapping of namespaces.
      */
-    protected Map nsMappings = new HashMap();
+    protected Map<String,Class<?>> nsMappings = new HashMap<String,Class<?>>();
 
     /**
      * Default constructor, creates blank XMP doc.
@@ -153,7 +153,7 @@
      * @param xmpSchema
      *            The schema to associated this identifier with.
      */
-    public void addXMLNSMapping(String namespace, Class xmpSchema)
+    public void addXMLNSMapping(String namespace, Class<?> xmpSchema)
     {
 
         if (!(XMPSchema.class.isAssignableFrom(xmpSchema)))
@@ -585,7 +585,7 @@
         basic.setThumbnail(t);
         basic.setBaseURL("http://www.pdfbox.org/");
 
-        List schemas = metadata.getSchemas();
+        List<XMPSchema> schemas = metadata.getSchemas();
         System.out.println("schemas=" + schemas);
 
         metadata.save("test.xmp");
@@ -600,11 +600,11 @@
      * @throws IOException
      *             If there is an error creating a specific schema.
      */
-    public List getSchemas() throws IOException
+    public List<XMPSchema> getSchemas() throws IOException
     {
         NodeList schemaList = xmpDocument
                 .getElementsByTagName("rdf:Description");
-        List retval = new ArrayList(schemaList.getLength());
+        List<XMPSchema> retval = new ArrayList<XMPSchema>(schemaList.getLength());
         for (int i = 0; i < schemaList.getLength(); i++)
         {
             Element schema = (Element) schemaList.item(i);
@@ -617,13 +617,13 @@
                 String value = attribute.getNodeValue();
                 if (name.startsWith("xmlns:") && nsMappings.containsKey(value))
                 {
-                    Class schemaClass = (Class) nsMappings.get(value);
+                    Class<?> schemaClass = nsMappings.get(value);
                     try
                     {
-                        Constructor ctor = schemaClass
+                        Constructor<?> ctor = schemaClass
                                 .getConstructor(new Class[] { Element.class,
                                         String.class });
-                        retval.add(ctor.newInstance(new Object[] { schema,
+                        retval.add((XMPSchema)ctor.newInstance(new Object[] { schema,
                                 name.substring(6) }));
                         found = true;
                     }
@@ -664,23 +664,23 @@
      * @throws IOException
      *             If an operation on the document fails.
      */
-    public List getSchemasByNamespaceURI(String namespaceURI)
+    public List<XMPSchema> getSchemasByNamespaceURI(String namespaceURI)
             throws IOException
     {
 
-        List l = getSchemas();
-        List result = new LinkedList();
+        List<XMPSchema> l = getSchemas();
+        List<XMPSchema> result = new LinkedList<XMPSchema>();
 
-        Class schemaClass = (Class) nsMappings.get(namespaceURI);
+        Class<?> schemaClass = nsMappings.get(namespaceURI);
         if (schemaClass == null)
         {
             return result;
         }
 
-        Iterator i = l.iterator();
+        Iterator<XMPSchema> i = l.iterator();
         while (i.hasNext())
         {
-            XMPSchema schema = (XMPSchema) i.next();
+            XMPSchema schema = i.next();
 
             if (schemaClass.isAssignableFrom(schema.getClass()))
             {
@@ -732,9 +732,9 @@
      * @throws IOException
      *             if there was an error creating the schemas of this.
      */
-    public XMPSchema getSchemaByClass(Class targetSchema) throws IOException
+    public XMPSchema getSchemaByClass(Class<?> targetSchema) throws IOException
     {
-        Iterator iter = getSchemas().iterator();
+        Iterator<XMPSchema> iter = getSchemas().iterator();
         while (iter.hasNext())
         {
             XMPSchema element = (XMPSchema) iter.next();
@@ -756,10 +756,10 @@
      */
     public void merge(XMPMetadata metadata) throws IOException
     {
-        List schemas2 = metadata.getSchemas();
-        for (Iterator iterator = schemas2.iterator(); iterator.hasNext();)
+        List<XMPSchema> schemas2 = metadata.getSchemas();
+        for (Iterator<XMPSchema> iterator = schemas2.iterator(); iterator.hasNext();)
         {
-            XMPSchema schema2 = (XMPSchema) iterator.next();
+            XMPSchema schema2 = iterator.next();
             XMPSchema schema1 = getSchemaByClass(schema2.getClass());
             if (schema1 == null)
             {

Modified: pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchema.java?rev=887689&r1=887688&r2=887689&view=diff
==============================================================================
--- pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchema.java (original)
+++ pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchema.java Sun Dec  6 15:09:55
2009
@@ -402,9 +402,9 @@
      * 
      * @return All of the values of the bag property in a list.
      */
-    public List getBagList(String bagName)
+    public List<String> getBagList(String bagName)
     {
-        List retval = null;
+        List<String> retval = null;
         NodeList nodes = schema.getElementsByTagName(bagName);
         if (nodes.getLength() > 0)
         {
@@ -413,7 +413,7 @@
             if (bagList.getLength() > 0)
             {
                 Element bag = (Element) bagList.item(0);
-                retval = new ArrayList();
+                retval = new ArrayList<String>();
                 NodeList items = bag.getElementsByTagName("rdf:li");
                 for (int i = 0; i < items.getLength(); i++)
                 {
@@ -579,9 +579,9 @@
      * @return A read-only list of java.lang.String objects or null if the
      *         property does not exist.
      */
-    public List getSequenceList(String seqName)
+    public List<String> getSequenceList(String seqName)
     {
-        List retval = null;
+        List<String> retval = null;
         NodeList nodes = schema.getElementsByTagName(seqName);
         if (nodes.getLength() > 0)
         {
@@ -590,7 +590,7 @@
             if (bagList.getLength() > 0)
             {
                 Element bag = (Element) bagList.item(0);
-                retval = new ArrayList();
+                retval = new ArrayList<String>();
                 NodeList items = bag.getElementsByTagName("rdf:li");
                 for (int i = 0; i < items.getLength(); i++)
                 {
@@ -612,9 +612,9 @@
      * 
      * @return A list of ResourceEvent objects or null if they do not exist.
      */
-    public List getEventSequenceList(String seqName)
+    public List<ResourceEvent> getEventSequenceList(String seqName)
     {
-        List retval = null;
+        List<ResourceEvent> retval = null;
         NodeList nodes = schema.getElementsByTagName(seqName);
         if (nodes.getLength() > 0)
         {
@@ -623,7 +623,7 @@
             if (bagList.getLength() > 0)
             {
                 Element bag = (Element) bagList.item(0);
-                retval = new ArrayList();
+                retval = new ArrayList<ResourceEvent>();
                 NodeList items = bag.getElementsByTagName("rdf:li");
                 for (int i = 0; i < items.getLength(); i++)
                 {
@@ -680,16 +680,16 @@
      * @throws IOException
      *             If there is an error converting the value to a date.
      */
-    public List getSequenceDateList(String seqName) throws IOException
+    public List<Calendar> getSequenceDateList(String seqName) throws IOException
     {
-        List strings = getSequenceList(seqName);
-        List retval = null;
+        List<String> strings = getSequenceList(seqName);
+        List<Calendar> retval = null;
         if (strings != null)
         {
-            retval = new ArrayList();
+            retval = new ArrayList<Calendar>();
             for (int i = 0; i < strings.size(); i++)
             {
-                retval.add(DateConverter.toCalendar((String) strings.get(i)));
+                retval.add(DateConverter.toCalendar(strings.get(i)));
             }
         }
         return retval;
@@ -963,9 +963,9 @@
      * @return A list of all languages, this will return an non-null empty list
      *         if none have been defined.
      */
-    public List getLanguagePropertyLanguages(String propertyName)
+    public List<String> getLanguagePropertyLanguages(String propertyName)
     {
-        List retval = new ArrayList();
+        List<String> retval = new ArrayList<String>();
 
         NodeList nodes = schema.getElementsByTagName(propertyName);
         if (nodes.getLength() > 0)
@@ -1035,18 +1035,18 @@
                         NodeList seqList = e.getElementsByTagName("rdf:Seq");
                         if (seqList.getLength() > 0)
                         {
-                            List newList = xmpSchema.getSequenceList(name);
-                            List oldList = getSequenceList(name);
+                            List<String> newList = xmpSchema.getSequenceList(name);
+                            List<String> oldList = getSequenceList(name);
 
-                            Iterator it = newList.iterator();
+                            Iterator<String> it = newList.iterator();
 
                             while (it.hasNext())
                             {
-                                Object object = it.next();
+                                String object = it.next();
                                 if (oldList == null
                                         || !oldList.contains(object))
                                 {
-                                    addSequenceValue(name, (String) object);
+                                    addSequenceValue(name, object);
                                 }
                             }
                             continue;
@@ -1054,18 +1054,18 @@
                         NodeList bagList = e.getElementsByTagName("rdf:Bag");
                         if (bagList.getLength() > 0)
                         {
-                            List newList = xmpSchema.getBagList(name);
-                            List oldList = getBagList(name);
+                            List<String> newList = xmpSchema.getBagList(name);
+                            List<String> oldList = getBagList(name);
 
-                            Iterator it = newList.iterator();
+                            Iterator<String> it = newList.iterator();
 
                             while (it.hasNext())
                             {
-                                Object object = it.next();
+                                String object = it.next();
                                 if (oldList == null
                                         || !oldList.contains(object))
                                 {
-                                    addBagValue(name, (String) object);
+                                    addBagValue(name, object);
                                 }
                             }
                             continue;

Modified: pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaBasic.java
URL: http://svn.apache.org/viewvc/pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaBasic.java?rev=887689&r1=887688&r2=887689&view=diff
==============================================================================
--- pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaBasic.java (original)
+++ pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaBasic.java Sun Dec
 6 15:09:55 2009
@@ -93,7 +93,7 @@
      *
      * @return The list of advisories.
      */
-    public List getAdvisories()
+    public List<String> getAdvisories()
     {
         return getBagList( prefix + ":Advisory" );
     }
@@ -188,7 +188,7 @@
      *
      * @return The list of identifiers.
      */
-    public List getIdentifiers()
+    public List<String> getIdentifiers()
     {
         return getBagList( prefix + ":Identifier" );
     }
@@ -367,7 +367,7 @@
      *
      * @return A non-null list of languages, potentially an empty list.
      */
-    public List getThumbnailLanguages()
+    public List<String> getThumbnailLanguages()
     {
         return getLanguagePropertyLanguages( prefix + ":Thumbnails" );
     }

Modified: pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaDublinCore.java
URL: http://svn.apache.org/viewvc/pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaDublinCore.java?rev=887689&r1=887688&r2=887689&view=diff
==============================================================================
--- pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaDublinCore.java (original)
+++ pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaDublinCore.java Sun
Dec  6 15:09:55 2009
@@ -80,7 +80,7 @@
      *
      * @return The list of contributors.
      */
-    public List getContributors()
+    public List<String> getContributors()
     {
         return getBagList( prefix + ":contributor" );
     }
@@ -130,7 +130,7 @@
      *
      * @return A list of java.lang.String objects.
      */
-    public List getCreators()
+    public List<String> getCreators()
     {
         return getSequenceList( prefix + ":creator" );
     }
@@ -162,7 +162,7 @@
      *
      * @throws IOException If there is an error creating the date object.
      */
-    public List getDates() throws IOException
+    public List<Calendar> getDates() throws IOException
     {
         return getSequenceDateList( prefix + ":date" );
     }
@@ -215,7 +215,7 @@
      *
      * @return A non-null list of languages, potentially an empty list.
      */
-    public List getDescriptionLanguages()
+    public List<String> getDescriptionLanguages()
     {
         return getLanguagePropertyLanguages( prefix + ":description" );
     }
@@ -285,7 +285,7 @@
      *
      * @return The list of languages.
      */
-    public List getLanguages()
+    public List<String> getLanguages()
     {
         return getBagList( prefix + ":language" );
     }
@@ -315,7 +315,7 @@
      *
      * @return The list of publishers.
      */
-    public List getPublishers()
+    public List<String> getPublishers()
     {
         return getBagList( prefix + ":publisher" );
     }
@@ -347,7 +347,7 @@
      *
      * @return The list of relationships.
      */
-    public List getRelationships()
+    public List<String> getRelationships()
     {
         return getBagList( prefix + ":relation" );
     }
@@ -401,7 +401,7 @@
      *
      * @return A non-null list of languages, potentially an empty list.
      */
-    public List getRightsLanguages()
+    public List<String> getRightsLanguages()
     {
         return getLanguagePropertyLanguages( prefix + ":rights" );
     }
@@ -451,7 +451,7 @@
      *
      * @return The list of subjects.
      */
-    public List getSubjects()
+    public List<String> getSubjects()
     {
         return getBagList( prefix + ":subject" );
     }
@@ -504,7 +504,7 @@
      *
      * @return A non-null list of languages, potentially an empty list.
      */
-    public List getTitleLanguages()
+    public List<String> getTitleLanguages()
     {
         return getLanguagePropertyLanguages( prefix + ":title" );
     }
@@ -524,7 +524,7 @@
      *
      * @return A list of types for this resource.
      */
-    public List getTypes()
+    public List<String> getTypes()
     {
         return getBagList(prefix + ":type" );
     }

Modified: pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaIptc4xmpCore.java
URL: http://svn.apache.org/viewvc/pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaIptc4xmpCore.java?rev=887689&r1=887688&r2=887689&view=diff
==============================================================================
--- pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaIptc4xmpCore.java (original)
+++ pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaIptc4xmpCore.java Sun
Dec  6 15:09:55 2009
@@ -248,7 +248,7 @@
      * 
      * @return The list of scenes.
      */
-    public List getScenes()
+    public List<String> getScenes()
     {
         return getBagList(prefix + ":Scene");
     }
@@ -267,7 +267,7 @@
      * 
      * @return All IPTC subject codes.
      */
-    public List getSubjectCodes()
+    public List<String> getSubjectCodes()
     {
         return getBagList(prefix + ":SubjectCode");
     }

Modified: pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaMediaManagement.java
URL: http://svn.apache.org/viewvc/pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaMediaManagement.java?rev=887689&r1=887688&r2=887689&view=diff
==============================================================================
--- pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaMediaManagement.java
(original)
+++ pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaMediaManagement.java
Sun Dec  6 15:09:55 2009
@@ -154,7 +154,7 @@
      * 
      * @return A list of ResourceEvent objects or null.
      */
-    public List getHistory()
+    public List<ResourceEvent> getHistory()
     {
         return getEventSequenceList( prefix + ":History" );
     }

Modified: pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaPhotoshop.java
URL: http://svn.apache.org/viewvc/pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaPhotoshop.java?rev=887689&r1=887688&r2=887689&view=diff
==============================================================================
--- pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaPhotoshop.java (original)
+++ pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaPhotoshop.java Sun
Dec  6 15:09:55 2009
@@ -294,7 +294,7 @@
      * 
      * @return The supplemental categories.
      */
-    public List getSupplementalCategories()
+    public List<String> getSupplementalCategories()
     {
         return getBagList(prefix + ":SupplementalCategories");
     }

Modified: pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaRightsManagement.java
URL: http://svn.apache.org/viewvc/pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaRightsManagement.java?rev=887689&r1=887688&r2=887689&view=diff
==============================================================================
--- pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaRightsManagement.java
(original)
+++ pdfbox/jempbox/trunk/src/main/java/org/apache/jempbox/xmp/XMPSchemaRightsManagement.java
Sun Dec  6 15:09:55 2009
@@ -120,7 +120,7 @@
      *
      * @return The list of owners.
      */
-    public List getOwners()
+    public List<String> getOwners()
     {
         return getBagList(prefix + ":Owner");
     }
@@ -173,7 +173,7 @@
      *
      * @return A non-null list of languages, potentially an empty list.
      */
-    public List getUsageTermsLanguages()
+    public List<String> getUsageTermsLanguages()
     {
         return getLanguagePropertyLanguages(prefix + ":UsageTerms");
     }

Modified: pdfbox/jempbox/trunk/src/test/java/org/apache/jempbox/xmp/XMPSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/jempbox/trunk/src/test/java/org/apache/jempbox/xmp/XMPSchemaTest.java?rev=887689&r1=887688&r2=887689&view=diff
==============================================================================
--- pdfbox/jempbox/trunk/src/test/java/org/apache/jempbox/xmp/XMPSchemaTest.java (original)
+++ pdfbox/jempbox/trunk/src/test/java/org/apache/jempbox/xmp/XMPSchemaTest.java Sun Dec 
6 15:09:55 2009
@@ -124,7 +124,7 @@
         schema.addBagValue("author", "Kent Beck");
         {
 
-            List l = schema.getBagList("author");
+            List<String> l = schema.getBagList("author");
 
             assertEquals(2, l.size());
 
@@ -135,26 +135,26 @@
         }
         {
             schema.removeBagValue("author", "Kent Beck");
-            List l = schema.getBagList("author");
+            List<String> l = schema.getBagList("author");
             assertEquals(1, l.size());
             assertTrue(l.get(0).equals("Tom DeMarco"));
         }
         { // Already removed
             schema.removeBagValue("author", "Kent Beck");
-            List l = schema.getBagList("author");
+            List<String> l = schema.getBagList("author");
             assertEquals(1, l.size());
             assertTrue(l.get(0).equals("Tom DeMarco"));
         }
         { // Duplicates allowed!
             schema.addBagValue("author", "Tom DeMarco");
-            List l = schema.getBagList("author");
+            List<String> l = schema.getBagList("author");
             assertEquals(2, l.size());
             assertTrue(l.get(0).equals("Tom DeMarco"));
             assertTrue(l.get(1).equals("Tom DeMarco"));
         }
         { // Removes both
             schema.removeBagValue("author", "Tom DeMarco");
-            List l = schema.getBagList("author");
+            List<String> l = schema.getBagList("author");
             assertEquals(0, l.size());
         }
     }
@@ -173,7 +173,7 @@
         schema.addSequenceValue("author", "Kent Beck");
         {
 
-            List l = schema.getSequenceList("author");
+            List<String> l = schema.getSequenceList("author");
 
             assertEquals(2, l.size());
 
@@ -182,26 +182,26 @@
         }
         {
             schema.removeSequenceValue("author", "Tom DeMarco");
-            List l = schema.getSequenceList("author");
+            List<String> l = schema.getSequenceList("author");
             assertEquals(1, l.size());
             assertTrue(l.get(0).equals("Kent Beck"));
         }
         { // Already removed
             schema.removeSequenceValue("author", "Tom DeMarco");
-            List l = schema.getSequenceList("author");
+            List<String> l = schema.getSequenceList("author");
             assertEquals(1, l.size());
             assertTrue(l.get(0).equals("Kent Beck"));
         }
         { // Duplicates allowed!
             schema.addSequenceValue("author", "Kent Beck");
-            List l = schema.getSequenceList("author");
+            List<String> l = schema.getSequenceList("author");
             assertEquals(2, l.size());
             assertTrue(l.get(0).equals("Kent Beck"));
             assertTrue(l.get(1).equals("Kent Beck"));
         }
         { // Remvoes all
             schema.removeSequenceValue("author", "Kent Beck");
-            List l = schema.getSequenceList("author");
+            List<String> l = schema.getSequenceList("author");
             assertEquals(0, l.size());
         }
     }
@@ -280,7 +280,7 @@
         schema.addSequenceDateValue("test:importantDates", c1);
         schema.addSequenceDateValue("test:importantDates", c2);
 
-        List l = schema.getSequenceDateList("test:importantDates");
+        List<Calendar> l = schema.getSequenceDateList("test:importantDates");
 
         assertEquals(2, l.size());
 



Mime
View raw message