[jboss-svn-commits] JBL Code SVN: r31592 - in labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools: runtime/rule/impl and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Feb 11 17:00:51 EST 2010


Author: baunax
Date: 2010-02-11 17:00:51 -0500 (Thu, 11 Feb 2010)
New Revision: 31592

Modified:
   labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/QueryResults.java
   labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/runtime/rule/impl/FlatQueryResults.java
   labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/runtime/rule/impl/NativeQueryResults.java
Log:
added generics

Modified: labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/QueryResults.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/QueryResults.java	2010-02-11 21:59:45 UTC (rev 31591)
+++ labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/QueryResults.java	2010-02-11 22:00:51 UTC (rev 31592)
@@ -23,8 +23,6 @@
 
 import org.drools.rule.Declaration;
 import org.drools.rule.Query;
-import org.drools.WorkingMemory;
-import org.drools.spi.Tuple;
 
 /**
  * Returned QueryResults instance for a requested named query. from here you can iterate the returned data, or
@@ -34,12 +32,12 @@
 public class QueryResults implements Iterable<QueryResult>{
     private Query           query;
 
-    private Map             declarations;
+    private Map<String, Declaration> declarations;
 
-    protected List          results;
+    protected List<FactHandle[]> results;
     protected WorkingMemory workingMemory;
 
-    public QueryResults(final List results,
+    public QueryResults(final List<FactHandle[]> results,
                         final Query query,
                         final WorkingMemory workingMemory) {
         this.results = results;
@@ -51,7 +49,7 @@
         if ( i > this.results.size() ) {
             throw new NoSuchElementException();
         }
-        return new QueryResult( (FactHandle[]) this.results.get( i ),
+        return new QueryResult( this.results.get(i),
                                 this.workingMemory,
                                 this );
     }
@@ -72,10 +70,10 @@
      * @return
      *      The Map of Declarations.
      */
