You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2014/06/24 11:07:06 UTC

svn commit: r1605034 [10/16] - in /jena/trunk: jena-arq/src/main/java/arq/ jena-arq/src/main/java/arq/cmdline/ jena-arq/src/main/java/com/hp/hpl/jena/query/ jena-arq/src/main/java/com/hp/hpl/jena/sparql/ jena-arq/src/main/java/com/hp/hpl/jena/sparql/al...

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/FBRuleInfGraph.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/FBRuleInfGraph.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/FBRuleInfGraph.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/FBRuleInfGraph.java Tue Jun 24 09:06:50 2014
@@ -142,7 +142,7 @@ public class FBRuleInfGraph  extends Bas
         initLP(schema);  
         tempNodecache = new TempNodeCache(this);
         if (JenaParameters.enableFilteringOfHiddenInfNodes) {
-            hiddenNodes = new HashSet<Node>();
+            hiddenNodes = new HashSet<>();
             if (schema != null && schema instanceof FBRuleInfGraph) {
                 hiddenNodes.addAll(((FBRuleInfGraph)schema).hiddenNodes);
             }
@@ -268,10 +268,10 @@ public class FBRuleInfGraph  extends Bas
      * Adds a set of new Backward rules
      */
     public void addBRules(List<Rule> rules) {
-        for (Iterator<Rule> i = rules.iterator(); i.hasNext(); ) {
-            Rule rule = i.next();
-//            logger.debug("Adding rule " + rule);
-            bEngine.addRule(rule);
+        for ( Rule rule : rules )
+        {
+            //            logger.debug("Adding rule " + rule);
+            bEngine.addRule( rule );
         }
         bEngine.reset();
     }
@@ -345,7 +345,7 @@ public class FBRuleInfGraph  extends Bas
     public void addRuleDuringPrepare(Rule rule) {
         if (rules == rawRules) {
             // Ensure the original is preserved in case we need to do a restart
-            rules = new ArrayList<Rule>( rawRules );
+            rules = new ArrayList<>( rawRules );
 //            if (rawRules instanceof ArrayList) {
 //                rules = (ArrayList<Rule>) ((ArrayList<Rule>)rawRules).clone();
 //            } else {
@@ -363,7 +363,7 @@ public class FBRuleInfGraph  extends Bas
      */
     public void addPreprocessingHook(RulePreprocessHook hook) {
         if (preprocessorHooks == null) {
-            preprocessorHooks = new ArrayList<RulePreprocessHook>();
+            preprocessorHooks = new ArrayList<>();
         }
         preprocessorHooks.add(hook);
     }
@@ -420,15 +420,18 @@ public class FBRuleInfGraph  extends Bas
                 }
             }
             // Insert any axiomatic statements into the caches
-            for (Iterator<Rule> i = rules.iterator(); i.hasNext(); ) {
-                Rule r = i.next();
-                if (r.bodyLength() == 0) {
+            for ( Rule r : rules )
+            {
+                if ( r.bodyLength() == 0 )
+                {
                     // An axiom
-                    for (int j = 0; j < r.headLength(); j++) {
-                        Object head = r.getHeadElement(j);
-                        if (head instanceof TriplePattern) {
+                    for ( int j = 0; j < r.headLength(); j++ )
+                    {
+                        Object head = r.getHeadElement( j );
+                        if ( head instanceof TriplePattern )
+                        {
                             TriplePattern h = (TriplePattern) head;
-                            transitiveEngine.add(h.asTriple());
+                            transitiveEngine.add( h.asTriple() );
                         }
                     }
                 }
@@ -448,9 +451,9 @@ public class FBRuleInfGraph  extends Bas
         // Call any optional preprocessing hook
         if (preprocessorHooks != null && preprocessorHooks.size() > 0) {
             Graph inserts = Factory.createGraphMem();
-            for (Iterator<RulePreprocessHook> i = preprocessorHooks.iterator(); i.hasNext(); ) {
-                RulePreprocessHook hook = i.next();
-                hook.run(this, dataFind, inserts);
+            for ( RulePreprocessHook hook : preprocessorHooks )
+            {
+                hook.run( this, dataFind, inserts );
             }
             if (inserts.size() > 0) {
                 FGraph finserts = new FGraph(inserts);
@@ -523,7 +526,7 @@ public class FBRuleInfGraph  extends Bas
         engine.setDerivationLogging(recordDerivations);
         bEngine.setDerivationLogging(recordDerivations);
         if (recordDerivations) {
-            derivations = new OneToManyMap<Triple, Derivation>();
+            derivations = new OneToManyMap<>();
         } else {
             derivations = null;
         }
@@ -627,9 +630,12 @@ public class FBRuleInfGraph  extends Bas
             boolean needReset = false;
             if (preprocessorHooks != null && preprocessorHooks.size() > 0) {
                 if (preprocessorHooks.size() > 1) {
-                    for (Iterator<RulePreprocessHook> i = preprocessorHooks.iterator(); i.hasNext();) {
-                        if (i.next().needsRerun(this, t)) {
-                            needReset = true; break;
+                    for ( RulePreprocessHook preprocessorHook : preprocessorHooks )
+                    {
+                        if ( preprocessorHook.needsRerun( this, t ) )
+                        {
+                            needReset = true;
+                            break;
                         }
                     }
                 } else {
@@ -779,11 +785,12 @@ public class FBRuleInfGraph  extends Bas
      */
     protected void performDatatypeRangeValidation(StandardValidityReport report) {
         HashMap<Node, List<RDFDatatype>> dtRange = getDTRange();
-        for (Iterator<Node> props = dtRange.keySet().iterator(); props.hasNext(); ) {
-            Node prop = props.next();
-            for (Iterator<Triple> i = find(null, prop, null); i.hasNext(); ) {
+        for ( Node prop : dtRange.keySet() )
+        {
+            for ( Iterator<Triple> i = find( null, prop, null ); i.hasNext(); )
+            {
                 Triple triple = i.next();
-                report.add(checkLiteral(prop, triple));
+                report.add( checkLiteral( prop, triple ) );
             }
         }
     }
@@ -805,13 +812,13 @@ public class FBRuleInfGraph  extends Bas
                 return new ValidityReport.Report(true, "dtRange", 
                     "Property " + prop + " has a typed range but was given a non literal value " + value);
             }
-            LiteralLabel ll = value.getLiteral();   
-            for (Iterator<RDFDatatype> i = range.iterator(); i.hasNext(); ) {
-                RDFDatatype dt = i.next();
-                if (!dt.isValidLiteral(ll)) {
-                    return new ValidityReport.Report(true, "dtRange", 
-                        "Property " + prop + " has a typed range " + dt +
-                        "that is not compatible with " + value, triple);
+            LiteralLabel ll = value.getLiteral();
+            for ( RDFDatatype dt : range )
+            {
+                if ( !dt.isValidLiteral( ll ) )
+                {
+                    return new ValidityReport.Report( true, "dtRange", "Property " + prop + " has a typed range " + dt +
+                        "that is not compatible with " + value, triple );
                 }
             }
         }
@@ -824,7 +831,7 @@ public class FBRuleInfGraph  extends Bas
      */
     protected HashMap<Node, List<RDFDatatype>> getDTRange() {
         if (dtRange == null) {
-            dtRange = new HashMap<Node, List<RDFDatatype>>();
+            dtRange = new HashMap<>();
             for (Iterator<Triple> i = find(null, RDFS.range.asNode(), null); i.hasNext(); ) {
                 Triple triple = i.next();
                 Node prop = triple.getSubject();
@@ -834,7 +841,7 @@ public class FBRuleInfGraph  extends Bas
                     if (dt != null) {
                         List<RDFDatatype> range = dtRange.get(prop);
                         if (range == null) {
-                            range = new ArrayList<RDFDatatype>();
+                            range = new ArrayList<>();
                             dtRange.put(prop, range);
                         }
                         range.add(dt);
@@ -853,11 +860,12 @@ public class FBRuleInfGraph  extends Bas
      * and transfer these rules to the backward engine. 
      */
     private static List<Rule> extractPureBackwardRules(List<Rule> rules) {
-        List<Rule> bRules = new ArrayList<Rule>();
-        for (Iterator<Rule> i = rules.iterator(); i.hasNext(); ) {
-            Rule r = i.next();
-            if (r.isBackward() && r.bodyLength() > 0) {
-                bRules.add(r);
+        List<Rule> bRules = new ArrayList<>();
+        for ( Rule r : rules )
+        {
+            if ( r.isBackward() && r.bodyLength() > 0 )
+            {
+                bRules.add( r );
             }
         }
         return bRules;
@@ -897,7 +905,7 @@ public class FBRuleInfGraph  extends Bas
     public void hideNode(Node n) {
         if (! JenaParameters.enableFilteringOfHiddenInfNodes) return;
         if (hiddenNodes == null) {
-            hiddenNodes = new HashSet<Node>();
+            hiddenNodes = new HashSet<>();
         }
         synchronized (hiddenNodes) {
             hiddenNodes.add(n);

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/FBRuleReasoner.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/FBRuleReasoner.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/FBRuleReasoner.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/FBRuleReasoner.java Tue Jun 24 09:06:50 2014
@@ -37,7 +37,7 @@ public class FBRuleReasoner implements R
     protected ReasonerFactory factory;
 
     /** The rules to be used by this instance of the forward engine */
-    protected List<Rule> rules = new ArrayList<Rule>();
+    protected List<Rule> rules = new ArrayList<>();
     
     /** A precomputed set of schema deductions */
     protected Graph schemaGraph;
@@ -128,7 +128,7 @@ public class FBRuleReasoner implements R
          TODO review & revise
     */
     public FBRuleReasoner addRules(List<Rule> rules) {
-        List<Rule> combined = new ArrayList<Rule>( this.rules );
+        List<Rule> combined = new ArrayList<>( this.rules );
         combined.addAll( rules );
         setRules( combined );
         return this;

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Functor.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Functor.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Functor.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Functor.java Tue Jun 24 09:06:50 2014
@@ -117,9 +117,10 @@ public class Functor implements ClauseEn
      * Returns true if the functor is fully ground, no variables
      */
     public boolean isGround() {
-        for (int i = 0; i < args.length; i++) {
-            Node n = args[i];
-            if (n instanceof Node_RuleVariable || n instanceof Node_ANY) {
+        for ( Node n : args )
+        {
+            if ( n instanceof Node_RuleVariable || n instanceof Node_ANY )
+            {
                 return false;
             }
         }
@@ -130,9 +131,12 @@ public class Functor implements ClauseEn
      * Returns true if the functor is fully ground in the given environment
      */
     public boolean isGround(BindingEnvironment env) {
-        for (int i = 0; i < args.length; i++) {
-            Node n = args[i];
-            if (env.getGroundVersion(args[i]).isVariable()) return false;
+        for ( Node n : args )
+        {
+            if ( env.getGroundVersion( n ).isVariable() )
+            {
+                return false;
+            }
         }
         return true;
     }
@@ -201,7 +205,7 @@ public class Functor implements ClauseEn
      */
     @Override
     public String toString() {
-        StringBuffer buff = new StringBuffer(name);
+        StringBuilder buff = new StringBuilder(name);
         buff.append("(");
         for (int i = 0; i < args.length; i++) {
             buff.append(PrintUtil.print(args[i]));

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/GenericRuleReasoner.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/GenericRuleReasoner.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/GenericRuleReasoner.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/GenericRuleReasoner.java Tue Jun 24 09:06:50 2014
@@ -192,7 +192,7 @@ public class GenericRuleReasoner extends
      */
     public void addPreprocessingHook(RulePreprocessHook hook) {
         if (preprocessorHooks == null) {
-            preprocessorHooks = new HashSet<RulePreprocessHook>();
+            preprocessorHooks = new HashSet<>();
         }
         preprocessorHooks.add(hook);
     }
@@ -341,8 +341,9 @@ public class GenericRuleReasoner extends
         grr.setTransitiveClosureCaching(enableTGCCaching);
         grr.setFunctorFiltering(filterFunctors);
         if (preprocessorHooks != null) {
-            for (Iterator<RulePreprocessHook> i = preprocessorHooks.iterator(); i.hasNext(); ) {
-                grr.addPreprocessingHook(i.next());
+            for ( RulePreprocessHook preprocessorHook : preprocessorHooks )
+            {
+                grr.addPreprocessingHook( preprocessorHook );
             }
         }
         return grr;
@@ -381,8 +382,9 @@ public class GenericRuleReasoner extends
             fbgraph.setTraceOn(traceOn);
             fbgraph.setFunctorFiltering(filterFunctors);
             if (preprocessorHooks!= null) {
-                for (Iterator<RulePreprocessHook> i = preprocessorHooks.iterator(); i.hasNext(); ) {
-                    fbgraph.addPreprocessingHook(i.next());
+                for ( RulePreprocessHook preprocessorHook : preprocessorHooks )
+                {
+                    fbgraph.addPreprocessingHook( preprocessorHook );
                 }
             }
         }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/LPBackwardRuleInfGraph.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/LPBackwardRuleInfGraph.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/LPBackwardRuleInfGraph.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/LPBackwardRuleInfGraph.java Tue Jun 24 09:06:50 2014
@@ -240,7 +240,7 @@ public class LPBackwardRuleInfGraph exte
     public void setDerivationLogging(boolean recordDerivations) {
         engine.setDerivationLogging(recordDerivations);
         if (recordDerivations) {
-            derivations = new OneToManyMap<Triple, Derivation>();
+            derivations = new OneToManyMap<>();
         } else {
             derivations = null;
         }
@@ -253,7 +253,7 @@ public class LPBackwardRuleInfGraph exte
     @Override
     public Iterator<Derivation> getDerivation(Triple t) {
         if (derivations == null) {
-            return new NullIterator<Derivation>();
+            return new NullIterator<>();
         } else {
             return derivations.getAll(t);
         }
@@ -336,27 +336,34 @@ public class LPBackwardRuleInfGraph exte
     protected void extractAxioms() {
         Graph axioms = fdeductions.getGraph();
         BBRuleContext contextForBuiltins = null;
-        for (Iterator<Rule> i = engine.getRuleStore().getAllRules().iterator(); i.hasNext(); ) {
-            Rule rule = i.next();
-            if (rule.bodyLength() == 0) {
+        for ( Rule rule : engine.getRuleStore().getAllRules() )
+        {
+            if ( rule.bodyLength() == 0 )
+            {
                 // An axiom
-                for (int j = 0; j < rule.headLength(); j++) {
-                    ClauseEntry axiom = rule.getHeadElement(j);
-                    if (axiom instanceof TriplePattern) {
-                        axioms.add(((TriplePattern)axiom).asTriple());
-                    } else if (axiom instanceof Functor) {
-                        if (contextForBuiltins == null) {
-                            contextForBuiltins = new BBRuleContext(this);
+                for ( int j = 0; j < rule.headLength(); j++ )
+                {
+                    ClauseEntry axiom = rule.getHeadElement( j );
+                    if ( axiom instanceof TriplePattern )
+                    {
+                        axioms.add( ( (TriplePattern) axiom ).asTriple() );
+                    }
+                    else if ( axiom instanceof Functor )
+                    {
+                        if ( contextForBuiltins == null )
+                        {
+                            contextForBuiltins = new BBRuleContext( this );
                         }
-                        Functor f = (Functor)axiom;
+                        Functor f = (Functor) axiom;
                         Builtin implementation = f.getImplementor();
-                        if (implementation == null) {
-                            throw new ReasonerException("Attempted to invoke undefined functor: " + f);
+                        if ( implementation == null )
+                        {
+                            throw new ReasonerException( "Attempted to invoke undefined functor: " + f );
                         }
                         Node[] args = f.getArgs();
-                        contextForBuiltins.setEnv(new BindingVector(args));
-                        contextForBuiltins.setRule(rule);
-                        implementation.headAction(args, args.length, contextForBuiltins);
+                        contextForBuiltins.setEnv( new BindingVector( args ) );
+                        contextForBuiltins.setRule( rule );
+                        implementation.headAction( args, args.length, contextForBuiltins );
                     }
                 }
             }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLFBRuleReasonerFactory.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLFBRuleReasonerFactory.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLFBRuleReasonerFactory.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLFBRuleReasonerFactory.java Tue Jun 24 09:06:50 2014
@@ -68,7 +68,7 @@ public class OWLFBRuleReasonerFactory im
             }
             Boolean doTrace = Util.checkBinaryPredicate(ReasonerVocabulary.PROPtraceOn, configuration);
             if (doTrace != null) {
-                reasoner.setTraceOn(doTrace.booleanValue());
+                reasoner.setTraceOn( doTrace );
             }
         }
         return reasoner;

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLMicroReasonerFactory.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLMicroReasonerFactory.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLMicroReasonerFactory.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLMicroReasonerFactory.java Tue Jun 24 09:06:50 2014
@@ -71,7 +71,7 @@ public class OWLMicroReasonerFactory imp
             }
             Boolean doTrace = Util.checkBinaryPredicate(ReasonerVocabulary.PROPtraceOn, configuration);
             if (doTrace != null) {
-                reasoner.setTraceOn(doTrace.booleanValue());
+                reasoner.setTraceOn( doTrace );
             }
         }
         return reasoner;

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLMiniReasonerFactory.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLMiniReasonerFactory.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLMiniReasonerFactory.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/OWLMiniReasonerFactory.java Tue Jun 24 09:06:50 2014
@@ -66,7 +66,7 @@ public class OWLMiniReasonerFactory impl
             }
             Boolean doTrace = Util.checkBinaryPredicate(ReasonerVocabulary.PROPtraceOn, configuration);
             if (doTrace != null) {
-                reasoner.setTraceOn(doTrace.booleanValue());
+                reasoner.setTraceOn( doTrace );
             }
         }
         return reasoner;

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/RDFSRuleReasoner.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/RDFSRuleReasoner.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/RDFSRuleReasoner.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/RDFSRuleReasoner.java Tue Jun 24 09:06:50 2014
@@ -53,7 +53,7 @@ public class RDFSRuleReasoner extends Ge
     protected static final String SIMPLE_RULE_FILE = "etc/rdfs-fb-tgc-simple.rules";
     
     /** The cached rule sets, indexed by processing level */
-    protected static Map<String, List<Rule>> ruleSets = new HashMap<String, List<Rule>>();
+    protected static Map<String, List<Rule>> ruleSets = new HashMap<>();
     
     /** The rule file names, indexed by processing level */
     protected static Map<String, String> ruleFiles;
@@ -62,7 +62,7 @@ public class RDFSRuleReasoner extends Ge
     protected static RulePreprocessHook cmpProcessor = new RDFSCMPPreprocessHook();
     
     static {
-        ruleFiles = new HashMap<String, String>();
+        ruleFiles = new HashMap<>();
         ruleFiles.put(DEFAULT_RULES, RULE_FILE);
         ruleFiles.put(FULL_RULES, FULL_RULE_FILE);
         ruleFiles.put(SIMPLE_RULES, SIMPLE_RULE_FILE);

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Rule.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Rule.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Rule.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Rule.java Tue Jun 24 09:06:50 2014
@@ -149,14 +149,22 @@ public class Rule implements ClauseEntry
     // Compute the monotonicity flag
     // Future support for negation would affect this
     private boolean allMonotonic(ClauseEntry[] elts) {
-        for (int i = 0; i < elts.length; i++) {
-            ClauseEntry elt = elts[i];
-            if (elt instanceof Functor) {
-                Builtin b = ((Functor)elt).getImplementor();
-                if (b != null) {
-                    if (! b.isMonotonic() ) return false;
-                } else {
-                    throw new ReasonerException("Undefined Functor " + ((Functor)elt).getName() +" in " + toShortString());
+        for ( ClauseEntry elt : elts )
+        {
+            if ( elt instanceof Functor )
+            {
+                Builtin b = ( (Functor) elt ).getImplementor();
+                if ( b != null )
+                {
+                    if ( !b.isMonotonic() )
+                    {
+                        return false;
+                    }
+                }
+                else
+                {
+                    throw new ReasonerException(
+                        "Undefined Functor " + ( (Functor) elt ).getName() + " in " + toShortString() );
                 }
             }
         }
@@ -259,12 +267,15 @@ public class Rule implements ClauseEntry
      */
     private int findVars(Object[] nodes, int maxIn) {
         int max = maxIn;
-        for (int i = 0; i < nodes.length; i++) {
-            Object node = nodes[i];
-            if (node instanceof TriplePattern) {
-                max = findVars((TriplePattern)node, max);
-            } else {
-                max = findVars((Functor)node, max); 
+        for ( Object node : nodes )
+        {
+            if ( node instanceof TriplePattern )
+            {
+                max = findVars( (TriplePattern) node, max );
+            }
+            else
+            {
+                max = findVars( (Functor) node, max );
             }
         }
         return max;
@@ -292,8 +303,12 @@ public class Rule implements ClauseEntry
     private int findVars(Functor f, int maxIn) {
         int max = maxIn;
         Node[] args = f.getArgs();
-        for (int i = 0; i < args.length; i++) {
-            if (args[i].isVariable()) max = maxVarIndex(args[i], max);
+        for ( Node arg : args )
+        {
+            if ( arg.isVariable() )
+            {
+                max = maxVarIndex( arg, max );
+            }
         }
         return max;
     }
@@ -315,7 +330,7 @@ public class Rule implements ClauseEntry
      * for trail implementations.
      */
     public Rule instantiate(BindingEnvironment env) {
-        HashMap<Node_RuleVariable, Node> vmap = new HashMap<Node_RuleVariable, Node>();
+        HashMap<Node_RuleVariable, Node> vmap = new HashMap<>();
         return new Rule(name, cloneClauseArray(head, vmap, env), cloneClauseArray(body, vmap, env));
     }
     
@@ -324,7 +339,7 @@ public class Rule implements ClauseEntry
      */
     public Rule cloneRule() {
         if (getNumVars() > 0) {
-            HashMap<Node_RuleVariable, Node> vmap = new HashMap<Node_RuleVariable, Node>();
+            HashMap<Node_RuleVariable, Node> vmap = new HashMap<>();
             return new Rule(name, cloneClauseArray(head, vmap, null), cloneClauseArray(body, vmap, null));
         } else {
             return this;
@@ -407,8 +422,10 @@ public class Rule implements ClauseEntry
      */
     public boolean isAxiom() {
         if (isBackward() && body.length > 0) return false;
-        for (int i = 0; i < body.length; i++) {
-            if (body[i] instanceof TriplePattern) {
+        for ( ClauseEntry aBody : body )
+        {
+            if ( aBody instanceof TriplePattern )
+            {
                 return false;
             }
         }
@@ -420,31 +437,35 @@ public class Rule implements ClauseEntry
      */
     @Override
     public String toString() {
-        StringBuffer buff = new StringBuffer();
+        StringBuilder buff = new StringBuilder();
         buff.append("[ ");
         if (name != null) {
             buff.append(name);
             buff.append(": ");
         }
-        if (isBackward) { 
-            for (int i = 0; i < head.length; i++) {
-                buff.append(PrintUtil.print(head[i]));
-                buff.append(" ");
+        if (isBackward) {
+            for ( ClauseEntry aHead : head )
+            {
+                buff.append( PrintUtil.print( aHead ) );
+                buff.append( " " );
             }
             buff.append("<- ");
-            for (int i = 0; i < body.length; i++) {
-                buff.append(PrintUtil.print(body[i]));
-                buff.append(" ");
+            for ( ClauseEntry aBody : body )
+            {
+                buff.append( PrintUtil.print( aBody ) );
+                buff.append( " " );
             }
         } else {
-            for (int i = 0; i < body.length; i++) {
-                buff.append(PrintUtil.print(body[i]));
-                buff.append(" ");
+            for ( ClauseEntry aBody : body )
+            {
+                buff.append( PrintUtil.print( aBody ) );
+                buff.append( " " );
             }
             buff.append("-> ");
-            for (int i = 0; i < head.length; i++) {
-                buff.append(PrintUtil.print(head[i]));
-                buff.append(" ");
+            for ( ClauseEntry aHead : head )
+            {
+                buff.append( PrintUtil.print( aHead ) );
+                buff.append( " " );
             }
         }
         buff.append("]");
@@ -499,10 +520,10 @@ public class Rule implements ClauseEntry
     */
     public static Parser rulesParserFromReader( BufferedReader src ) {
        try {
-           StringBuffer result = new StringBuffer();
+           StringBuilder result = new StringBuilder();
            String line;
-           Map<String, String> prefixes = new HashMap<String, String>();
-           List<Rule> preloadedRules = new ArrayList<Rule>();
+           Map<String, String> prefixes = new HashMap<>();
+           List<Rule> preloadedRules = new ArrayList<>();
            while ((line = src.readLine()) != null) {
                if (line.startsWith("#")) continue;     // Skip comment lines
                line = line.trim();
@@ -609,7 +630,7 @@ public class Rule implements ClauseEntry
      */
     public static List<Rule> parseRules(Parser parser) throws ParserException {
         boolean finished = false;
-        List<Rule> ruleset = new ArrayList<Rule>();
+        List<Rule> ruleset = new ArrayList<>();
         ruleset.addAll(parser.getRulesPreload());
         while (!finished) {
             try {
@@ -658,7 +679,7 @@ public class Rule implements ClauseEntry
         private int literalState = NORMAL;
         
         /** Trace back of recent tokens for error reporting */
-        protected List<String> priorTokens = new ArrayList<String>();
+        protected List<String> priorTokens = new ArrayList<>();
         
         /** Maximum number of recent tokens to remember */
         private static final int maxPriors = 20;
@@ -670,7 +691,7 @@ public class Rule implements ClauseEntry
         private PrefixMapping prefixMapping = PrefixMapping.Factory.create();
         
         /** Pre-included rules */
-        private List<Rule> preloadedRules = new ArrayList<Rule>();
+        private List<Rule> preloadedRules = new ArrayList<>();
         
         /**
          * Constructor
@@ -752,7 +773,7 @@ public class Rule implements ClauseEntry
          * in error reporting
          */
         public String recentTokens() {
-            StringBuffer trace = new StringBuffer();
+            StringBuilder trace = new StringBuilder();
             for (int i = priorTokens.size()-1; i >= 0; i--) {
                 trace.append(priorTokens.get(i));
                 trace.append(" ");
@@ -894,7 +915,7 @@ public class Rule implements ClauseEntry
         Node parseNumber(String lit) {
             if ( Character.isDigit(lit.charAt(0)) || 
                 (lit.charAt(0) == '-' && lit.length() > 1 && Character.isDigit(lit.charAt(1))) ) {
-                if (lit.indexOf(".") != -1) {
+                if ( lit.contains( "." ) ) {
                     // Float?
                     if (XSDDatatype.XSDfloat.isValid(lit)) {
                         return NodeFactory.createLiteral(lit, "", XSDDatatype.XSDfloat);
@@ -919,7 +940,7 @@ public class Rule implements ClauseEntry
                 throw new ParserException("Expected '(' at start of clause, found " + token, this);
             }
             token = nextToken();
-            List<Node> nodeList = new ArrayList<Node>();
+            List<Node> nodeList = new ArrayList<>();
             while (!isSyntax(token)) {
                 nodeList.add(parseNode(token));
                 token = nextToken();
@@ -990,16 +1011,16 @@ public class Rule implements ClauseEntry
                     nextToken();
                 }
                 // Start rule parsing with empty variable table
-                if (!retainVarMap) varMap = new HashMap<String, Node_RuleVariable>();
+                if (!retainVarMap) varMap = new HashMap<>();
                 // Body
-                List<ClauseEntry> body = new ArrayList<ClauseEntry>();
+                List<ClauseEntry> body = new ArrayList<>();
                 token = peekToken();
                 while ( !(token.equals("->") || token.equals("<-")) ) {
                     body.add(parseClause());
                     token = peekToken();
                 }
                 boolean backwardRule = token.equals("<-");
-                List<ClauseEntry> head = new ArrayList<ClauseEntry>();
+                List<ClauseEntry> head = new ArrayList<>();
                 token = nextToken();   // skip -> token
                 token = peekToken();
                 while ( !(token.equals(".") || token.equals("]")) ) {
@@ -1051,11 +1072,13 @@ public class Rule implements ClauseEntry
     @Override
     public int hashCode() {
         int hash = 0;
-        for (int i = 0; i < body.length; i++) {
-            hash = (hash << 1) ^ body[i].hashCode();
-        }
-        for (int i = 0; i < head.length; i++) {
-            hash = (hash << 1) ^ head[i].hashCode();
+        for ( ClauseEntry aBody : body )
+        {
+            hash = ( hash << 1 ) ^ aBody.hashCode();
+        }
+        for ( ClauseEntry aHead : head )
+        {
+            hash = ( hash << 1 ) ^ aHead.hashCode();
         }
         return hash;
     }
@@ -1087,7 +1110,7 @@ public class Rule implements ClauseEntry
          * Extract context trace from prior tokens stack
          */
         private static String constructMessage(String baseMessage, Parser parser) {
-            StringBuffer message = new StringBuffer();
+            StringBuilder message = new StringBuilder();
             message.append(baseMessage);
             message.append("\nAt '");
             message.append(parser.recentTokens());

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Util.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Util.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Util.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/Util.java Tue Jun 24 09:06:50 2014
@@ -213,7 +213,7 @@ public class Util {
      * Construct a new integer valued node
      */
     public static Node makeIntNode(int value) {
-        return NodeFactory.createLiteral(LiteralLabelFactory.create(new Integer(value)));
+        return NodeFactory.createLiteral(LiteralLabelFactory.create( value ));
     }
 
     /**
@@ -221,9 +221,9 @@ public class Util {
      */
     public static Node makeLongNode(long value) {
         if (value > Integer.MAX_VALUE) {
-            return NodeFactory.createLiteral(LiteralLabelFactory.create(new Long(value)));
+            return NodeFactory.createLiteral(LiteralLabelFactory.create( value ));
         } else {
-            return NodeFactory.createLiteral(LiteralLabelFactory.create(new Integer((int)value)));
+            return NodeFactory.createLiteral(LiteralLabelFactory.create( (int) value ));
         }
     }
 
@@ -231,7 +231,7 @@ public class Util {
      * Construct a new double valued node
      */
     public static Node makeDoubleNode(double value) {
-        return NodeFactory.createLiteral(LiteralLabelFactory.create(new Double(value)));
+        return NodeFactory.createLiteral(LiteralLabelFactory.create( value ));
     }
 
     /**
@@ -293,7 +293,7 @@ public class Util {
     public static Boolean checkBinaryPredicate(Property predicate, Resource configuration) {
         StmtIterator i = configuration.listProperties(predicate);
         if (i.hasNext()) {
-            return new Boolean(i.nextStatement().getObject().toString().equalsIgnoreCase("true"));
+            return i.nextStatement().getObject().toString().equalsIgnoreCase( "true" );
         } else {
             return null;
         }
@@ -311,7 +311,7 @@ public class Util {
         if (i.hasNext()) {
             RDFNode lit = i.nextStatement().getObject();
             if (lit instanceof Literal) {
-                return new Integer(((Literal)lit).getInt());
+                return ( (Literal) lit ).getInt();
             }
         }
         return null;

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/AssertDisjointPairs.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/AssertDisjointPairs.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/AssertDisjointPairs.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/AssertDisjointPairs.java Tue Jun 24 09:06:50 2014
@@ -58,12 +58,13 @@ public class AssertDisjointPairs extends
     public void headAction(Node[] args, int length, RuleContext context) {
         checkArgs(length, context);
         List<Node> l = Util.convertList(args[0], context);
-        for (Iterator<Node> i = l.iterator(); i.hasNext(); ) {
-            Node x = i.next();
-            for (Iterator<Node> j = l.iterator(); j.hasNext(); ) {
-                Node y = j.next();
-                if (!x.sameValueAs(y)) {
-                    context.add( new Triple(x, OWL.differentFrom.asNode(), y) );
+        for ( Node x : l )
+        {
+            for ( Node y : l )
+            {
+                if ( !x.sameValueAs( y ) )
+                {
+                    context.add( new Triple( x, OWL.differentFrom.asNode(), y ) );
                 }
             }
         }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/CountLiteralValues.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/CountLiteralValues.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/CountLiteralValues.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/CountLiteralValues.java Tue Jun 24 09:06:50 2014
@@ -57,7 +57,7 @@ public class CountLiteralValues extends 
      */
     @Override
     public boolean bodyCall(Node[] args, int length, RuleContext context) {
-        List<Node> values = new ArrayList<Node>();
+        List<Node> values = new ArrayList<>();
         Node a0 = getArg(0, args, context);
         Node a1 = getArg(1, args, context);
         for (Iterator<Triple> ni = context.find(a0, a1, null); ni.hasNext(); ) {
@@ -66,8 +66,10 @@ public class CountLiteralValues extends 
                 // Can't just use contains because distinct objects may
                 // be semantically equal
                 boolean gotit = false;
-                for (Iterator<Node> i = values.iterator(); i.hasNext(); ) {
-                    if (v.sameValueAs(i.next())) {
+                for ( Node value : values )
+                {
+                    if ( v.sameValueAs( value ) )
+                    {
                         gotit = true;
                         break;
                     }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListEqual.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListEqual.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListEqual.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListEqual.java Tue Jun 24 09:06:50 2014
@@ -70,19 +70,22 @@ public class ListEqual extends BaseBuilt
         List<Node> elts1 = Util.convertList(list1, context);
         List<Node> elts2 = Util.convertList(list2, context);
         if (elts1.size() != elts2.size()) return false;
-        for (Iterator<Node> i = elts1.iterator(); i.hasNext(); ) {
-            Node elt = i.next();
+        for ( Node elt : elts1 )
+        {
             boolean matched = false;
-            for (Iterator<Node> j = elts2.iterator(); j.hasNext(); ) {
+            for ( Iterator<Node> j = elts2.iterator(); j.hasNext(); )
+            {
                 Node elt2 = j.next();
-                if (elt.sameValueAs(elt2)) {
+                if ( elt.sameValueAs( elt2 ) )
+                {
                     // Found match, consume it
                     j.remove();
                     matched = true;
                     break;
                 }
             }
-            if (!matched) {
+            if ( !matched )
+            {
                 return false;
             }
         }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListMapAsObject.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListMapAsObject.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListMapAsObject.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListMapAsObject.java Tue Jun 24 09:06:50 2014
@@ -64,8 +64,8 @@ public class ListMapAsObject extends Bas
         Node n1 = getArg(1, args, context);
         Node n2 = getArg(2, args, context);
         List<Node> l = Util.convertList(n2, context);
-        for (Iterator<Node> i = l.iterator(); i.hasNext(); ) {
-            Node x = i.next();
+        for ( Node x : l )
+        {
             context.add( new Triple( n0, n1, x ) );
         }
     }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListMapAsSubject.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListMapAsSubject.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListMapAsSubject.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/ListMapAsSubject.java Tue Jun 24 09:06:50 2014
@@ -63,9 +63,9 @@ public class ListMapAsSubject extends Ba
         Node n1 = getArg(1, args, context);
         Node n2 = getArg(2, args, context);
         List<Node>l = Util.convertList(n0, context);
-        for (Iterator<Node> i = l.iterator(); i.hasNext(); ) {
-            Node x = i.next();
-            context.add( new Triple(x, n1, n2));
+        for ( Node x : l )
+        {
+            context.add( new Triple( x, n1, n2 ) );
         }
     }
     

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/StrConcat.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/StrConcat.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/StrConcat.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/StrConcat.java Tue Jun 24 09:06:50 2014
@@ -62,7 +62,7 @@ public class StrConcat extends BaseBuilt
     public boolean bodyCall(Node[] args, int length, RuleContext context) {
         if (length < 1) 
             throw new BuiltinException(this, context, "Must have at least 1 argument to " + getName());
-        StringBuffer buff = new StringBuffer();
+        StringBuilder buff = new StringBuilder();
         for (int i = 0; i < length-1; i++) {
             buff.append( lex(getArg(i, args, context), context) );
         }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/UriConcat.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/UriConcat.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/UriConcat.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/builtins/UriConcat.java Tue Jun 24 09:06:50 2014
@@ -53,7 +53,7 @@ public class UriConcat extends StrConcat
     public boolean bodyCall(Node[] args, int length, RuleContext context) {
         if (length < 1) 
             throw new BuiltinException(this, context, "Must have at least 1 argument to " + getName());
-        StringBuffer buff = new StringBuffer();
+        StringBuilder buff = new StringBuilder();
         for (int i = 0; i < length-1; i++) {
             buff.append( lex(getArg(i, args, context), context) );
         }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BFRuleContext.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BFRuleContext.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BFRuleContext.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BFRuleContext.java Tue Jun 24 09:06:50 2014
@@ -50,7 +50,7 @@ public class BFRuleContext implements Ru
     protected List<Triple> pending;
 
     /** A temporary list of Triples which will be removed from the graph at the end of a rule scan */
-    protected List<Triple> deletesPending = new ArrayList<Triple>();
+    protected List<Triple> deletesPending = new ArrayList<>();
 
     /** A searchable index into the pending triples */
     protected Graph pendingCache;
@@ -64,8 +64,8 @@ public class BFRuleContext implements Ru
     public BFRuleContext(ForwardRuleInfGraphI graph) {
         this.graph = graph;
         env = new BindingStack();
-        stack = new ArrayList<Triple>();
-        pending = new ArrayList<Triple>();
+        stack = new ArrayList<>();
+        pending = new ArrayList<>();
         pendingCache = Factory.createGraphMem();
     }
     
@@ -162,9 +162,9 @@ public class BFRuleContext implements Ru
         }
         pending.clear();
         // Flush out pending removes as well
-        for (Iterator<Triple> i = deletesPending.iterator(); i.hasNext(); ) {
-            Triple t = i.next();
-            graph.delete(t);
+        for ( Triple t : deletesPending )
+        {
+            graph.delete( t );
         }
         deletesPending.clear();
     }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingStack.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingStack.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingStack.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingStack.java Tue Jun 24 09:06:50 2014
@@ -41,7 +41,7 @@ public class BindingStack implements Bin
     protected Node[] environment;
     
     /** A stack of prior binding sets */
-    protected ArrayList<Node[]> trail = new ArrayList<Node[]>();
+    protected ArrayList<Node[]> trail = new ArrayList<>();
     
     /** Index of the current binding set */
     protected int index = 0;
@@ -126,14 +126,16 @@ public class BindingStack implements Bin
             Functor functor = (Functor)node.getLiteralValue();
             if (functor.isGround()) return node;
             Node[] args = functor.getArgs();
-            List<Node> boundargs = new ArrayList<Node>(args.length);
-            for (int i = 0; i < args.length; i++) {
-                Node binding = getBinding(args[i]);
-                if (binding == null) {
+            List<Node> boundargs = new ArrayList<>(args.length);
+            for ( Node arg : args )
+            {
+                Node binding = getBinding( arg );
+                if ( binding == null )
+                {
                     // Not sufficent bound to instantiate functor yet
                     return null;
                 }
-                boundargs.add(binding);
+                boundargs.add( binding );
             }
             Functor newf = new Functor(functor.getName(), boundargs);
             return Functor.makeFunctorNode( newf );

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingVector.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingVector.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingVector.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingVector.java Tue Jun 24 09:06:50 2014
@@ -87,14 +87,16 @@ public class BindingVector implements Bi
             Functor functor = (Functor)node.getLiteralValue();
             if (functor.isGround()) return node;
             Node[] args = functor.getArgs();
-            List<Node> boundargs = new ArrayList<Node>(args.length);
-            for (int i = 0; i < args.length; i++) {
-                Node binding = getBinding(args[i]);
-                if (binding == null) {
+            List<Node> boundargs = new ArrayList<>(args.length);
+            for ( Node arg : args )
+            {
+                Node binding = getBinding( arg );
+                if ( binding == null )
+                {
                     // Not sufficently bound to instantiate functor yet
                     return null;
                 }
-                boundargs.add(binding);
+                boundargs.add( binding );
             }
             Functor newf = new Functor( functor.getName(), boundargs );
             return Functor.makeFunctorNode( newf );
@@ -205,13 +207,17 @@ public class BindingVector implements Bi
     @Override
     public String toString() {
         StringBuffer buffer = new StringBuffer();
-        for (int i = 0; i < environment.length; i++) {
-            if (environment[i] == null) {
-                buffer.append("-");
-            } else {
-                buffer.append(PrintUtil.print(environment[i]));
+        for ( Node anEnvironment : environment )
+        {
+            if ( anEnvironment == null )
+            {
+                buffer.append( "-" );
+            }
+            else
+            {
+                buffer.append( PrintUtil.print( anEnvironment ) );
             }
-            buffer.append(" ");
+            buffer.append( " " );
         }
         return buffer.toString();
     }
@@ -360,9 +366,9 @@ public class BindingVector implements Bi
     @Override
     public int hashCode() {
         int hash = 0;
-        for (int i = 0; i < environment.length; i++) {
-            Node n = environment[i];
-            hash = (hash << 1) ^ (n == null ? 0x537c: n.hashCode());
+        for ( Node n : environment )
+        {
+            hash = ( hash << 1 ) ^ ( n == null ? 0x537c : n.hashCode() );
         }
         return hash;
     }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingVectorMultiSet.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingVectorMultiSet.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingVectorMultiSet.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/BindingVectorMultiSet.java Tue Jun 24 09:06:50 2014
@@ -65,7 +65,7 @@ public class BindingVectorMultiSet {
 	}
 
 	/** Inner representation */
-	protected Map<BindingVector, Map<BindingVector, Count>> data = new HashMap<BindingVector, Map<BindingVector, Count>>();
+	protected Map<BindingVector, Map<BindingVector, Count>> data = new HashMap<>();
 
 	/** An array of indices which mark the primary key */
 	protected byte[] matchIndices;
@@ -156,7 +156,7 @@ public class BindingVectorMultiSet {
 	protected void put(BindingVector env, Count c) {
 		Map<BindingVector, Count> set = getRawSubSet(env);
 		if (set == null) {
-			set = new HashMap<BindingVector, Count>();
+			set = new HashMap<>();
 			data.put(getPartialEnv(env), set);
 		}
 		set.put(env, c);
@@ -170,16 +170,16 @@ public class BindingVectorMultiSet {
 	 * @param queue
 	 */
 	public void putAll(BindingVectorMultiSet queue) {
-		for (Iterator<BindingVector> it = queue.data.keySet().iterator(); it
-				.hasNext();) {
-			BindingVector env = it.next();
-			Map<BindingVector, Count> set = getRawSubSet(env);
-			if (set == null) {
-				set = new HashMap<BindingVector, Count>();
-				data.put(env, set);
-			}
-			set.putAll(queue.data.get(env));
-		}
+        for ( BindingVector env : queue.data.keySet() )
+        {
+            Map<BindingVector, Count> set = getRawSubSet( env );
+            if ( set == null )
+            {
+                set = new HashMap<>();
+                data.put( env, set );
+            }
+            set.putAll( queue.data.get( env ) );
+        }
 	}
 
 	/**

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/EnvironmentFrameWithDerivation.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/EnvironmentFrameWithDerivation.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/EnvironmentFrameWithDerivation.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/EnvironmentFrameWithDerivation.java Tue Jun 24 09:06:50 2014
@@ -69,9 +69,10 @@ public class EnvironmentFrameWithDerivat
      * Return a safe copy of the list of matched subgoals in this subderivation.
      */
     public List<Triple> getMatchList() {
-        ArrayList<Triple> matchList = new ArrayList<Triple>();
-        for (int i = 0; i < matches.length; i++) {
-            matchList.add( LPInterpreter.deref(matches[i]));
+        ArrayList<Triple> matchList = new ArrayList<>();
+        for ( TriplePattern matche : matches )
+        {
+            matchList.add( LPInterpreter.deref( matche ) );
         }
         return matchList;
     }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/FRuleEngine.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/FRuleEngine.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/FRuleEngine.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/FRuleEngine.java Tue Jun 24 09:06:50 2014
@@ -131,10 +131,11 @@ public class FRuleEngine implements FRul
                 context.addTriple(i.next());
             }
         } else {
-            for (Iterator<Node> p = predicatesUsed.iterator(); p.hasNext(); ) {
-                Node predicate = p.next();
-                for (Iterator<Triple> i = inserts.find(new TriplePattern(null, predicate, null)); i.hasNext(); ) {
-                    context.addTriple(i.next());
+            for ( Node predicate : predicatesUsed )
+            {
+                for ( Iterator<Triple> i = inserts.find( new TriplePattern( null, predicate, null ) ); i.hasNext(); )
+                {
+                    context.addTriple( i.next() );
                 }
             }
         }
@@ -229,7 +230,7 @@ public class FRuleEngine implements FRul
                 logger.info("Processing: " + PrintUtil.print(t));
             }
             // Check for rule triggers
-            HashSet<Rule> firedRules = new HashSet<Rule>();
+            HashSet<Rule> firedRules = new HashSet<>();
             Iterator<ClausePointer> i1 = clauseIndex.getAll(t.getPredicate());
             Iterator<ClausePointer> i2 = clauseIndex.getAll(Node.ANY);
             Iterator<ClausePointer> i = WrappedIterator.create(i1).andThen(i2);
@@ -258,25 +259,34 @@ public class FRuleEngine implements FRul
      * @return an object that can be installed into the engine using setRuleStore.
      */
     public void compile(List<Rule> rules, boolean ignoreBrules) {
-        clauseIndex = new OneToManyMap<Node, ClausePointer>();
-        predicatesUsed = new HashSet<Node>();
+        clauseIndex = new OneToManyMap<>();
+        predicatesUsed = new HashSet<>();
         wildcardRule = false;
-            
-        for (Iterator<Rule> i = rules.iterator(); i.hasNext(); ) {
-            Rule r = i.next();
-            if (ignoreBrules && r.isBackward()) continue;
+
+        for ( Rule r : rules )
+        {
+            if ( ignoreBrules && r.isBackward() )
+            {
+                continue;
+            }
             Object[] body = r.getBody();
-            for (int j = 0; j < body.length; j++) {
-                if (body[j] instanceof TriplePattern) {
-                    Node predicate = ((TriplePattern) body[j]).getPredicate();
-                    ClausePointer cp = new ClausePointer(r, j);
-                    if (predicate.isVariable()) {
-                        clauseIndex.put(Node.ANY, cp);
+            for ( int j = 0; j < body.length; j++ )
+            {
+                if ( body[j] instanceof TriplePattern )
+                {
+                    Node predicate = ( (TriplePattern) body[j] ).getPredicate();
+                    ClausePointer cp = new ClausePointer( r, j );
+                    if ( predicate.isVariable() )
+                    {
+                        clauseIndex.put( Node.ANY, cp );
                         wildcardRule = true;
-                    } else {
-                        clauseIndex.put(predicate, cp);
-                        if (! wildcardRule) {
-                            predicatesUsed.add(predicate);
+                    }
+                    else
+                    {
+                        clauseIndex.put( predicate, cp );
+                        if ( !wildcardRule )
+                        {
+                            predicatesUsed.add( predicate );
                         }
                     }
                 }
@@ -291,17 +301,20 @@ public class FRuleEngine implements FRul
      */
     protected void findAndProcessAxioms() {
         BFRuleContext context = new BFRuleContext(infGraph);
-        for (Iterator<Rule> i = rules.iterator(); i.hasNext(); ) {
-            Rule r = i.next();
-            if (r.bodyLength() == 0) {
+        for ( Rule r : rules )
+        {
+            if ( r.bodyLength() == 0 )
+            {
                 // An axiom
-                for (int j = 0; j < r.headLength(); j++) {
-                    Object head = r.getHeadElement(j);
-                    if (head instanceof TriplePattern) {
+                for ( int j = 0; j < r.headLength(); j++ )
+                {
+                    Object head = r.getHeadElement( j );
+                    if ( head instanceof TriplePattern )
+                    {
                         TriplePattern h = (TriplePattern) head;
-                        Triple t = new Triple(h.getSubject(), h.getPredicate(), h.getObject());
-                        context.addTriple(t);
-                        infGraph.getDeductionsGraph().add(t);
+                        Triple t = new Triple( h.getSubject(), h.getPredicate(), h.getObject() );
+                        context.addTriple( t );
+                        infGraph.getDeductionsGraph().add( t );
                     }
                 }
             }
@@ -315,20 +328,27 @@ public class FRuleEngine implements FRul
      */
     protected void findAndProcessActions() {
         BFRuleContext context = new BFRuleContext(infGraph);
-        for (Iterator<Rule> i = rules.iterator(); i.hasNext(); ) {
-            Rule r = i.next();
-            if (r.bodyLength() == 0) {
+        for ( Rule r : rules )
+        {
+            if ( r.bodyLength() == 0 )
+            {
                 // An axiom
-                for (int j = 0; j < r.headLength(); j++) {
-                    Object head = r.getHeadElement(j);
-                    if (head instanceof Functor) {
-                        Functor f = (Functor)head;
+                for ( int j = 0; j < r.headLength(); j++ )
+                {
+                    Object head = r.getHeadElement( j );
+                    if ( head instanceof Functor )
+                    {
+                        Functor f = (Functor) head;
                         Builtin imp = f.getImplementor();
-                        if (imp != null) {
-                            context.setRule(r);
-                            imp.headAction(f.getArgs(), f.getArgLength(), context);
-                        } else {
-                            throw new ReasonerException("Invoking undefined Functor " + f.getName() +" in " + r.toShortString());
+                        if ( imp != null )
+                        {
+                            context.setRule( r );
+                            imp.headAction( f.getArgs(), f.getArgLength(), context );
+                        }
+                        else
+                        {
+                            throw new ReasonerException(
+                                "Invoking undefined Functor " + f.getName() + " in " + r.toShortString() );
                         }
                     }
                 }
@@ -348,7 +368,7 @@ public class FRuleEngine implements FRul
         // Create an ordered list of body clauses to process, best at the end
         ClauseEntry[] body = rule.getBody();
         int len = body.length;
-        List<ClauseEntry> clauses = new ArrayList<ClauseEntry>(len-1);
+        List<ClauseEntry> clauses = new ArrayList<>(len-1);
         
         if (len <= 1) {
             // No clauses to add, just fall through to clause matcher
@@ -425,7 +445,7 @@ public class FRuleEngine implements FRul
             List<Triple> matchList = null;
             if (recordDerivations) {
                 // Create derivation record
-                matchList = new ArrayList<Triple>(rule.bodyLength());
+                matchList = new ArrayList<>(rule.bodyLength());
                 for (int i = 0; i < rule.bodyLength(); i++) {
                     Object clause = rule.getBodyElement(i);
                     if (clause instanceof TriplePattern) {
@@ -468,7 +488,7 @@ public class FRuleEngine implements FRul
             return true;
         }
         // More clauses left to match ...
-        List<ClauseEntry> clausesCopy = new ArrayList<ClauseEntry>(clauses);
+        List<ClauseEntry> clausesCopy = new ArrayList<>(clauses);
         TriplePattern clause = (TriplePattern) clausesCopy.remove(index);
         Node objPattern = env.getBinding(clause.getObject());
         if (Functor.isFunctor(objPattern)) {

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/Generator.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/Generator.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/Generator.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/Generator.java Tue Jun 24 09:06:50 2014
@@ -40,7 +40,7 @@ public class Generator implements LPAgen
     protected LPInterpreter interpreter;
         
     /** The ordered set of results available for the goal */
-    protected ArrayList<Object> results = new ArrayList<Object>();
+    protected ArrayList<Object> results = new ArrayList<>();
     
     /** A indexed version of the result set, used while the generator is live 
      *  to detect duplicate results */
@@ -53,10 +53,10 @@ public class Generator implements LPAgen
     protected boolean checkReadyNeeded = false;
     
     /** The set of choice points producing results for us to use */
-    protected Set<ConsumerChoicePointFrame> generatingCPs = new HashSet<ConsumerChoicePointFrame>();
+    protected Set<ConsumerChoicePointFrame> generatingCPs = new HashSet<>();
     
     /** The list of active consumer choice points consuming results from this generator */
-    protected Set<ConsumerChoicePointFrame> consumingCPs = new HashSet<ConsumerChoicePointFrame>();
+    protected Set<ConsumerChoicePointFrame> consumingCPs = new HashSet<>();
     
     /** Flags whether the generator is live/dead/unknown during completion checking */
     protected LFlag completionState;
@@ -83,7 +83,7 @@ public class Generator implements LPAgen
         this.interpreter = interpreter;
         this.goal = goal;       // Just used for debugging
         isSingleton = goal.isGround();
-        if (!isSingleton) resultSet = new HashSet<Object>();
+        if (!isSingleton) resultSet = new HashSet<>();
     }
     
     /**
@@ -102,8 +102,10 @@ public class Generator implements LPAgen
         if (isComplete()) return false;
         if (checkReadyNeeded) {
             isReady = false;
-            for (Iterator<ConsumerChoicePointFrame> i = generatingCPs.iterator(); i.hasNext(); ) {
-                if ( i.next().isReady() ) {
+            for ( ConsumerChoicePointFrame generatingCP : generatingCPs )
+            {
+                if ( generatingCP.isReady() )
+                {
                     isReady = true;
                     break;
                 }
@@ -161,9 +163,10 @@ public class Generator implements LPAgen
             isReady = false;
             completionState = LFlag.DEAD;
             // Anyone we were generating results for is now finished
-            for (Iterator<ConsumerChoicePointFrame> i = consumingCPs.iterator(); i.hasNext(); ) {
-                ConsumerChoicePointFrame ccp = i.next();
-                if ( ! ccp.isReady()) {
+            for ( ConsumerChoicePointFrame ccp : consumingCPs )
+            {
+                if ( !ccp.isReady() )
+                {
                     ccp.setFinished();
                 }
             }
@@ -201,8 +204,8 @@ public class Generator implements LPAgen
      */
     public void notifyResults() {
         LPBRuleEngine engine = interpreter.getEngine();
-        for (Iterator<ConsumerChoicePointFrame> i = consumingCPs.iterator(); i.hasNext(); ) {
-            ConsumerChoicePointFrame cons = i.next();
+        for ( ConsumerChoicePointFrame cons : consumingCPs )
+        {
             cons.setReady();
         }
     }
@@ -287,7 +290,7 @@ public class Generator implements LPAgen
      * dependent on can run.
      */
     public void checkForCompletions() {
-        HashSet<Generator> visited = new HashSet<Generator>();
+        HashSet<Generator> visited = new HashSet<>();
         if (runCompletionCheck(visited) != LFlag.LIVE) {
             postCompletionCheckScan(visited);
         }
@@ -298,11 +301,12 @@ public class Generator implements LPAgen
      * been run.
      */
     public static void checkForCompletions(Collection<? extends Generator> completions) {
-        HashSet<Generator> visited = new HashSet<Generator>();
+        HashSet<Generator> visited = new HashSet<>();
         boolean atLeastOneZombie = false;
-        for (Iterator<? extends Generator> i = completions.iterator(); i.hasNext(); ) {
-            Generator g = i.next();
-            if (g.runCompletionCheck(visited) != LFlag.LIVE) {
+        for ( Generator g : completions )
+        {
+            if ( g.runCompletionCheck( visited ) != LFlag.LIVE )
+            {
                 atLeastOneZombie = true;
             }
         }
@@ -323,12 +327,15 @@ public class Generator implements LPAgen
         if (isReady()) {
             completionState = LFlag.LIVE;
         } else {
-            for (Iterator<ConsumerChoicePointFrame> i = generatingCPs.iterator(); i.hasNext(); ) {
-                ConsumerChoicePointFrame ccp = i.next();
-                if (ccp.isReady()) {
+            for ( ConsumerChoicePointFrame ccp : generatingCPs )
+            {
+                if ( ccp.isReady() )
+                {
                     completionState = LFlag.LIVE;
                     break;
-                } else if ( ccp.generator.runCompletionCheck(visited) == LFlag.LIVE) {
+                }
+                else if ( ccp.generator.runCompletionCheck( visited ) == LFlag.LIVE )
+                {
                     completionState = LFlag.LIVE;
                     break;
                 }
@@ -343,21 +350,25 @@ public class Generator implements LPAgen
      * to complete.
      */
     protected static void postCompletionCheckScan(Set<Generator> visited ) {
-        for (Iterator<Generator> iv = visited.iterator(); iv.hasNext(); ) {
-            Generator g = iv.next();
-            if (g.completionState == LFlag.LIVE) {
-                for (Iterator<ConsumerChoicePointFrame> i = g.consumingCPs.iterator(); i.hasNext(); ) {
+        for ( Generator g : visited )
+        {
+            if ( g.completionState == LFlag.LIVE )
+            {
+                for ( Iterator<ConsumerChoicePointFrame> i = g.consumingCPs.iterator(); i.hasNext(); )
+                {
                     LPInterpreterContext link = i.next().getConsumingContext();
-                    if (link instanceof Generator) {
-                        ((Generator)link).propagateLive(visited); 
+                    if ( link instanceof Generator )
+                    {
+                        ( (Generator) link ).propagateLive( visited );
                     }
                 }
             }
         }
-        
-        for (Iterator<Generator> iv = visited.iterator(); iv.hasNext(); ) {
-            Generator g = iv.next();
-            if (g.completionState != LFlag.LIVE) {
+
+        for ( Generator g : visited )
+        {
+            if ( g.completionState != LFlag.LIVE )
+            {
                 g.setComplete();
             }
         }
@@ -371,10 +382,12 @@ public class Generator implements LPAgen
     protected void propagateLive(Set<Generator> filter) {
         if (completionState != LFlag.LIVE) {
             completionState = LFlag.LIVE;
-            for (Iterator<ConsumerChoicePointFrame> i = consumingCPs.iterator(); i.hasNext(); ) {
-                LPInterpreterContext link = i.next().getConsumingContext();
-                if (link instanceof Generator) {
-                    ((Generator)link).propagateLive(filter); 
+            for ( ConsumerChoicePointFrame consumingCP : consumingCPs )
+            {
+                LPInterpreterContext link = consumingCP.getConsumingContext();
+                if ( link instanceof Generator )
+                {
+                    ( (Generator) link ).propagateLive( filter );
                 }
             }
         }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPBRuleEngine.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPBRuleEngine.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPBRuleEngine.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPBRuleEngine.java Tue Jun 24 09:06:50 2014
@@ -52,14 +52,14 @@ public class LPBRuleEngine {
     protected boolean recordDerivations;
         
     /** List of engine instances which are still processing queries */
-    protected List<LPInterpreter> activeInterpreters = new ArrayList<LPInterpreter>();
+    protected List<LPInterpreter> activeInterpreters = new ArrayList<>();
     
     /** Table mapping tabled goals to generators for those goals.
      *  This is here so that partial goal state can be shared across multiple queries. */
-    protected HashMap<TriplePattern, Generator> tabledGoals = new HashMap<TriplePattern, Generator>();
+    protected HashMap<TriplePattern, Generator> tabledGoals = new HashMap<>();
     
     /** Set of generators waiting to be run */
-    protected LinkedList<LPAgendaEntry> agenda = new LinkedList<LPAgendaEntry>();
+    protected LinkedList<LPAgendaEntry> agenda = new LinkedList<>();
 //    protected List agenda = new ArrayList();
 //    protected Collection agenda = new HashSet();
     
@@ -113,7 +113,7 @@ public class LPBRuleEngine {
      */
     public synchronized void reset() {
         checkSafeToUpdate();
-        tabledGoals = new HashMap<TriplePattern, Generator>();
+        tabledGoals = new HashMap<>();
         agenda.clear();
     }
     
@@ -160,10 +160,11 @@ public class LPBRuleEngine {
      * Stop the current work. Forcibly stop all current query instances over this engine.
      */
     public synchronized void halt() {
-        ArrayList<LPInterpreter> copy = new ArrayList<LPInterpreter>(activeInterpreters);  
+        ArrayList<LPInterpreter> copy = new ArrayList<>(activeInterpreters);
         // Copy because closing the LPInterpreter will detach it from this engine which affects activeInterpreters
-        for (Iterator<LPInterpreter> i = copy.iterator(); i.hasNext(); ) {
-            i.next().close();
+        for ( LPInterpreter aCopy : copy )
+        {
+            aCopy.close();
         }
     }
        
@@ -221,15 +222,17 @@ public class LPBRuleEngine {
      */
     public void checkSafeToUpdate() {
         if (!activeInterpreters.isEmpty()) {
-            ArrayList<LPInterpreterContext> toClose = new ArrayList<LPInterpreterContext>();
-            for (Iterator<LPInterpreter> i = activeInterpreters.iterator(); i.hasNext(); ) {
-                LPInterpreter interpreter = i.next();
-                if (interpreter.getContext() instanceof LPTopGoalIterator) {
-                    toClose.add(interpreter.getContext());
+            ArrayList<LPInterpreterContext> toClose = new ArrayList<>();
+            for ( LPInterpreter interpreter : activeInterpreters )
+            {
+                if ( interpreter.getContext() instanceof LPTopGoalIterator )
+                {
+                    toClose.add( interpreter.getContext() );
                 }
             }
-            for (Iterator<LPInterpreterContext> i = toClose.iterator(); i.hasNext(); ) {
-                ((LPTopGoalIterator)i.next()).close();
+            for ( LPInterpreterContext aToClose : toClose )
+            {
+                ( (LPTopGoalIterator) aToClose ).close();
             }
         }
     }
@@ -295,7 +298,7 @@ public class LPBRuleEngine {
     public void pump(LPInterpreterContext gen) {
         Collection<Generator> batch = null;
         if (CYCLES_BETWEEN_COMPLETION_CHECK > 0) {
-            batch = new ArrayList<Generator>(CYCLES_BETWEEN_COMPLETION_CHECK);
+            batch = new ArrayList<>(CYCLES_BETWEEN_COMPLETION_CHECK);
         }
         int count = 0; 
         while(!gen.isReady()) {
@@ -340,11 +343,13 @@ public class LPBRuleEngine {
     public void checkForCompletions() {
         List<Generator> contexts = null;
         synchronized (activeInterpreters) {
-            contexts = new ArrayList<Generator>(activeInterpreters.size());
-            for (Iterator<LPInterpreter> i = activeInterpreters.iterator(); i.hasNext(); ) {
-                LPInterpreterContext context = i.next().getContext();
-                if (context instanceof Generator) {
-                    contexts.add( (Generator) context);     
+            contexts = new ArrayList<>(activeInterpreters.size());
+            for ( LPInterpreter activeInterpreter : activeInterpreters )
+            {
+                LPInterpreterContext context = activeInterpreter.getContext();
+                if ( context instanceof Generator )
+                {
+                    contexts.add( (Generator) context );
                 }
             }
 
@@ -386,12 +391,13 @@ public class LPBRuleEngine {
         if (profile == null) {
             System.out.println("No profile collected");
         } else {
-            ArrayList<Count> counts = new ArrayList<Count>();
+            ArrayList<Count> counts = new ArrayList<>();
             counts.addAll(profile.values());
             Collections.sort(counts);
             System.out.println("LP engine rule profile");
-            for (Iterator<Count> i = counts.iterator(); i.hasNext(); ) {
-                System.out.println(i.next());
+            for ( Count count : counts )
+            {
+                System.out.println( count );
             }
         }
     }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPInterpreter.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPInterpreter.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPInterpreter.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPInterpreter.java Tue Jun 24 09:06:50 2014
@@ -63,7 +63,7 @@ public class LPInterpreter {
     protected FrameObject cpFrame;
     
     /** The trail of variable bindings that have to be unwound on backtrack */
-    protected ArrayList<Node> trail = new ArrayList<Node>();
+    protected ArrayList<Node> trail = new ArrayList<>();
 
     /** The execution context description to be passed to builtins */
     protected RuleContext context;
@@ -119,7 +119,7 @@ public class LPInterpreter {
             envFrame = new EnvironmentFrame(RuleClauseCode.returnCodeBlock);
         }
         envFrame.allocate(RuleClauseCode.MAX_PERMANENT_VARS);
-        HashMap<Node, Node> mappedVars = new HashMap<Node, Node>();
+        HashMap<Node, Node> mappedVars = new HashMap<>();
         envFrame.pVars[0] = argVars[0] = standardize(goal.getSubject(), mappedVars);
         envFrame.pVars[1] = argVars[1] = standardize(goal.getPredicate(), mappedVars);
         envFrame.pVars[2] = argVars[2] = standardize(goal.getObject(), mappedVars);
@@ -641,7 +641,7 @@ public class LPInterpreter {
      * Tracing support - return a format set of triple queries/results.
      */
     private String getArgTrace() {
-        StringBuffer temp = new StringBuffer();
+        StringBuilder temp = new StringBuilder();
         temp.append(PrintUtil.print(deref(argVars[0])));
         temp.append(" ");
         temp.append(PrintUtil.print(deref(argVars[1])));
@@ -784,8 +784,10 @@ public class LPInterpreter {
                 Functor f = (Functor) dnode.getLiteralValue();
                 Node[] fargs = f.getArgs();
                 boolean needCopy = false;
-                for (int i = 0; i < fargs.length; i++) {
-                    if (fargs[i].isVariable()) {
+                for ( Node farg : fargs )
+                {
+                    if ( farg.isVariable() )
+                    {
                         needCopy = true;
                         break;
                     }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPRuleStore.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPRuleStore.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPRuleStore.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPRuleStore.java Tue Jun 24 09:06:50 2014
@@ -45,7 +45,7 @@ public class LPRuleStore extends RuleSto
     protected Map<Node, Map<Node, List<RuleClauseCode>>> indexPredicateToCodeMap;
         
     /** Set of predicates which should be tabled */
-    protected HashSet<Node> tabledPredicates = new HashSet<Node>();
+    protected HashSet<Node> tabledPredicates = new HashSet<>();
         
     /** Threshold for number of rule entries in a predicate bucket before second level indexing kicks in */
     private static final int INDEX_THRESHOLD = 20;
@@ -164,27 +164,31 @@ public class LPRuleStore extends RuleSto
     protected void compileAll() {
         isCompiled = true;
         
-        predicateToCodeMap = new HashMap<Node, List<RuleClauseCode>>();
-        allRuleClauseCodes = new ArrayList<RuleClauseCode>();
-        indexPredicateToCodeMap = new HashMap<Node, Map<Node, List<RuleClauseCode>>>();
-        for (Iterator<Rule> ri = getAllRules().iterator(); ri.hasNext(); ) {
-            Rule r = ri.next();
-            ClauseEntry term = r.getHeadElement(0);
-            if (term instanceof TriplePattern) {
-                RuleClauseCode code = new RuleClauseCode(r);
-                allRuleClauseCodes.add(code);
-                Node predicate = ((TriplePattern)term).getPredicate();
-                if (predicate.isVariable()) {
+        predicateToCodeMap = new HashMap<>();
+        allRuleClauseCodes = new ArrayList<>();
+        indexPredicateToCodeMap = new HashMap<>();
+        for ( Rule r : getAllRules() )
+        {
+            ClauseEntry term = r.getHeadElement( 0 );
+            if ( term instanceof TriplePattern )
+            {
+                RuleClauseCode code = new RuleClauseCode( r );
+                allRuleClauseCodes.add( code );
+                Node predicate = ( (TriplePattern) term ).getPredicate();
+                if ( predicate.isVariable() )
+                {
                     predicate = Node_RuleVariable.WILD;
                 }
-                List<RuleClauseCode> predicateCode = predicateToCodeMap.get(predicate);
-                if (predicateCode == null) {
-                    predicateCode = new ArrayList<RuleClauseCode>();
-                    predicateToCodeMap.put(predicate, predicateCode);
-                }
-                predicateCode.add(code);
-                if (predicateCode.size() > INDEX_THRESHOLD) {
-                    indexPredicateToCodeMap.put(predicate, new HashMap<Node, List<RuleClauseCode>>());
+                List<RuleClauseCode> predicateCode = predicateToCodeMap.get( predicate );
+                if ( predicateCode == null )
+                {
+                    predicateCode = new ArrayList<>();
+                    predicateToCodeMap.put( predicate, predicateCode );
+                }
+                predicateCode.add( code );
+                if ( predicateCode.size() > INDEX_THRESHOLD )
+                {
+                    indexPredicateToCodeMap.put( predicate, new HashMap<Node, List<RuleClauseCode>>() );
                 }
             }
         }
@@ -192,58 +196,66 @@ public class LPRuleStore extends RuleSto
         // Now add the wild card rules into the list for each non-wild predicate)
         List<RuleClauseCode> wildRules = predicateToCodeMap.get(Node_RuleVariable.WILD);
         if (wildRules != null) {
-            for (Iterator<Map.Entry<Node, List<RuleClauseCode>>> i = predicateToCodeMap.entrySet().iterator(); i.hasNext(); ) {
-                Map.Entry<Node, List<RuleClauseCode>> entry = i.next();
+            for ( Map.Entry<Node, List<RuleClauseCode>> entry : predicateToCodeMap.entrySet() )
+            {
                 Node predicate = entry.getKey();
                 List<RuleClauseCode> predicateCode = entry.getValue();
-                if (predicate != Node_RuleVariable.WILD) {
-                    predicateCode.addAll(wildRules);
+                if ( predicate != Node_RuleVariable.WILD )
+                {
+                    predicateCode.addAll( wildRules );
                 }
             }
         }
         indexPredicateToCodeMap.put(Node_RuleVariable.WILD, new HashMap<Node, List<RuleClauseCode>>());
                 
         // Now built any required two level indices
-        for (Iterator<Map.Entry<Node, Map<Node, List<RuleClauseCode>>>> i = indexPredicateToCodeMap.entrySet().iterator(); i.hasNext(); ) {
-            Map.Entry<Node, Map<Node, List<RuleClauseCode>>> entry = i.next();
+        for ( Map.Entry<Node, Map<Node, List<RuleClauseCode>>> entry : indexPredicateToCodeMap.entrySet() )
+        {
             Node predicate = entry.getKey();
             Map<Node, List<RuleClauseCode>> predicateMap = entry.getValue();
-            List<RuleClauseCode> wildRulesForPredicate = new ArrayList<RuleClauseCode>();
-            List<RuleClauseCode> allRulesForPredicate =  predicate.isVariable() ? allRuleClauseCodes : predicateToCodeMap.get(predicate);
-            for (Iterator<RuleClauseCode> j = allRulesForPredicate.iterator(); j.hasNext(); ) {
+            List<RuleClauseCode> wildRulesForPredicate = new ArrayList<>();
+            List<RuleClauseCode> allRulesForPredicate =
+                predicate.isVariable() ? allRuleClauseCodes : predicateToCodeMap.get( predicate );
+            for ( Iterator<RuleClauseCode> j = allRulesForPredicate.iterator(); j.hasNext(); )
+            {
                 RuleClauseCode code = j.next();
-                ClauseEntry head = code.getRule().getHeadElement(0);
+                ClauseEntry head = code.getRule().getHeadElement( 0 );
                 boolean indexed = false;
-                if (head instanceof TriplePattern) {
-                    Node objectPattern = ((TriplePattern)head).getObject();
-                    if (!objectPattern.isVariable() && !Functor.isFunctor(objectPattern)) {
+                if ( head instanceof TriplePattern )
+                {
+                    Node objectPattern = ( (TriplePattern) head ).getObject();
+                    if ( !objectPattern.isVariable() && !Functor.isFunctor( objectPattern ) )
+                    {
                         // Index against object
-                        List<RuleClauseCode> indexedCode = predicateMap.get(objectPattern);
-                        if (indexedCode == null) {
-                            indexedCode = new ArrayList<RuleClauseCode>();
-                            predicateMap.put(objectPattern, indexedCode);
+                        List<RuleClauseCode> indexedCode = predicateMap.get( objectPattern );
+                        if ( indexedCode == null )
+                        {
+                            indexedCode = new ArrayList<>();
+                            predicateMap.put( objectPattern, indexedCode );
                         }
-                        indexedCode.add(code);
+                        indexedCode.add( code );
                         indexed = true;
                     }
                 }
-                if (!indexed) {
-                    wildRulesForPredicate.add(code);
+                if ( !indexed )
+                {
+                    wildRulesForPredicate.add( code );
                 }
             }
             // Now fold the rules that apply to any index entry into all the indexed entries
-            for (Iterator<Map.Entry<Node, List<RuleClauseCode>>> k = predicateMap.entrySet().iterator(); k.hasNext(); ) {
+            for ( Iterator<Map.Entry<Node, List<RuleClauseCode>>> k = predicateMap.entrySet().iterator(); k.hasNext(); )
+            {
                 Map.Entry<Node, List<RuleClauseCode>> ent = k.next();
                 Node pred = ent.getKey();
                 List<RuleClauseCode> predicateCode = ent.getValue();
-                predicateCode.addAll(wildRulesForPredicate);
+                predicateCode.addAll( wildRulesForPredicate );
             }
         }
         
         // Now compile all the clauses
-        for (Iterator<RuleClauseCode> i = allRuleClauseCodes.iterator(); i.hasNext(); ) {
-            RuleClauseCode code = i.next();
-            code.compile(this);
+        for ( RuleClauseCode code : allRuleClauseCodes )
+        {
+            code.compile( this );
         }
     }