[jboss-cvs] JBossAS SVN: r75181 - projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jun 29 16:45:15 EDT 2008


Author: flavia.rainone at jboss.com
Date: 2008-06-29 16:45:15 -0400 (Sun, 29 Jun 2008)
New Revision: 75181

Modified:
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/InternalNode.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/MultiValueLeafNode.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Node.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SingleValueLeafNode.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotCollection.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Tree.java
Log:
[JBAOP-503] Improved generics support on the tree.

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/InternalNode.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/InternalNode.java	2008-06-29 18:04:02 UTC (rev 75180)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/InternalNode.java	2008-06-29 20:45:15 UTC (rev 75181)
@@ -81,7 +81,8 @@
       return this;
    }
    
-   public void search(Collection<E> result, SearchKey searchKey)
+   @SuppressWarnings("all")   
+   public void search(Collection<? super E> result, SearchKey searchKey)
    {
       char nextChar = searchKey.matches(super.keyPart);
       if (nextChar == Flags.ALL)

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/MultiValueLeafNode.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/MultiValueLeafNode.java	2008-06-29 18:04:02 UTC (rev 75180)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/MultiValueLeafNode.java	2008-06-29 20:45:15 UTC (rev 75181)
@@ -73,7 +73,7 @@
       return null;
    }
    
-   public void search(Collection<E> result, SearchKey searchKey)
+   public void search(Collection<? super E> result, SearchKey searchKey)
    {
       char nextChar = searchKey.matches(super.keyPart);
       if (nextChar == Flags.POSITIVE)

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Node.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Node.java	2008-06-29 18:04:02 UTC (rev 75180)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Node.java	2008-06-29 20:45:15 UTC (rev 75181)
@@ -58,7 +58,7 @@
     * @return a <code>Collection</code> of the objects identified by the keys
     *         matched by the search key
     */
-   public abstract void search(Collection<E> result, SearchKey searchKey);
+   public abstract void search(Collection<? super E> result, SearchKey searchKey);
    
    /**
     * Searchs by the single value whose key equals {@code searchKey}.

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SingleValueLeafNode.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SingleValueLeafNode.java	2008-06-29 18:04:02 UTC (rev 75180)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SingleValueLeafNode.java	2008-06-29 20:45:15 UTC (rev 75181)
@@ -54,7 +54,7 @@
    
    protected LeafNode<E> insertValue(E value)
    {
-      return new MultiValueLeafNode(this.keyPart, this.value, value);
+      return new MultiValueLeafNode<E>(this.keyPart, this.value, value);
    }
    
    public E searchValue(SearchKey searchKey)
@@ -67,7 +67,7 @@
       return null;
    }
    
-   public void search(Collection<E> result, SearchKey searchKey)
+   public void search(Collection<? super E> result, SearchKey searchKey)
    {
       char nextChar = searchKey.matches(super.keyPart);
       if (nextChar == Flags.POSITIVE)

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotCollection.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotCollection.java	2008-06-29 18:04:02 UTC (rev 75180)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotCollection.java	2008-06-29 20:45:15 UTC (rev 75181)
@@ -116,6 +116,7 @@
     * @see #loadSlot(char)
     * @see #isSlotEmpty()
     */
+   @SuppressWarnings("all")
    public final E getSlotContent()
    {
       slotIndex = flagSystem.calculateFlagIndex();

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Tree.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Tree.java	2008-06-29 18:04:02 UTC (rev 75180)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Tree.java	2008-06-29 20:45:15 UTC (rev 75181)
@@ -23,6 +23,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 
 import org.jboss.aop.joinpoint.graph.tree.insertion.InsertionKey;
 import org.jboss.aop.joinpoint.graph.tree.search.SearchKey;
@@ -40,12 +41,12 @@
    /**
     * Root of the tree.
     */
-   private Node root;
+   private Node<E> root;
    
    /**
     * State of the tree: empty or not.
     */
-   private State state;
+   private State<E> state;
    
    /**
     * Constructs an empty tree.
@@ -82,7 +83,7 @@
     * @param result a collection where all values matched by <code>
     *         searchKeyExpresion</code> will be added
     */
-   public void search(String searchKeyExpression, Collection<E> result)
+   public void search(String searchKeyExpression, Collection<? super E> result)
    {
       SearchKey searchKey = new SearchKey(searchKeyExpression);
       state.search(searchKey, result);
@@ -122,7 +123,7 @@
     */
    public E searchValue(String searchKey)
    {
-      return (E) state.searchElement(new SearchKey(searchKey));
+      return state.searchElement(new SearchKey(searchKey));
    }
    
    /**
@@ -132,31 +133,31 @@
     * @author Flavia Rainone
     *
     */
-   interface State
+   interface State<T>
    {
       /**
        * Performs an insertion in the tree.
        * @see Tree#insert(String, Object)
        */
-      <E> void insert(InsertionKey insertionKey, E value);
+      void insert(InsertionKey insertionKey, T value);
       
       /**
        * Performs a search in the tree.
        * @see Tree#searchValue(String)
        */
-      <E> Collection<E> search(SearchKey searchKey);
+      Collection<T> search(SearchKey searchKey);
       
       /**
        * Performs a search in the tree.
        * @see Tree#search(String, Collection)
        */
-      <E> void search(SearchKey searchKey, Collection<E> result);
+      void search(SearchKey searchKey, Collection<? super T> result);
       
       /**
        * Performs a search for a specific element in the tree.
        * @see Tree#searchElement(String)
        */
-      <E> E searchElement(SearchKey searchKey);
+      T searchElement(SearchKey searchKey);
    }
 
    /**
@@ -165,23 +166,23 @@
     * 
     * @author Flavia Rainone
     */
-   class EmptyState implements State
+   class EmptyState implements State<E>
    {
-      public <E> void insert(InsertionKey insertionKey, E value)
+      public void insert(InsertionKey insertionKey, E value)
       {
          root = new SingleValueLeafNode<E>(insertionKey.toKeyPart(), value);
          state = new NotEmptyState();
          
       }
       
-      public <E> Collection<E> search(SearchKey searchKey)
+      public Collection<E> search(SearchKey searchKey)
       {
          return new ArrayList<E>();
       }
       
-      public <E> void search(SearchKey searchKey, Collection<E> result) {}
+      public void search(SearchKey searchKey, Collection<? super E> result) {}
       
-      public <E> E searchElement(SearchKey searchKey)
+      public E searchElement(SearchKey searchKey)
       {
          return null;
       }
@@ -193,30 +194,30 @@
     * 
     * @author Flavia Rainone
     */
-   class NotEmptyState implements State
+   class NotEmptyState implements State<E>
    {
-      public <E> void insert(InsertionKey insertionKey, E value)
+      public void insert(InsertionKey insertionKey, E value)
       {
          root = root.insert(insertionKey, value);
       }
       
-      public <E> Collection<E> search(SearchKey searchKey)
+      public Collection<E> search(SearchKey searchKey)
       {
          //return root.search(searchKey);
-    	  Collection<E> result = new ArrayList<E>();
+    	  Collection<E> result = new HashSet<E>();
     	  root.search(result, searchKey);
     	  return result;
       }
       
-      public <E> void search(SearchKey searchKey, Collection<E> result)
+      public void search(SearchKey searchKey, Collection<? super E> result)
       {
          //return root.search(searchKey);
         root.search(result, searchKey);
       }
       
-      public <E> E searchElement(SearchKey searchKey)
+      public E searchElement(SearchKey searchKey)
       {
-         return (E) root.searchValue(searchKey);
+         return root.searchValue(searchKey);
       }
    }
    




More information about the jboss-cvs-commits mailing list