-    public Map getDeclarations() {
+    public Map<String, Declaration> getDeclarations() {
 
         final Declaration[] declarations = this.query.getDeclarations();
-        final Map map = new HashMap( declarations.length );
+        final Map<String, Declaration> map = new HashMap<String, Declaration>( declarations.length );
         for ( int i = 0, length = declarations.length; i < length; i++ ) {
             map.put( declarations[i].getIdentifier(),
                      declarations[i] );
@@ -95,10 +93,10 @@
 
     private class QueryResultsIterator
         implements
-        Iterator {
-        private Iterator iterator;
+        Iterator<QueryResult> {
+        private Iterator<FactHandle[]> iterator;
 
-        public QueryResultsIterator(final Iterator iterator) {
+        public QueryResultsIterator(final Iterator<FactHandle[]> iterator) {
             this.iterator = iterator;
         }
 
@@ -106,8 +104,8 @@
             return this.iterator.hasNext();
         }
 
-        public Object next() {
-            return new QueryResult( (FactHandle[]) this.iterator.next(),
+        public QueryResult next() {
+            return new QueryResult( this.iterator.next(),
                                     QueryResults.this.workingMemory,
                                     QueryResults.this );
         }

Modified: labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/runtime/rule/impl/FlatQueryResults.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/runtime/rule/impl/FlatQueryResults.java	2010-02-11 21:59:45 UTC (rev 31591)
+++ labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/runtime/rule/impl/FlatQueryResults.java	2010-02-11 22:00:51 UTC (rev 31592)
@@ -15,11 +15,11 @@
     implements
     QueryResults {
     private Map<String, Integer> identifiers;
-    private List<List>           results;
+    private List<List<Object>>           results;
     private List<List<FactHandle>> factHandles;
 
     public FlatQueryResults(Map<String, Integer> identifiers,
-                            List<List> results,
+                            List<List<Object>> results,
                             List<List<FactHandle>> factHandles) {
         this.identifiers = identifiers;
         this.results = results;
@@ -27,8 +27,8 @@
     }
 
     public FlatQueryResults(org.drools.QueryResults results) {
-        Declaration[] declrs = (Declaration[]) results.getDeclarations().values().toArray( new Declaration[results.getDeclarations().size()] );
-        this.results = new ArrayList<List>( results.size() );
+        Declaration[] declrs = results.getDeclarations().values().toArray( new Declaration[results.getDeclarations().size()] );
+        this.results = new ArrayList<List<Object>>( results.size() );
         this.factHandles = new ArrayList<List<FactHandle>> ( results.size() );
 
         int length = declrs.length;
@@ -56,7 +56,7 @@
     }
 
     public String[] getIdentifiers() {
-        return (String[]) identifiers.keySet().toArray( new String[identifiers.size()] );
+        return identifiers.keySet().toArray( new String[identifiers.size()] );
     }
 
     public int size() {
@@ -69,15 +69,13 @@
                                          this.factHandles.iterator() );
     }
 
-    private class QueryResultsIterator
-        implements
-        Iterator {
+    private class QueryResultsIterator implements Iterator<QueryResultsRow> {
         private Map<String, Integer> identifiers;
-        private Iterator             iterator;
+        private Iterator<List<Object>> iterator;
         private Iterator<List<FactHandle>> handleIterator;
 
         public QueryResultsIterator(Map<String, Integer> identifiers,
-                                    final Iterator iterator,
+                                    final Iterator<List<Object>> iterator,
                                     final Iterator<List<FactHandle>> handleIterator) {
             this.identifiers = identifiers;
             this.iterator = iterator;
@@ -88,10 +86,10 @@
             return this.iterator.hasNext();
         }
 
-        public Object next() {
+        public QueryResultsRow next() {
             return new FlatQueryResultRow( identifiers,
-                                           (List) this.iterator.next(),
-                                           (List<FactHandle>) this.handleIterator.next() );
+                                           this.iterator.next(),
+                                           this.handleIterator.next() );
         }
 
         public void remove() {

Modified: labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/runtime/rule/impl/NativeQueryResults.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/runtime/rule/impl/NativeQueryResults.java	2010-02-11 21:59:45 UTC (rev 31591)
+++ labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-core/src/main/java/org/drools/runtime/rule/impl/NativeQueryResults.java	2010-02-11 22:00:51 UTC (rev 31592)
@@ -3,10 +3,14 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
 import org.drools.rule.Declaration;
+import org.drools.runtime.rule.QueryResults;
 import org.drools.runtime.rule.QueryResultsRow;
-import org.drools.runtime.rule.QueryResults;
 
+ at XmlAccessorType( XmlAccessType.FIELD )
 public class NativeQueryResults
     implements
     QueryResults {
@@ -18,9 +22,10 @@
     }
 
     public String[] getIdentifiers() {
-        return (String[]) this.results.getDeclarations().keySet().toArray( new String[this.results.getDeclarations().size()] );
+        return this.results.getDeclarations().keySet().toArray( new String[this.results.getDeclarations().size()] );
     }
     
+    
     public Map<String, Declaration> getDeclarations() {
         return this.results.getDeclarations();
     }
@@ -35,10 +40,10 @@
 
     private class QueryResultsIterator
         implements
-        Iterator {
-        private Iterator iterator;
+        Iterator<QueryResultsRow> {
+        private Iterator<org.drools.QueryResult> iterator;
 
-        public QueryResultsIterator(final Iterator iterator) {
+        public QueryResultsIterator(final Iterator<org.drools.QueryResult> iterator) {
             this.iterator = iterator;
         }
 
@@ -46,8 +51,8 @@
             return this.iterator.hasNext();
         }
 
-        public Object next() {
-            return new NativeQueryResultRow( (org.drools.QueryResult) this.iterator.next() );
+        public QueryResultsRow next() {
+            return new NativeQueryResultRow(this.iterator.next());
         }
 
         public void remove() {



More information about the jboss-svn-commits mailing list