BATIK-1204: Add generics

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/batik/trunk@1813521 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/batik-anim/src/main/java/org/apache/batik/anim/dom/SVG12DOMImplementation.java b/batik-anim/src/main/java/org/apache/batik/anim/dom/SVG12DOMImplementation.java
index 8ced7c0..7c0ceb2 100644
--- a/batik-anim/src/main/java/org/apache/batik/anim/dom/SVG12DOMImplementation.java
+++ b/batik-anim/src/main/java/org/apache/batik/anim/dom/SVG12DOMImplementation.java
@@ -174,7 +174,7 @@
     /**
      * The SVG element factories.
      */
-    protected static HashMap svg12Factories = new HashMap(svg11Factories);
+    protected static HashMap<String, ElementFactory> svg12Factories = new HashMap<String, ElementFactory>(svg11Factories);
 
     static {
         svg12Factories.put(SVG12Constants.SVG_FLOW_DIV_TAG,
@@ -414,7 +414,7 @@
     /**
      * The XBL element factories.
      */
-    protected static HashMap xblFactories = new HashMap();
+    protected static HashMap<String, ElementFactory> xblFactories = new HashMap<String, ElementFactory>();
 
     static {
         xblFactories.put(XBLConstants.XBL_XBL_TAG,
diff --git a/batik-anim/src/main/java/org/apache/batik/anim/dom/SVGDOMImplementation.java b/batik-anim/src/main/java/org/apache/batik/anim/dom/SVGDOMImplementation.java
index 38438e2..6f8da3d 100644
--- a/batik-anim/src/main/java/org/apache/batik/anim/dom/SVGDOMImplementation.java
+++ b/batik-anim/src/main/java/org/apache/batik/anim/dom/SVGDOMImplementation.java
@@ -77,7 +77,7 @@
     protected static final String RESOURCES =
         "org.apache.batik.dom.svg.resources.Messages";
 
-    protected HashMap factories;
+    protected HashMap<String, ElementFactory> factories;
 
     /**
      * Returns the default instance of this class.
@@ -173,7 +173,7 @@
      * Creates a stylesheet from the data of an xml-stylesheet
      * processing instruction or return null.
      */
-    public StyleSheet createStyleSheet(Node n, HashMap attrs) {
+    public StyleSheet createStyleSheet(Node n, HashMap<String, String> attrs) {
         throw new UnsupportedOperationException
             ("StyleSheetFactory.createStyleSheet is not implemented"); // XXX
     }
@@ -233,7 +233,7 @@
     /**
      * The SVG element factories.
      */
-    protected static HashMap svg11Factories = new HashMap();
+    protected static HashMap<String, ElementFactory> svg11Factories = new HashMap<String, ElementFactory>();
 
     static {
         svg11Factories.put(SVGConstants.SVG_A_TAG,
diff --git a/batik-anim/src/main/java/org/apache/batik/anim/dom/SVGStyleSheetProcessingInstruction.java b/batik-anim/src/main/java/org/apache/batik/anim/dom/SVGStyleSheetProcessingInstruction.java
index 107c6c5..09a9f16 100644
--- a/batik-anim/src/main/java/org/apache/batik/anim/dom/SVGStyleSheetProcessingInstruction.java
+++ b/batik-anim/src/main/java/org/apache/batik/anim/dom/SVGStyleSheetProcessingInstruction.java
@@ -80,14 +80,14 @@
      */
     public StyleSheet getCSSStyleSheet() {
         if (styleSheet == null) {
-            HashMap attrs = getPseudoAttributes();
-            String type = (String)attrs.get("type");
+            HashMap<String, String> attrs = getPseudoAttributes();
+            String type = attrs.get("type");
 
             if ("text/css".equals(type)) {
-                String title     = (String)attrs.get("title");
-                String media     = (String)attrs.get("media");
-                String href      = (String)attrs.get("href");
-                String alternate = (String)attrs.get("alternate");
+                String title     = attrs.get("title");
+                String media     = attrs.get("media");
+                String href      = attrs.get("href");
+                String alternate = attrs.get("alternate");
                 SVGOMDocument doc = (SVGOMDocument)getOwnerDocument();
                 ParsedURL durl = doc.getParsedURL();
                 ParsedURL burl = new ParsedURL(durl, href);
diff --git a/batik-anim/src/main/java/org/apache/batik/anim/dom/XBLEventSupport.java b/batik-anim/src/main/java/org/apache/batik/anim/dom/XBLEventSupport.java
index fafeca5..866a199 100644
--- a/batik-anim/src/main/java/org/apache/batik/anim/dom/XBLEventSupport.java
+++ b/batik-anim/src/main/java/org/apache/batik/anim/dom/XBLEventSupport.java
@@ -50,17 +50,17 @@
     /**
      * The unstoppable capturing listeners table.
      */
-    protected HashMap capturingImplementationListeners;
+    protected HashMap<String, EventListenerList> capturingImplementationListeners;
 
     /**
      * The unstoppable bubbling listeners table.
      */
-    protected HashMap bubblingImplementationListeners;
+    protected HashMap<String, EventListenerList> bubblingImplementationListeners;
 
     /**
      * Map of event types to their aliases.
      */
-    protected static HashMap eventTypeAliases = new HashMap();
+    protected static HashMap<String, String> eventTypeAliases = new HashMap<String, String>();
     static {
         eventTypeAliases.put("SVGLoad",   "load");
         eventTypeAliases.put("SVGUnoad",  "unload");
@@ -125,19 +125,19 @@
                                                  String type,
                                                  EventListener listener,
                                                  boolean useCapture) {
-        HashMap listeners;
+        HashMap<String, EventListenerList> listeners;
         if (useCapture) {
             if (capturingImplementationListeners == null) {
-                capturingImplementationListeners = new HashMap();
+                capturingImplementationListeners = new HashMap<String, EventListenerList>();
             }
             listeners = capturingImplementationListeners;
         } else {
             if (bubblingImplementationListeners == null) {
-                bubblingImplementationListeners = new HashMap();
+                bubblingImplementationListeners = new HashMap<String, EventListenerList>();
             }
             listeners = bubblingImplementationListeners;
         }
-        EventListenerList list = (EventListenerList) listeners.get(type);
+        EventListenerList list = listeners.get(type);
         if (list == null) {
             list = new EventListenerList();
             listeners.put(type, list);
@@ -152,12 +152,12 @@
                                                     String type,
                                                     EventListener listener,
                                                     boolean useCapture) {
-        HashMap listeners = useCapture ? capturingImplementationListeners
-                                         : bubblingImplementationListeners;
+        HashMap<String, EventListenerList> listeners = useCapture
+            ? capturingImplementationListeners : bubblingImplementationListeners;
         if (listeners == null) {
             return;
         }
-        EventListenerList list = (EventListenerList) listeners.get(type);
+        EventListenerList list = listeners.get(type);
         if (list == null) {
             return;
         }
@@ -439,12 +439,9 @@
      */
     public EventListenerList getImplementationEventListeners
             (String type, boolean useCapture) {
-        HashMap listeners = useCapture ? capturingImplementationListeners
-                                         : bubblingImplementationListeners;
-        if (listeners == null) {
-            return null;
-        }
-        return (EventListenerList) listeners.get(type);
+        HashMap<String, EventListenerList> listeners = useCapture
+            ? capturingImplementationListeners : bubblingImplementationListeners;
+        return listeners != null ? listeners.get(type) : null;
     }
 
     /**
diff --git a/batik-dom/src/main/java/org/apache/batik/dom/AbstractDOMImplementation.java b/batik-dom/src/main/java/org/apache/batik/dom/AbstractDOMImplementation.java
index 541f27a..84a531c 100644
--- a/batik-dom/src/main/java/org/apache/batik/dom/AbstractDOMImplementation.java
+++ b/batik-dom/src/main/java/org/apache/batik/dom/AbstractDOMImplementation.java
@@ -58,7 +58,7 @@
     /**
      * The supported features.
      */
-    protected final HashMap features = new HashMap();
+    protected final HashMap<String, Object> features = new HashMap<String, Object>();
     {
         // registerFeature("BasicEvents",        "3.0");
         registerFeature("Core",               new String[] { "2.0", "3.0" });
diff --git a/batik-dom/src/main/java/org/apache/batik/dom/StyleSheetFactory.java b/batik-dom/src/main/java/org/apache/batik/dom/StyleSheetFactory.java
index 08b4df7..1f49d20 100644
--- a/batik-dom/src/main/java/org/apache/batik/dom/StyleSheetFactory.java
+++ b/batik-dom/src/main/java/org/apache/batik/dom/StyleSheetFactory.java
@@ -36,5 +36,5 @@
      * processing instruction or return null when it is not possible
      * to create the given stylesheet.
      */
-    StyleSheet createStyleSheet(Node node, HashMap pseudoAttrs);
+    StyleSheet createStyleSheet(Node node, HashMap<String, String> pseudoAttrs);
 }
diff --git a/batik-dom/src/main/java/org/apache/batik/dom/StyleSheetProcessingInstruction.java b/batik-dom/src/main/java/org/apache/batik/dom/StyleSheetProcessingInstruction.java
index 0ffcdbd..9964170 100644
--- a/batik-dom/src/main/java/org/apache/batik/dom/StyleSheetProcessingInstruction.java
+++ b/batik-dom/src/main/java/org/apache/batik/dom/StyleSheetProcessingInstruction.java
@@ -57,7 +57,7 @@
     /**
      * The pseudo attributes.
      */
-    protected transient HashMap pseudoAttributes;
+    protected transient HashMap<String, String> pseudoAttributes;
 
     /**
      * Creates a new ProcessingInstruction object.
@@ -118,9 +118,9 @@
     /**
      * Returns the pseudo attributes in a table.
      */
-    public HashMap getPseudoAttributes() {
+    public HashMap<String, String> getPseudoAttributes() {
         if (pseudoAttributes == null) {
-            pseudoAttributes = new HashMap();
+            pseudoAttributes = new HashMap<String, String>();
             pseudoAttributes.put("alternate", "no");
             pseudoAttributes.put("media",     "all");
             DOMUtilities.parseStyleSheetPIData(data, pseudoAttributes);
diff --git a/batik-dom/src/main/java/org/apache/batik/dom/events/DocumentEventSupport.java b/batik-dom/src/main/java/org/apache/batik/dom/events/DocumentEventSupport.java
index 04410f8..5c6580d 100644
--- a/batik-dom/src/main/java/org/apache/batik/dom/events/DocumentEventSupport.java
+++ b/batik-dom/src/main/java/org/apache/batik/dom/events/DocumentEventSupport.java
@@ -100,7 +100,7 @@
     /**
      * The event factories table.
      */
-    protected HashMap eventFactories = new HashMap();
+    protected HashMap<String, EventFactory> eventFactories = new HashMap<String, EventFactory>();
     {
         // DOM 3 event names:
         eventFactories.put(EVENT_TYPE.toLowerCase(),
@@ -163,7 +163,7 @@
      */
     public Event createEvent(String eventType)
             throws DOMException {
-        EventFactory ef = (EventFactory)eventFactories.get(eventType.toLowerCase());
+        EventFactory ef = eventFactories.get(eventType.toLowerCase());
         if (ef == null) {
             throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
                                    "Bad event type: " + eventType);
diff --git a/batik-dom/src/main/java/org/apache/batik/dom/events/EventSupport.java b/batik-dom/src/main/java/org/apache/batik/dom/events/EventSupport.java
index bd645c5..f9a799b 100644
--- a/batik-dom/src/main/java/org/apache/batik/dom/events/EventSupport.java
+++ b/batik-dom/src/main/java/org/apache/batik/dom/events/EventSupport.java
@@ -44,12 +44,12 @@
     /**
      * The capturing listeners table.
      */
-    protected HashMap capturingListeners;
+    protected HashMap<String, EventListenerList> capturingListeners;
 
     /**
      * The bubbling listeners table.
      */
-    protected HashMap bubblingListeners;
+    protected HashMap<String, EventListenerList> bubblingListeners;
 
     /**
      * The node for which events are being handled.
@@ -105,7 +105,7 @@
                                    EventListener listener,
                                    boolean useCapture,
                                    Object group) {
-        HashMap listeners;
+        HashMap<String, EventListenerList> listeners;
         if (useCapture) {
             if (capturingListeners == null) {
                 capturingListeners = new HashMap();
@@ -117,7 +117,7 @@
             }
             listeners = bubblingListeners;
         }
-        EventListenerList list = (EventListenerList) listeners.get(type);
+        EventListenerList list = listeners.get(type);
         if (list == null) {
             list = new EventListenerList();
             listeners.put(type, list);
@@ -164,7 +164,7 @@
                                       String type,
                                       EventListener listener,
                                       boolean useCapture) {
-        HashMap listeners;
+        HashMap<String, EventListenerList> listeners;
         if (useCapture) {
             listeners = capturingListeners;
         } else {
@@ -173,7 +173,7 @@
         if (listeners == null) {
             return;
         }
-        EventListenerList list = (EventListenerList) listeners.get(type);
+        EventListenerList list = listeners.get(type);
         if (list != null) {
             list.removeListener(namespaceURI, listener);
             if (list.size() == 0) {
@@ -388,8 +388,7 @@
      */
     public boolean hasEventListenerNS(String namespaceURI, String type) {
         if (capturingListeners != null) {
-            EventListenerList ell
-                = (EventListenerList) capturingListeners.get(type);
+            EventListenerList ell = capturingListeners.get(type);
             if (ell != null) {
                 if (ell.hasEventListener(namespaceURI)) {
                     return true;
@@ -397,8 +396,7 @@
             }
         }
         if (bubblingListeners != null) {
-            EventListenerList ell
-                = (EventListenerList) capturingListeners.get(type);
+            EventListenerList ell = capturingListeners.get(type);
             if (ell != null) {
                 return ell.hasEventListener(namespaceURI);
             }
@@ -414,12 +412,12 @@
      */
     public EventListenerList getEventListeners(String type,
                                                boolean useCapture) {
-        HashMap listeners
+        HashMap<String, EventListenerList> listeners
             = useCapture ? capturingListeners : bubblingListeners;
         if (listeners == null) {
             return null;
         }
-        return (EventListenerList) listeners.get(type);
+        return listeners.get(type);
     }
 
     /**
diff --git a/batik-dom/src/main/java/org/apache/batik/dom/util/DOMUtilities.java b/batik-dom/src/main/java/org/apache/batik/dom/util/DOMUtilities.java
index 1165ae8..fd02570 100644
--- a/batik-dom/src/main/java/org/apache/batik/dom/util/DOMUtilities.java
+++ b/batik-dom/src/main/java/org/apache/batik/dom/util/DOMUtilities.java
@@ -852,7 +852,7 @@
      * Parses a 'xml-stylesheet' processing instruction data section and
      * puts the pseudo attributes in the given table.
      */
-    public static void parseStyleSheetPIData(String data, HashMap table) {
+    public static void parseStyleSheetPIData(String data, HashMap<String, String> table) {
         // !!! Internationalization
         char c;
         int i = 0;
diff --git a/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java b/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
index f3c040a..3640879 100644
--- a/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
+++ b/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
@@ -2042,9 +2042,9 @@
                     if (n instanceof StyleSheetProcessingInstruction) {
                         StyleSheetProcessingInstruction sspi;
                         sspi = (StyleSheetProcessingInstruction)n;
-                        HashMap attrs = sspi.getPseudoAttributes();
-                        final String title = (String)attrs.get("title");
-                        String alt = (String)attrs.get("alternate");
+                        HashMap<String, String> attrs = sspi.getPseudoAttributes();
+                        final String title = attrs.get("title");
+                        String alt = attrs.get("alternate");
                         if (title != null && "yes".equals(alt)) {
                             JRadioButtonMenuItem button;
                             button = new JRadioButtonMenuItem(title);
diff --git a/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/XMLInputHandler.java b/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/XMLInputHandler.java
index d7eada5..a9637d9 100644
--- a/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/XMLInputHandler.java
+++ b/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/XMLInputHandler.java
@@ -293,7 +293,7 @@
                 ProcessingInstruction pi 
                     = (ProcessingInstruction)child;
                 
-                HashMap table = new HashMap();
+                HashMap<String, String> table = new HashMap<String, String>();
                 DOMUtilities.parseStyleSheetPIData(pi.getData(),
                                                    table);