Revision: 17546
          http://sourceforge.net/p/gate/code/17546
Author:   markagreenwood
Date:     2014-03-05 20:54:08 +0000 (Wed, 05 Mar 2014)
Log Message:
-----------
the last generics updates before bed

Modified Paths:
--------------
    gate/trunk/src/main/gate/Factory.java
    gate/trunk/src/main/gate/FeatureMap.java
    gate/trunk/src/main/gate/util/SimpleFeatureMapImpl.java
    gate/trunk/src/main/gate/util/SimpleMapImpl.java

Modified: gate/trunk/src/main/gate/Factory.java
===================================================================
--- gate/trunk/src/main/gate/Factory.java       2014-03-05 18:38:46 UTC (rev 
17545)
+++ gate/trunk/src/main/gate/Factory.java       2014-03-05 20:54:08 UTC (rev 
17546)
@@ -813,20 +813,18 @@
     }
   }
 
-  static Class<ParseCpsl> japeParserClass = ParseCpsl.class;
-  public static Class<ParseCpsl> getJapeParserClass() {
+  static Class<? extends ParseCpsl> japeParserClass = ParseCpsl.class;
+  public static Class<? extends ParseCpsl> getJapeParserClass() {
       return japeParserClass;
   }
-  @SuppressWarnings("unchecked")
-  public static void setJapeParserClass(Class newClass) {
-      if (! ParseCpsl.class.isAssignableFrom(newClass))
-          throw new IllegalArgumentException("Parser class must inherit from " 
+ ParseCpsl.class);
+
+  public static void setJapeParserClass(Class<? extends ParseCpsl> newClass) {
       japeParserClass = newClass;
   }
 
   public static ParseCpsl newJapeParser(java.io.Reader stream, Map 
existingMacros) {
       try {
-          Constructor<ParseCpsl> c = japeParserClass.getConstructor
+          Constructor<? extends ParseCpsl> c = japeParserClass.getConstructor
               (new Class[] {java.io.Reader.class, existingMacros.getClass()});
           return c.newInstance(new Object[] {stream, existingMacros});
       } catch (NoSuchMethodException e) { // Shouldn't happen

Modified: gate/trunk/src/main/gate/FeatureMap.java
===================================================================
--- gate/trunk/src/main/gate/FeatureMap.java    2014-03-05 18:38:46 UTC (rev 
17545)
+++ gate/trunk/src/main/gate/FeatureMap.java    2014-03-05 20:54:08 UTC (rev 
17546)
@@ -57,7 +57,7 @@
     * from aFeatureMap are included in <b>this</b> obj, or <code>false</code>
     * otherwise.
     */
-  public boolean subsumes(FeatureMap aFeatureMap, Set aFeatureNamesSet);
+  public boolean subsumes(FeatureMap aFeatureMap, Set<? extends Object> 
aFeatureNamesSet);
 
   /**
    *

Modified: gate/trunk/src/main/gate/util/SimpleFeatureMapImpl.java
===================================================================
--- gate/trunk/src/main/gate/util/SimpleFeatureMapImpl.java     2014-03-05 
18:38:46 UTC (rev 17545)
+++ gate/trunk/src/main/gate/util/SimpleFeatureMapImpl.java     2014-03-05 
20:54:08 UTC (rev 17546)
@@ -249,7 +249,7 @@
     * otherwise.
     */
   @Override
-  public boolean subsumes(FeatureMap aFeatureMap, Set aFeatureNamesSet){
+  public boolean subsumes(FeatureMap aFeatureMap, Set<? extends Object> 
aFeatureNamesSet){
     // This means that all features are taken into consideration.
     if (aFeatureNamesSet == null) return this.subsumes(aFeatureMap);
     // null is included in everything
@@ -353,14 +353,15 @@
 //////////////////THE EVENT HANDLING CODE//////////////
 //Needed so an annotation can listen to its features//
 //and update correctly the database//////////////////
-  private transient Vector mapListeners;
+  private transient Vector<FeatureMapListener> mapListeners;
   /**
    * Removes a gate listener
    */
   @Override
   public synchronized void removeFeatureMapListener(FeatureMapListener l) {
     if (mapListeners != null && mapListeners.contains(l)) {
-      Vector v = (Vector) mapListeners.clone();
+      @SuppressWarnings("unchecked")
+      Vector<FeatureMapListener> v = (Vector<FeatureMapListener>) 
mapListeners.clone();
       v.removeElement(l);
       mapListeners = v;
     }
@@ -370,7 +371,8 @@
    */
   @Override
   public synchronized void addFeatureMapListener(FeatureMapListener l) {
-    Vector v = mapListeners == null ? new Vector(2) : 
(Vector)mapListeners.clone();
+    @SuppressWarnings("unchecked")
+    Vector<FeatureMapListener> v = mapListeners == null ? new 
Vector<FeatureMapListener>(2) : 
(Vector<FeatureMapListener>)mapListeners.clone();
     if (!v.contains(l)) {
       v.addElement(l);
       mapListeners = v;
@@ -382,11 +384,11 @@
    */
   protected void fireMapUpdatedEvent () {
     if (mapListeners != null) {
-      Vector listeners = mapListeners;
+      Vector<FeatureMapListener> listeners = mapListeners;
       int count = listeners.size();
       if (count == 0) return;
       for (int i = 0; i < count; i++)
-        ((FeatureMapListener) listeners.elementAt(i)).featureMapUpdated();
+        listeners.elementAt(i).featureMapUpdated();
     }
   }//fireMapUpdatedEvent
 

Modified: gate/trunk/src/main/gate/util/SimpleMapImpl.java
===================================================================
--- gate/trunk/src/main/gate/util/SimpleMapImpl.java    2014-03-05 18:38:46 UTC 
(rev 17545)
+++ gate/trunk/src/main/gate/util/SimpleMapImpl.java    2014-03-05 20:54:08 UTC 
(rev 17546)
@@ -70,11 +70,11 @@
   transient static Object nullKey = new NullKey();
 
   /** the static 'all keys' collection */
-  transient public static ConcurrentHashMap theKeysHere;
+  transient public static ConcurrentHashMap<Object,Object> theKeysHere;
 
   /** additional static members initialization */
   static {
-    theKeysHere = new ConcurrentHashMap();
+    theKeysHere = new ConcurrentHashMap<Object,Object>();
     theKeysHere.put(nullKey, nullKey);
   } // static code
 
@@ -106,7 +106,7 @@
    * Not supported. This method is here only to conform the Map interface
    */
   @Override
-  public Collection values() {
+  public Collection<Object> values() {
     throw new UnsupportedOperationException(
       "SimpleMapImpl.values() not implemented!");
   } // values()
@@ -116,9 +116,9 @@
    * affect the map.
    */
   @Override
-  public Set keySet()
+  public Set<Object> keySet()
   {
-    HashSet s = new HashSet(size());
+    Set<Object> s = new HashSet<Object>(size());
     Object k;
     for (int i = 0; i < count; i++) {
       k = theKeys[i];
@@ -236,7 +236,7 @@
    * put all the elements from a map
    */
   @Override
-  public void putAll(Map t)
+  public void putAll(Map<? extends Object, ? extends Object> t)
   {
     if (t == null) {
       throw new UnsupportedOperationException(
@@ -327,7 +327,7 @@
   /**
    * Auxiliary classes needed for the support of entrySet() method
    */
-  private static class Entry implements Map.Entry {
+  private static class Entry implements Map.Entry<Object,Object> {
     int hash;
     Object key;
     Object value;
@@ -364,7 +364,7 @@
     public boolean equals(Object o) {
       if (!(o instanceof Map.Entry))
         return false;
-      Map.Entry e = (Map.Entry)o;
+      Map.Entry<?,?> e = (Map.Entry<?,?>)o;
 
       return (key==null ? e.getKey()==null : key.equals(e.getKey())) &&
         (value==null ? e.getValue()==null : value.equals(e.getValue()));
@@ -383,9 +383,9 @@
 
 
   @Override
-  public Set entrySet() {
-    HashSet s = new HashSet(size());
-    Object v, k;
+  public Set<Map.Entry<Object, Object>> entrySet() {
+    Set<Map.Entry<Object, Object>> s = new 
HashSet<Map.Entry<Object,Object>>(size());
+    Object k;
     for (int i = 0; i < count; i++) {
       k = theKeys[i];
       s.add(new Entry(k.hashCode(), ((k==nullKey)?null:k), theValues[i]));
@@ -427,7 +427,7 @@
   @Override
   public int hashCode() {
     int h = 0;
-    Iterator i = entrySet().iterator();
+    Iterator<Map.Entry<Object,Object>> i = entrySet().iterator();
     while (i.hasNext())
       h += i.next().hashCode();
     return h;
@@ -459,11 +459,11 @@
   public String toString() {
     int max = size() - 1;
     StringBuffer buf = new StringBuffer();
-    Iterator i = entrySet().iterator();
+    Iterator<Map.Entry<Object, Object>> i = entrySet().iterator();
 
     buf.append("{");
     for (int j = 0; j <= max; j++) {
-      Entry e = (Entry) (i.next());
+      Map.Entry<Object, Object> e = (i.next());
       buf.append(e.getKey() + "=" + e.getValue());
       if (j < max)
         buf.append(", ");

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to