commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1130906 - in /commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/src/main/java/org/apache/commons/digester3/examples/xmlrules/addressbook: AddressBook.java Person.java
Date Fri, 03 Jun 2011 05:56:50 GMT
Author: simonetripodi
Date: Fri Jun  3 05:56:50 2011
New Revision: 1130906

URL: http://svn.apache.org/viewvc?rev=1130906&view=rev
Log:
added generics to collections

Modified:
    commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/src/main/java/org/apache/commons/digester3/examples/xmlrules/addressbook/AddressBook.java
    commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/src/main/java/org/apache/commons/digester3/examples/xmlrules/addressbook/Person.java

Modified: commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/src/main/java/org/apache/commons/digester3/examples/xmlrules/addressbook/AddressBook.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/src/main/java/org/apache/commons/digester3/examples/xmlrules/addressbook/AddressBook.java?rev=1130906&r1=1130905&r2=1130906&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/src/main/java/org/apache/commons/digester3/examples/xmlrules/addressbook/AddressBook.java
(original)
+++ commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/src/main/java/org/apache/commons/digester3/examples/xmlrules/addressbook/AddressBook.java
Fri Jun  3 05:56:50 2011
@@ -24,7 +24,7 @@ import java.util.Iterator;
  * See Main.java.
  */
 public class AddressBook {
-    LinkedList people = new LinkedList();
+    LinkedList<Person> people = new LinkedList<Person>();
     
     public void addPerson(Person p) {
         people.addLast(p);
@@ -33,8 +33,8 @@ public class AddressBook {
     public void print() {
         System.out.println("Address book has " + people.size() + " entries");
 
-        for(Iterator i = people.iterator(); i.hasNext(); ) {
-            Person p = (Person) i.next();
+        for(Iterator<Person> i = people.iterator(); i.hasNext(); ) {
+            Person p = i.next();
             p.print();
         }
     }

Modified: commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/src/main/java/org/apache/commons/digester3/examples/xmlrules/addressbook/Person.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/src/main/java/org/apache/commons/digester3/examples/xmlrules/addressbook/Person.java?rev=1130906&r1=1130905&r2=1130906&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/src/main/java/org/apache/commons/digester3/examples/xmlrules/addressbook/Person.java
(original)
+++ commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/src/main/java/org/apache/commons/digester3/examples/xmlrules/addressbook/Person.java
Fri Jun  3 05:56:50 2011
@@ -29,8 +29,8 @@ public class Person {
   private int id;
   private String category;
   private String name;
-  private HashMap emails = new HashMap();
-  private List addresses = new ArrayList();
+  private HashMap<String, String> emails = new HashMap<String, String>();
+  private List<Address> addresses = new ArrayList<Address>();
   
   /** 
    * A unique id for this person. Note that the Digester automatically
@@ -62,15 +62,15 @@ public class Person {
       System.out.println("  category=" + category);
       System.out.println("  name=" + name);
       
-      for(Iterator i = emails.keySet().iterator(); i.hasNext(); ) {
-          String type = (String) i.next();
-          String address = (String) emails.get(type);
+      for(Iterator<String> i = emails.keySet().iterator(); i.hasNext(); ) {
+          String type = i.next();
+          String address = emails.get(type);
           
           System.out.println("  email (type " + type + ") : " + address);
       }
       
-      for(Iterator i = addresses.iterator(); i.hasNext(); ) {
-          Address addr = (Address) i.next();
+      for(Iterator<Address> i = addresses.iterator(); i.hasNext(); ) {
+          Address addr = i.next();
           addr.print(System.out, 2);
       }
   }



Mime
View raw message