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 [11/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/impl/LPTopGoalIterator.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPTopGoalIterator.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPTopGoalIterator.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/LPTopGoalIterator.java Tue Jun 24 09:06:50 2014
@@ -18,8 +18,6 @@
package com.hp.hpl.jena.reasoner.rulesys.impl;
-import java.util.NoSuchElementException;
-
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.reasoner.rulesys.BackwardRuleInfGraphI;
import com.hp.hpl.jena.util.iterator.ClosableIterator;
@@ -42,7 +40,7 @@ public class LPTopGoalIterator implement
BackwardRuleInfGraphI infgraph;
/** The set of choice points that the top level interpter is waiting for */
- protected Set<ConsumerChoicePointFrame> choicePoints = new HashSet<ConsumerChoicePointFrame>();
+ protected Set<ConsumerChoicePointFrame> choicePoints = new HashSet<>();
/** The choice point most recently notified as ready to run. */
protected ConsumerChoicePointFrame nextToRun;
@@ -157,13 +155,15 @@ public class LPTopGoalIterator implement
public boolean isReady() {
if (checkReadyNeeded) {
isReady = false;
- for (Iterator<ConsumerChoicePointFrame> i = choicePoints.iterator(); i.hasNext(); ) {
- ConsumerChoicePointFrame ccp = i.next();
- if ( ccp.isReady() ) {
- if (nextToRun == null) {
+ for ( ConsumerChoicePointFrame ccp : choicePoints )
+ {
+ if ( ccp.isReady() )
+ {
+ if ( nextToRun == null )
+ {
nextToRun = ccp;
}
- isReady = true;
+ isReady = true;
break;
}
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/OWLExptRuleTranslationHook.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/OWLExptRuleTranslationHook.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/OWLExptRuleTranslationHook.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/OWLExptRuleTranslationHook.java Tue Jun 24 09:06:50 2014
@@ -48,23 +48,22 @@ public class OWLExptRuleTranslationHook
while (it.hasNext()) {
Triple decl = it.next();
Node className = decl.getSubject();
- List<Node> elements = new ArrayList<Node>();
+ List<Node> elements = new ArrayList<>();
translateIntersectionList(decl.getObject(), dataFind, elements);
// Generate the corresponding ruleset
- List<ClauseEntry> recognitionBody = new ArrayList<ClauseEntry>();
+ List<ClauseEntry> recognitionBody = new ArrayList<>();
Node var = new Node_RuleVariable("?x", 0);
- for (Iterator<Node> i = elements.iterator(); i.hasNext(); ) {
- Node description = i.next();
+ for ( Node description : elements )
+ {
// Implication rule
- Rule ir = new Rule("intersectionImplication", new ClauseEntry[] {
- new TriplePattern(className, RDFS.subClassOf.asNode(), description)
- }, new ClauseEntry[0]);
- ir.setBackward(false);
- infGraph.addRuleDuringPrepare(ir);
- // Recognition rule elements
- recognitionBody.add(new TriplePattern(var, RDF.type.asNode(), description));
+ Rule ir = new Rule( "intersectionImplication", new ClauseEntry[]{
+ new TriplePattern( className, RDFS.subClassOf.asNode(), description ) }, new ClauseEntry[0] );
+ ir.setBackward( false );
+ infGraph.addRuleDuringPrepare( ir );
+ // Recognition rule elements
+ recognitionBody.add( new TriplePattern( var, RDF.type.asNode(), description ) );
}
- List<ClauseEntry> recognitionHead = new ArrayList<ClauseEntry>(1);
+ List<ClauseEntry> recognitionHead = new ArrayList<>(1);
recognitionHead.add(new TriplePattern(var, RDF.type.asNode(), className));
Rule rr = new Rule("intersectionRecognition", recognitionHead, recognitionBody);
rr.setBackward(true);
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/OWLRuleTranslationHook.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/OWLRuleTranslationHook.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/OWLRuleTranslationHook.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/OWLRuleTranslationHook.java Tue Jun 24 09:06:50 2014
@@ -49,24 +49,23 @@ public class OWLRuleTranslationHook impl
while (it.hasNext()) {
Triple decl = it.next();
Node className = decl.getSubject();
- List<Node> elements = new ArrayList<Node>();
+ List<Node> elements = new ArrayList<>();
translateIntersectionList(decl.getObject(), dataFind, elements);
// Generate the corresponding ruleset
- List<ClauseEntry> recognitionBody = new ArrayList<ClauseEntry>();
+ List<ClauseEntry> recognitionBody = new ArrayList<>();
Node var = new Node_RuleVariable("?x", 0);
- for (Iterator<Node> i = elements.iterator(); i.hasNext(); ) {
- Node description = i.next();
+ for ( Node description : elements )
+ {
// Implication rule
- Rule ir = new Rule("intersectionImplication", new ClauseEntry[] {
- new TriplePattern(className, RDFS.subClassOf.asNode(), description)
- }, new ClauseEntry[0]);
- ir.setBackward(false);
+ Rule ir = new Rule( "intersectionImplication", new ClauseEntry[]{
+ new TriplePattern( className, RDFS.subClassOf.asNode(), description ) }, new ClauseEntry[0] );
+ ir.setBackward( false );
// System.out.println("translation hook => " + ir);
- infGraph.addRuleDuringPrepare(ir);
- // Recognition rule elements
- recognitionBody.add(new TriplePattern(var, RDF.type.asNode(), description));
+ infGraph.addRuleDuringPrepare( ir );
+ // Recognition rule elements
+ recognitionBody.add( new TriplePattern( var, RDF.type.asNode(), description ) );
}
- List<ClauseEntry> recognitionHead = new ArrayList<ClauseEntry>(1);
+ List<ClauseEntry> recognitionHead = new ArrayList<>(1);
recognitionHead.add(new TriplePattern(var, RDF.type.asNode(), className));
Rule rr = new Rule("intersectionRecognition", recognitionHead, recognitionBody);
rr.setBackward(true);
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RDFSCMPPreprocessHook.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RDFSCMPPreprocessHook.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RDFSCMPPreprocessHook.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RDFSCMPPreprocessHook.java Tue Jun 24 09:06:50 2014
@@ -48,7 +48,7 @@ public class RDFSCMPPreprocessHook imple
@Override
public void run(FBRuleInfGraph infGraph, Finder dataFind, Graph inserts) {
ExtendedIterator<Triple> it = dataFind.find(new TriplePattern(null, null, null));
- HashSet<Node> properties = new HashSet<Node>();
+ HashSet<Node> properties = new HashSet<>();
while (it.hasNext()) {
Triple triple = it.next();
Node prop = triple.getPredicate();
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEClauseFilter.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEClauseFilter.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEClauseFilter.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEClauseFilter.java Tue Jun 24 09:06:50 2014
@@ -92,7 +92,7 @@ public class RETEClauseFilter implements
public static RETEClauseFilter compile(TriplePattern clause, int envLength, List<Node> varList) {
byte[] instructions = new byte[300];
byte[] bindInstructions = new byte[100];
- ArrayList<Object> args = new ArrayList<Object>();
+ ArrayList<Object> args = new ArrayList<>();
int pc = 0;
int bpc = 0;
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEConflictSet.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEConflictSet.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEConflictSet.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEConflictSet.java Tue Jun 24 09:06:50 2014
@@ -55,7 +55,7 @@ public class RETEConflictSet {
protected boolean isMonotonic;
/** the list of rule activations left to fire */
- protected ArrayList<CSEntry> conflictSet = new ArrayList<CSEntry>();
+ protected ArrayList<CSEntry> conflictSet = new ArrayList<>();
/** count the number of positive entries - optimization hack */
protected int nPos = 0;
@@ -145,7 +145,7 @@ public class RETEConflictSet {
List<Triple> matchList = null;
if (infGraph.shouldLogDerivations() && isAdd) {
// 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) {
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEEngine.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEEngine.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEEngine.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEEngine.java Tue Jun 24 09:06:50 2014
@@ -47,14 +47,14 @@ public class RETEEngine implements FRule
protected OneToManyMap<Node, RETENode> clauseIndex;
/** Queue of newly added triples waiting to be processed */
- protected List<Triple> addsPending = new ArrayList<Triple>();
+ protected List<Triple> addsPending = new ArrayList<>();
/** A HashSet of pending triples for faster lookup */
- protected HashSet<Triple> addsHash = new HashSet<Triple>();
+ protected HashSet<Triple> addsHash = new HashSet<>();
/** Queue of newly deleted triples waiting to be processed */
- protected List<Triple> deletesPending = new ArrayList<Triple>();
+ protected List<Triple> deletesPending = new ArrayList<>();
/** The conflict set of rules waiting to fire */
@@ -95,9 +95,10 @@ public class RETEEngine implements FRule
this.rules = rules;
// Check if this is a monotonic rule set
isMonotonic = true;
- for (Iterator<Rule> i = rules.iterator(); i.hasNext(); ) {
- Rule r = i.next();
- if ( ! r.isMonotonic() ) {
+ for ( Rule r : rules )
+ {
+ if ( !r.isMonotonic() )
+ {
isMonotonic = false;
break;
}
@@ -234,10 +235,10 @@ public class RETEEngine implements FRule
// Clone the RETE network to this engine
RETERuleContext context = new RETERuleContext(infGraph, this);
- Map<RETENode, RETENode> netCopy = new HashMap<RETENode, RETENode>();
- clauseIndex = new OneToManyMap<Node, RETENode>();
- for (Iterator<Map.Entry<Node, RETENode>> i = rs.clauseIndex.entrySet().iterator(); i.hasNext(); ) {
- Map.Entry<Node, RETENode> entry = i.next();
+ Map<RETENode, RETENode> netCopy = new HashMap<>();
+ clauseIndex = new OneToManyMap<>();
+ for ( Map.Entry<Node, RETENode> entry : rs.clauseIndex.entrySet() )
+ {
clauseIndex.put( entry.getKey(), entry.getValue().clone( netCopy, context ) );
}
}
@@ -258,68 +259,92 @@ public class RETEEngine implements FRule
* @param ignoreBrules set to true if rules written in backward notation should be ignored
*/
public void compile(List<Rule> rules, boolean ignoreBrules) {
- clauseIndex = new OneToManyMap<Node, RETENode>();
- predicatePatterns = new OneToManyMap<Node, Node>();
+ clauseIndex = new OneToManyMap<>();
+ predicatePatterns = new OneToManyMap<>();
wildcardRule = false;
-
- for (Iterator<Rule> it = rules.iterator(); it.hasNext(); ) {
- Rule rule = it.next();
- if (ignoreBrules && rule.isBackward()) continue;
-
+
+ for ( Rule rule : rules )
+ {
+ if ( ignoreBrules && rule.isBackward() )
+ {
+ continue;
+ }
+
int numVars = rule.getNumVars();
boolean[] seenVar = new boolean[numVars];
RETESourceNode prior = null;
-
- for (int i = 0; i < rule.bodyLength(); i++) {
- Object clause = rule.getBodyElement(i);
- if (clause instanceof TriplePattern) {
+
+ for ( int i = 0; i < rule.bodyLength(); i++ )
+ {
+ Object clause = rule.getBodyElement( i );
+ if ( clause instanceof TriplePattern )
+ {
// Create the filter node for this pattern
- ArrayList<Node> clauseVars = new ArrayList<Node>(numVars);
- RETEClauseFilter clauseNode = RETEClauseFilter.compile((TriplePattern)clause, numVars, clauseVars);
- Node predicate = ((TriplePattern)clause).getPredicate();
- Node object = ((TriplePattern)clause).getObject();
- if (predicate.isVariable()) {
- clauseIndex.put(Node.ANY, clauseNode);
+ ArrayList<Node> clauseVars = new ArrayList<>( numVars );
+ RETEClauseFilter clauseNode =
+ RETEClauseFilter.compile( (TriplePattern) clause, numVars, clauseVars );
+ Node predicate = ( (TriplePattern) clause ).getPredicate();
+ Node object = ( (TriplePattern) clause ).getObject();
+ if ( predicate.isVariable() )
+ {
+ clauseIndex.put( Node.ANY, clauseNode );
wildcardRule = true;
- } else {
- clauseIndex.put(predicate, clauseNode);
- if (! wildcardRule) {
- if (object.isVariable()) object = Node.ANY;
- if (Functor.isFunctor(object)) object = Node.ANY;
- recordPredicatePattern(predicate, object);
+ }
+ else
+ {
+ clauseIndex.put( predicate, clauseNode );
+ if ( !wildcardRule )
+ {
+ if ( object.isVariable() )
+ {
+ object = Node.ANY;
+ }
+ if ( Functor.isFunctor( object ) )
+ {
+ object = Node.ANY;
+ }
+ recordPredicatePattern( predicate, object );
}
}
-
+
// Create list of variables which should be cross matched between the earlier clauses and this one
- ArrayList<Byte> matchIndices = new ArrayList<Byte>(numVars);
- for (Iterator<Node> iv = clauseVars.iterator(); iv.hasNext(); ) {
- int varIndex = ((Node_RuleVariable)iv.next()).getIndex();
- if (seenVar[varIndex]) matchIndices.add(new Byte((byte)varIndex));
+ ArrayList<Byte> matchIndices = new ArrayList<>( numVars );
+ for ( Iterator<Node> iv = clauseVars.iterator(); iv.hasNext(); )
+ {
+ int varIndex = ( (Node_RuleVariable) iv.next() ).getIndex();
+ if ( seenVar[varIndex] )
+ {
+ matchIndices.add( new Byte( (byte) varIndex ) );
+ }
seenVar[varIndex] = true;
}
-
+
// Build the join node
- if (prior == null) {
+ if ( prior == null )
+ {
// First clause, no joins yet
prior = clauseNode;
- } else {
- RETEQueue leftQ = new RETEQueue(matchIndices);
- RETEQueue rightQ = new RETEQueue(matchIndices);
- leftQ.setSibling(rightQ);
- rightQ.setSibling(leftQ);
- clauseNode.setContinuation(rightQ);
- prior.setContinuation(leftQ);
+ }
+ else
+ {
+ RETEQueue leftQ = new RETEQueue( matchIndices );
+ RETEQueue rightQ = new RETEQueue( matchIndices );
+ leftQ.setSibling( rightQ );
+ rightQ.setSibling( leftQ );
+ clauseNode.setContinuation( rightQ );
+ prior.setContinuation( leftQ );
prior = leftQ;
}
}
}
-
+
// Finished compiling a rule - add terminal
- if (prior != null) {
- RETETerminal term = createTerminal(rule);
- prior.setContinuation(term);
+ if ( prior != null )
+ {
+ RETETerminal term = createTerminal( rule );
+ prior.setContinuation( term );
}
-
+
}
if (wildcardRule) predicatePatterns = null;
@@ -489,15 +514,17 @@ public class RETEEngine implements FRule
* Scan the rules for any axioms and insert those
*/
protected void findAndProcessAxioms() {
- for (Iterator<Rule> i = rules.iterator(); i.hasNext(); ) {
- Rule r = i.next();
- if (r.isAxiom()) {
+ for ( Rule r : rules )
+ {
+ if ( r.isAxiom() )
+ {
// An axiom
- RETERuleContext context = new RETERuleContext(infGraph, this);
- context.setEnv(new BindingVector(new Node[r.getNumVars()]));
- context.setRule(r);
- if (context.shouldFire(true)) {
- RETEConflictSet.execute(context, true);
+ RETERuleContext context = new RETERuleContext( infGraph, this );
+ context.setEnv( new BindingVector( new Node[r.getNumVars()] ) );
+ context.setRule( r );
+ if ( context.shouldFire( true ) )
+ {
+ RETEConflictSet.execute( context, true );
}
/* // Old version, left during debug and final checks
for (int j = 0; j < r.headLength(); j++) {
@@ -519,20 +546,27 @@ public class RETEEngine implements FRule
*/
protected void findAndProcessActions() {
RETERuleContext tempContext = new RETERuleContext(infGraph, this);
- for (Iterator<Rule> i = rules.iterator(); i.hasNext(); ) {
- Rule r = i.next();
- if (r.bodyLength() == 0) {
- for (int j = 0; j < r.headLength(); j++) {
- Object head = r.getHeadElement(j);
- if (head instanceof Functor) {
- Functor f = (Functor)head;
+ for ( Rule r : rules )
+ {
+ if ( r.bodyLength() == 0 )
+ {
+ 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) {
- tempContext.setRule(r);
- tempContext.setEnv(new BindingVector( r.getNumVars() ));
- imp.headAction(f.getArgs(), f.getArgLength(), tempContext);
- } else {
- throw new ReasonerException("Invoking undefined Functor " + f.getName() +" in " + r.toShortString());
+ if ( imp != null )
+ {
+ tempContext.setRule( r );
+ tempContext.setEnv( new BindingVector( r.getNumVars() ) );
+ imp.headAction( f.getArgs(), f.getArgLength(), tempContext );
+ }
+ else
+ {
+ throw new ReasonerException(
+ "Invoking undefined Functor " + f.getName() + " in " + r.toShortString() );
}
}
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEQueue.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEQueue.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEQueue.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RETEQueue.java Tue Jun 24 09:06:50 2014
@@ -68,7 +68,7 @@ public class RETEQueue implements RETESi
int len = matchIndexList.size();
matchIndices = new byte[len];
for (int i = 0; i < len; i++) {
- matchIndices[i] = matchIndexList.get(i).byteValue();
+ matchIndices[i] = matchIndexList.get( i );
}
this.queue = new BindingVectorMultiSet(matchIndices);
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RuleClauseCode.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RuleClauseCode.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RuleClauseCode.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RuleClauseCode.java Tue Jun 24 09:06:50 2014
@@ -357,19 +357,19 @@ public class RuleClauseCode {
private List<Node>[] termVarTable;
/** Map from variables to the list of term positions in which it occurs */
- private Map<Node_RuleVariable, List<TermIndex>> varOccurrence = new HashMap<Node_RuleVariable, List<TermIndex>>();
+ private Map<Node_RuleVariable, List<TermIndex>> varOccurrence = new HashMap<>();
/** List of all permanent variables */
- private List<Node_RuleVariable> permanentVars = new ArrayList<Node_RuleVariable>();
+ private List<Node_RuleVariable> permanentVars = new ArrayList<>();
/** List of all temporary variables */
- private List<Node_RuleVariable> tempVars = new ArrayList<Node_RuleVariable>();
+ private List<Node_RuleVariable> tempVars = new ArrayList<>();
/** The total number of var occurrences */
int totalOccurrences = 0;
/** the set of variables processed so far during the compile phase */
- Set<Node_RuleVariable> seen = new HashSet<Node_RuleVariable>();
+ Set<Node_RuleVariable> seen = new HashSet<>();
/** The rule being parsed */
Rule rule;
@@ -383,7 +383,7 @@ public class RuleClauseCode {
this.rule = rule;
// Create a scratch area for assembling the code, use a worst-case size estimate
code = new byte[10 + totalOccurrences + rule.bodyLength()*10];
- args = new ArrayList<Object>();
+ args = new ArrayList<>();
}
/**
@@ -660,7 +660,7 @@ public class RuleClauseCode {
Node_RuleVariable var = (Node_RuleVariable)n;
List<TermIndex> occurrences = varOccurrence.get(var);
if (occurrences == null) {
- occurrences = new ArrayList<TermIndex>();
+ occurrences = new ArrayList<>();
varOccurrence.put(var, occurrences);
}
occurrences.add(new TermIndex(var, i, j));
@@ -670,22 +670,27 @@ public class RuleClauseCode {
// Classify vars as permanent unless they are just dummies (only used once at all)
// or only used head+first body goal (but not if used in a builtin)
- for (Iterator<List<TermIndex>> enti = varOccurrence.values().iterator(); enti.hasNext(); ) {
- List<TermIndex> occurrences = enti.next();
+ for ( List<TermIndex> occurrences : varOccurrence.values() )
+ {
Node_RuleVariable var = null;
boolean inFirst = false;
boolean inLaterBody = false;
boolean inBuiltin = false;
- for (Iterator<TermIndex> oi = occurrences.iterator(); oi.hasNext(); ) {
+ for ( Iterator<TermIndex> oi = occurrences.iterator(); oi.hasNext(); )
+ {
TermIndex occurence = oi.next();
var = occurence.var;
int termNumber = occurence.termNumber;
- if (termNumber == 0) {
+ if ( termNumber == 0 )
+ {
inFirst = true;
- } else if (termNumber > 1) {
+ }
+ else if ( termNumber > 1 )
+ {
inLaterBody = true;
}
- if (termNumber > 0 && rule.getBodyElement(termNumber-1) instanceof Functor) {
+ if ( termNumber > 0 && rule.getBodyElement( termNumber - 1 ) instanceof Functor )
+ {
inBuiltin = true;
}
}
@@ -693,15 +698,19 @@ public class RuleClauseCode {
// if (inBuiltin) {
// permanentVars.add(var);
// } else {
- if (!isDummy(var)) {
- if (inLaterBody || !inFirst) {
- permanentVars.add(var);
- } else {
- tempVars.add(var);
- }
+ if ( !isDummy( var ) )
+ {
+ if ( inLaterBody || !inFirst )
+ {
+ permanentVars.add( var );
}
+ else
+ {
+ tempVars.add( var );
+ }
+ }
// }
-
+
}
if (permanentVars.size() > MAX_PERMANENT_VARS) {
@@ -746,7 +755,7 @@ public class RuleClauseCode {
/** Return an list of variables or nodes in a ClauseEntry, in flattened order */
private List<Node> termVars(ClauseEntry term) {
- List<Node> result = new ArrayList<Node>();
+ List<Node> result = new ArrayList<>();
if (term instanceof TriplePattern) {
TriplePattern goal = (TriplePattern)term;
result.add(goal.getSubject());
@@ -760,8 +769,9 @@ public class RuleClauseCode {
}
} else if (term instanceof Functor) {
Node[] args = ((Functor)term).getArgs();
- for (int i = 0; i < args.length; i++) {
- result.add(args[i]);
+ for ( Node arg : args )
+ {
+ result.add( arg );
}
}
return result;
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RuleStore.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RuleStore.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RuleStore.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/RuleStore.java Tue Jun 24 09:06:50 2014
@@ -37,27 +37,28 @@ import com.hp.hpl.jena.util.OneToManyMap
public class RuleStore {
/** The set of rules indexed by head predicate */
- protected OneToManyMap<Node, Rule> goalMap = new OneToManyMap<Node, Rule>();
+ protected OneToManyMap<Node, Rule> goalMap = new OneToManyMap<>();
/** The list of all rules in the store */
protected List<Rule> allRules;
/** Index of the rules, used to block multiple entries */
- protected Set<Rule> ruleIndex = new HashSet<Rule>();
+ protected Set<Rule> ruleIndex = new HashSet<>();
/**
* Constructor. Create an empty rule store.
*/
public RuleStore() {
- allRules = new ArrayList<Rule>();
+ allRules = new ArrayList<>();
}
/**
* Constructor. Stores and indexes a list of rules.
*/
public RuleStore(List<Rule> rules) {
- for (Iterator<Rule> i = rules.iterator(); i.hasNext(); ) {
- addRule( i.next() );
+ for ( Rule rule : rules )
+ {
+ addRule( rule );
}
allRules = rules;
}
@@ -66,8 +67,9 @@ public class RuleStore {
* Add all the rules and from an existing rulestore into this one.
*/
public void addAll(RuleStore store) {
- for (Iterator<Rule> i = store.getAllRules().iterator(); i.hasNext(); ) {
- addRule( i.next() );
+ for ( Rule rule : store.getAllRules() )
+ {
+ addRule( rule );
}
}
@@ -144,7 +146,7 @@ public class RuleStore {
* @param goal the goal being matched
*/
public List<Rule> rulesFor(TriplePattern goal) {
- List<Rule> rules = new ArrayList<Rule>();
+ List<Rule> rules = new ArrayList<>();
if (goal.getPredicate().isVariable()) {
checkAll(goalMap.values().iterator(), goal, rules);
} else {
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/TempNodeCache.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/TempNodeCache.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/TempNodeCache.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/rulesys/impl/TempNodeCache.java Tue Jun 24 09:06:50 2014
@@ -40,10 +40,10 @@ import com.hp.hpl.jena.util.OneToManyMap
public class TempNodeCache {
/** Map from instance+property to value */
- protected OneToManyMap<NodePair, Node> ipMap = new OneToManyMap<NodePair, Node>();
+ protected OneToManyMap<NodePair, Node> ipMap = new OneToManyMap<>();
/** Map from temp to RDF class, if any */
- protected Map<Node, Node> classMap = new HashMap<Node, Node>();
+ protected Map<Node, Node> classMap = new HashMap<>();
/**
* Cosntructor.
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/GraphNode.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/GraphNode.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/GraphNode.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/GraphNode.java Tue Jun 24 09:06:50 2014
@@ -34,13 +34,13 @@ class GraphNode {
protected Node rdfNode;
/** The list of direct successor nodes to this node */
- protected Set<GraphNode> succ = new HashSet<GraphNode>();
+ protected Set<GraphNode> succ = new HashSet<>();
/** The list of direct predecessors nodes */
- protected Set<GraphNode> pred = new HashSet<GraphNode>();
+ protected Set<GraphNode> pred = new HashSet<>();
/** The set of all transitive successor nodes to this node */
- protected Set<GraphNode> succClosed = new HashSet<GraphNode>();
+ protected Set<GraphNode> succClosed = new HashSet<>();
/** An optional cache of the triples that represent succClosed */
protected List<Triple> succClosedTriples;
@@ -90,9 +90,9 @@ class GraphNode {
@Override void addSuccessors( Node base, TransitiveGraphCache tgc, ArrayList<Triple> result )
{
- for (Iterator<GraphNode> j = components.iterator(); j.hasNext(); )
+ for ( GraphNode component : components )
{
- result.add( new Triple(base, tgc.closedPredicate, j.next().rdfNode) );
+ result.add( new Triple( base, tgc.closedPredicate, component.rdfNode ) );
}
}
@@ -268,7 +268,7 @@ class GraphNode {
* node to the target node.
*/
public void propagateAdd(GraphNode target) {
- Set<GraphNode> sc = new HashSet<GraphNode>(target.succClosed);
+ Set<GraphNode> sc = new HashSet<>(target.succClosed);
sc.add(target);
visitPredecessors(new Visitor<Set<GraphNode>, GraphNode>() {
@Override
@@ -283,7 +283,7 @@ class GraphNode {
i.remove();
if (s == processing) {
// Can't remove immediately w/o beaking the visitor loop
- if (kill == null) kill = new ArrayList<GraphNode>();
+ if (kill == null) kill = new ArrayList<>();
kill.add(node);
} else {
s.pred.remove(node);
@@ -300,7 +300,7 @@ class GraphNode {
* node as lead.
*/
public void propagateSCC() {
- Set<GraphNode> visited = new HashSet<GraphNode>();
+ Set<GraphNode> visited = new HashSet<>();
visited.add(this);
// Scan predecessors not including ourselves
doVisitPredecessors(new Visitor<Set<GraphNode>, Object>() {
@@ -317,7 +317,7 @@ class GraphNode {
// s.pred.remove(node);
if (s == processing) {
// Can't remove immediately w/o beaking the visitor loop
- if (kill == null) kill = new ArrayList<GraphNode>();
+ if (kill == null) kill = new ArrayList<>();
kill.add(node);
} else {
s.pred.remove(node);
@@ -337,12 +337,12 @@ class GraphNode {
*/
public void makeLeadNodeFor(Set<GraphNode> members) {
// Accumulate all successors
- Set<GraphNode> newSucc = new HashSet<GraphNode>();
- Set<GraphNode> newSuccClosed = new HashSet<GraphNode>();
- for (Iterator<GraphNode> i = members.iterator(); i.hasNext(); ) {
- GraphNode n = i.next();
- newSucc.addAll(n.succ);
- newSuccClosed.addAll(n.succClosed);
+ Set<GraphNode> newSucc = new HashSet<>();
+ Set<GraphNode> newSuccClosed = new HashSet<>();
+ for ( GraphNode n : members )
+ {
+ newSucc.addAll( n.succ );
+ newSuccClosed.addAll( n.succClosed );
}
newSucc.removeAll(members);
newSuccClosed.removeAll(members);
@@ -350,24 +350,26 @@ class GraphNode {
succClosed = newSuccClosed;
// Rewrite all direct successors to have us as predecessor
- for (Iterator<GraphNode> i = succ.iterator(); i.hasNext();) {
- GraphNode n = i.next();
- n.pred.removeAll(members);
- n.pred.add(this);
+ for ( GraphNode n : succ )
+ {
+ n.pred.removeAll( members );
+ n.pred.add( this );
}
// Find all predecessor nodes and relink link them to point to us
- Set<GraphNode> done = new HashSet<GraphNode>();
- Set<GraphNode> newAliases = new HashSet<GraphNode>();
- for (Iterator<GraphNode> i = members.iterator(); i.hasNext(); ) {
- addSiblings( newAliases, i.next() );
+ Set<GraphNode> done = new HashSet<>();
+ Set<GraphNode> newAliases = new HashSet<>();
+ for ( GraphNode member : members )
+ {
+ addSiblings( newAliases, member );
}
becomeLeaderOf( newAliases );
- for (Iterator<GraphNode> i = members.iterator(); i.hasNext(); ) {
- GraphNode n = i.next();
- if (n != this) {
- pred.addAll(n.pred);
- n.relocateAllRefTo(this, done);
+ for ( GraphNode n : members )
+ {
+ if ( n != this )
+ {
+ pred.addAll( n.pred );
+ n.relocateAllRefTo( this, done );
n.becomeSubordinateOf( this );
}
}
@@ -419,11 +421,11 @@ class GraphNode {
*/
private List<Triple> triplesForSuccessors(Node base, boolean closed, TransitiveGraphCache tgc) {
Set<GraphNode> successors = closed ? succClosed : succ;
- ArrayList<Triple> result = new ArrayList<Triple>(successors.size() + 10);
+ ArrayList<Triple> result = new ArrayList<>(successors.size() + 10);
result.add(new Triple(base, tgc.closedPredicate, base)); // implicit reflexive case
- for (Iterator<GraphNode> i = successors.iterator(); i.hasNext(); ) {
- GraphNode s = i.next();
- result.add(new Triple(base, tgc.closedPredicate, s.rdfNode));
+ for ( GraphNode s : successors )
+ {
+ result.add( new Triple( base, tgc.closedPredicate, s.rdfNode ) );
s.siblings.addSuccessors( base, tgc, result );
}
siblings.addSuccessors( base, tgc, result );
@@ -453,14 +455,18 @@ class GraphNode {
StringBuffer sb = new StringBuffer();
sb.append("{");
boolean started = false;
- for (Iterator<GraphNode> i = s.iterator(); i.hasNext(); ) {
- if (started) {
- sb.append(", ");
- } else {
- started = true;
- }
- sb.append(i.next().toString());
- }
+ for ( GraphNode value : s )
+ {
+ if ( started )
+ {
+ sb.append( ", " );
+ }
+ else
+ {
+ started = true;
+ }
+ sb.append( value.toString() );
+ }
sb.append("}");
return sb.toString();
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/TransitiveEngine.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/TransitiveEngine.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/TransitiveEngine.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/TransitiveEngine.java Tue Jun 24 09:06:50 2014
@@ -162,11 +162,11 @@ public class TransitiveEngine {
*/
private void prepare() {
if (isPrepared) return;
- subClassAliases = new HashSet<Node>();
+ subClassAliases = new HashSet<>();
subClassAliases.add(subClassOf);
subClassAliases.add(directSubClassOf);
- subPropertyAliases = new HashSet<Node>();
+ subPropertyAliases = new HashSet<>();
subPropertyAliases.add(subPropertyOf);
subPropertyAliases.add(directSubPropertyOf);
@@ -379,7 +379,7 @@ public class TransitiveEngine {
// declarations - hence the double iteration
boolean foundAny = false;
boolean foundMore = false;
- HashSet<Node> cached = new HashSet<Node>();
+ HashSet<Node> cached = new HashSet<>();
do {
ExtendedIterator<Triple> subProps
= spCache.find(new TriplePattern(null, TransitiveReasoner.subPropertyOf, TransitiveReasoner.subPropertyOf));
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/TransitiveGraphCache.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/TransitiveGraphCache.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/TransitiveGraphCache.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/reasoner/transitiveReasoner/TransitiveGraphCache.java Tue Jun 24 09:06:50 2014
@@ -63,7 +63,7 @@ public class TransitiveGraphCache implem
protected boolean cacheTriples = false;
/** Map from RDF Node to the corresponding Graph node. */
- protected HashMap<Node, GraphNode> nodeMap = new HashMap<Node, GraphNode>();
+ protected HashMap<Node, GraphNode> nodeMap = new HashMap<>();
/** The RDF predicate representing the direct relation */
protected Node directPredicate;
@@ -76,7 +76,7 @@ public class TransitiveGraphCache implem
/** The original triples, needed for processing delete operations
* because some information is lost in the SCC process */
- protected Set<Triple> originalTriples = new HashSet<Triple>();
+ protected Set<Triple> originalTriples = new HashSet<>();
/**
* Inner class used to represent vistors than can be applied to each
@@ -113,16 +113,16 @@ public class TransitiveGraphCache implem
Iterator<GraphNode> aliasIterator = null;
/** stack of graph nodes being walked */
- ArrayList<GraphNode> nodeStack = new ArrayList<GraphNode>();
+ ArrayList<GraphNode> nodeStack = new ArrayList<>();
/** stack of iterators for the higher nodes in the walk */
- ArrayList<Iterator<GraphNode>> iteratorStack = new ArrayList<Iterator<GraphNode>>();
+ ArrayList<Iterator<GraphNode>> iteratorStack = new ArrayList<>();
/** The next value to be returned */
Triple next;
/** The set of junction nodes already visited */
- HashSet<GraphNode> visited = new HashSet<GraphNode>();
+ HashSet<GraphNode> visited = new HashSet<>();
/**
* Constructor. Creates an iterator which will walk
@@ -358,7 +358,7 @@ public class TransitiveGraphCache implem
// Reduce graph to DAG by factoring out SCCs
// startN.assertLinkTo(endN);
// First find all the members of the new component
- members = new HashSet<GraphNode>();
+ members = new HashSet<>();
members.add(endN);
startN.visitPredecessors(new Visitor<Set<GraphNode>, GraphNode>() {
@Override
@@ -400,7 +400,7 @@ public class TransitiveGraphCache implem
// This is a remove of a direct link possibly within an SCC
// Delay as long as possible and do deletes in a batch
if (deletesPending == null) {
- deletesPending = new HashSet<Triple>();
+ deletesPending = new HashSet<>();
}
deletesPending.add(t);
}
@@ -410,52 +410,58 @@ public class TransitiveGraphCache implem
*/
private void processDeletes() {
// The kernel is the set of start nodes of deleted links
- Set<GraphNode> kernel = new HashSet<GraphNode>();
- for (Iterator<Triple> i = deletesPending.iterator(); i.hasNext(); ) {
- Triple t = i.next();
- GraphNode start = nodeMap.get(t.getSubject());
- kernel.add(start);
- }
+ Set<GraphNode> kernel = new HashSet<>();
+ for ( Triple t : deletesPending )
+ {
+ GraphNode start = nodeMap.get( t.getSubject() );
+ kernel.add( start );
+ }
// The predecessor set of kernel
- Set<GraphNode> pKernel = new HashSet<GraphNode>();
+ Set<GraphNode> pKernel = new HashSet<>();
pKernel.addAll(kernel);
- for (Iterator<GraphNode> i = nodeMap.values().iterator(); i.hasNext(); ) {
- GraphNode n = i.next();
- for (Iterator<GraphNode> j = kernel.iterator(); j.hasNext();) {
- GraphNode target = j.next();
- if (n.pathTo(target)) {
- pKernel.add(n); break;
- }
- }
- }
+ for ( GraphNode n : nodeMap.values() )
+ {
+ for ( Iterator<GraphNode> j = kernel.iterator(); j.hasNext(); )
+ {
+ GraphNode target = j.next();
+ if ( n.pathTo( target ) )
+ {
+ pKernel.add( n );
+ break;
+ }
+ }
+ }
// Cut the pKernel away from the finge of nodes that it connects to
- for (Iterator<GraphNode> i = pKernel.iterator(); i.hasNext(); ) {
- GraphNode n = i.next();
- for (Iterator<GraphNode> j = n.succ.iterator(); j.hasNext(); ) {
- GraphNode fringe = j.next();
- if (! pKernel.contains(fringe)) {
- fringe.pred.remove(n);
- }
- }
- n.succ.clear();
- n.succClosed.clear();
- n.pred.clear();
- }
+ for ( GraphNode n : pKernel )
+ {
+ for ( Iterator<GraphNode> j = n.succ.iterator(); j.hasNext(); )
+ {
+ GraphNode fringe = j.next();
+ if ( !pKernel.contains( fringe ) )
+ {
+ fringe.pred.remove( n );
+ }
+ }
+ n.succ.clear();
+ n.succClosed.clear();
+ n.pred.clear();
+ }
// Delete the triples
originalTriples.removeAll(deletesPending);
deletesPending.clear();
// Reinsert the remaining links
- for (Iterator<Triple> i = originalTriples.iterator(); i.hasNext(); ) {
- Triple t = i.next();
- GraphNode n = nodeMap.get(t.getSubject());
- if (pKernel.contains(n)) {
- addRelation(t);
- }
- }
+ for ( Triple t : originalTriples )
+ {
+ GraphNode n = nodeMap.get( t.getSubject() );
+ if ( pKernel.contains( n ) )
+ {
+ addRelation( t );
+ }
+ }
}
/**
@@ -582,7 +588,7 @@ public class TransitiveGraphCache implem
if (gn_o == null) return NullIterator.instance();
gn_o = gn_o.leadNode();
if ( closed ? gn_s.pathTo(gn_o) : gn_s.directPathTo(gn_o) ) {
- return new SingletonIterator<Triple>(new Triple(s, pred, o));
+ return new SingletonIterator<>(new Triple(s, pred, o));
} else {
return NullIterator.instance();
}
@@ -624,9 +630,10 @@ public class TransitiveGraphCache implem
public void setCaching(boolean enable) {
if (! enable && cacheTriples) {
// Switching off so clear the existing cache
- for (Iterator<GraphNode> i = nodeMap.values().iterator(); i.hasNext(); ) {
- i.next().clearTripleCache();
- }
+ for ( GraphNode graphNode : nodeMap.values() )
+ {
+ graphNode.clearTripleCache();
+ }
}
cacheTriples = enable;
}
@@ -636,11 +643,11 @@ public class TransitiveGraphCache implem
*/
public String dump() {
StringBuffer sb = new StringBuffer();
- for (Iterator<GraphNode> i = nodeMap.values().iterator(); i.hasNext(); ) {
- GraphNode n = i.next();
- sb.append(n.dump());
- sb.append("\n");
- }
+ for ( GraphNode n : nodeMap.values() )
+ {
+ sb.append( n.dump() );
+ sb.append( "\n" );
+ }
return sb.toString();
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/LockMRSW.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/LockMRSW.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/LockMRSW.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/LockMRSW.java Tue Jun 24 09:06:50 2014
@@ -42,7 +42,7 @@ public class LockMRSW implements Lock
static Logger log = LoggerFactory.getLogger(LockMRSW.class) ;
// Map of threads to lock state for this lock
- Map<Thread, LockState> threadStates = new HashMap<Thread, LockState>() ;
+ Map<Thread, LockState> threadStates = new HashMap<>() ;
// We keep this is a variable because it is tested outside of a lock.
int threadStatesSize = threadStates.size() ;
@@ -180,7 +180,7 @@ public class LockMRSW implements Lock
synchronized
private String report(LockState state)
{
- StringBuffer sb = new StringBuffer() ;
+ StringBuilder sb = new StringBuilder() ;
sb.append("Thread R/W: ") ;
sb.append(Integer.toString(state.readLocks)) ;
sb.append("/") ;
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/RandomOrderGraph.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/RandomOrderGraph.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/RandomOrderGraph.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/RandomOrderGraph.java Tue Jun 24 09:06:50 2014
@@ -51,12 +51,12 @@ public class RandomOrderGraph extends Wr
@Override
public ExtendedIterator<Triple> find( TripleMatch m )
- { return new RandomOrderIterator<Triple>(bufsz,super.find( m ));
+ { return new RandomOrderIterator<>(bufsz,super.find( m ));
}
@Override
public ExtendedIterator<Triple> find( Node s, Node p, Node o )
- { return new RandomOrderIterator<Triple>(bufsz,super.find( s, p, o ));
+ { return new RandomOrderIterator<>(bufsz,super.find( s, p, o ));
}
@Override
public Capabilities getCapabilities() {
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/uuid/LibUUID.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/uuid/LibUUID.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/uuid/LibUUID.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/shared/uuid/LibUUID.java Tue Jun 24 09:06:50 2014
@@ -56,7 +56,7 @@ class LibUUID
// of this OS process (so two identical programs, starting at
// exactly the same time, might get the same seed).
- StringBuffer seedInput = new StringBuffer(200) ;
+ StringBuilder seedInput = new StringBuilder(200) ;
try { seedInput.append(InetAddress.getLocalHost().getHostAddress()) ; }
// Not every machine has an IP address.
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/CharEncoding.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/CharEncoding.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/CharEncoding.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/CharEncoding.java Tue Jun 24 09:06:50 2014
@@ -27,7 +27,7 @@ import java.util.*;
* character encodings.
*/
abstract public class CharEncoding {
- static Set<String> macEncodings = new HashSet<String>() ;
+ static Set<String> macEncodings = new HashSet<>() ;
static
{
macEncodings.add("MacArabic") ;
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/CollectionFactory.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/CollectionFactory.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/CollectionFactory.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/CollectionFactory.java Tue Jun 24 09:06:50 2014
@@ -30,32 +30,32 @@ public class CollectionFactory
Answer a new Map which uses hashing for lookup.
*/
public static <K,V> Map<K,V> createHashedMap()
- { return new HashMap<K,V>(); }
+ { return new HashMap<>(); }
/**
Answer a new Map which uses hashing for lookup and has initial size
<code>size</code>.
*/
public static <K,V> Map<K,V> createHashedMap( int size )
- { return new HashMap<K,V>( size ); }
+ { return new HashMap<>( size ); }
/**
Answer a new Map which uses hashing for lookup and is initialised to be
a copy of <code>toCopy</code>.
*/
public static <K,V> Map<K,V> createHashedMap( Map<K,V> toCopy )
- { return new HashMap<K,V>( toCopy ); }
+ { return new HashMap<>( toCopy ); }
/**
Answer a new Set which uses haashing for lookup.
*/
public static <T> Set<T> createHashedSet()
- { return new HashSet<T>(); }
+ { return new HashSet<>(); }
/**
Answer a new Set which uses hashing for lookup and is initialised as a copy
of <code>toCopy</code>.
*/
public static <T> Set<T> createHashedSet( Collection<T> toCopy )
- { return new HashSet<T>( toCopy ); }
+ { return new HashSet<>( toCopy ); }
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/FileManager.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/FileManager.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/FileManager.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/FileManager.java Tue Jun 24 09:06:50 2014
@@ -79,7 +79,7 @@ public class FileManager
static FileManager fmInstance = null ;
static boolean logAllLookups = true ;
- protected List<Locator> fmHandlers = new ArrayList<Locator>() ;
+ protected List<Locator> fmHandlers = new ArrayList<>() ;
protected LocationMapper fmMapper = null ;
// This forces Jena to initialize and wire in RIOT if available.
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/FileUtils.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/FileUtils.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/FileUtils.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/FileUtils.java Tue Jun 24 09:06:50 2014
@@ -166,7 +166,7 @@ public class FileUtils
if ( s.indexOf('%') < 0 )
return s ;
int len = s.length();
- StringBuffer sbuff = new StringBuffer(len) ;
+ StringBuilder sbuff = new StringBuilder(len) ;
for ( int i =0 ; i < len ; i++ )
{
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/IteratorCollection.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/IteratorCollection.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/IteratorCollection.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/IteratorCollection.java Tue Jun 24 09:06:50 2014
@@ -59,7 +59,7 @@ public class IteratorCollection
*/
public static <T> List<T> iteratorToList( Iterator<? extends T> it )
{
- List<T> result = new ArrayList<T>();
+ List<T> result = new ArrayList<>();
try { while (it.hasNext()) result.add( it.next() ); }
finally { NiceIterator.close( it ); }
return result;
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/LocationMapper.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/LocationMapper.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/LocationMapper.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/LocationMapper.java Tue Jun 24 09:06:50 2014
@@ -56,8 +56,8 @@ public class LocationMapper
static String s_globalMapperPath = null ;
- Map<String, String> altLocations = new HashMap<String, String>() ;
- Map<String, String> altPrefixes = new HashMap<String, String>() ;
+ Map<String, String> altLocations = new HashMap<>() ;
+ Map<String, String> altPrefixes = new HashMap<>() ;
static LocationMapper theMapper = null ;
@@ -181,16 +181,15 @@ public class LocationMapper
return altLocations.get(uri) ;
String newStart = null ;
String oldStart = null ;
- for ( Iterator<String> iter = altPrefixes.keySet().iterator() ; iter.hasNext() ;)
+ for ( String prefix : altPrefixes.keySet() )
{
- String prefix = iter.next() ;
- if ( uri.startsWith(prefix) )
+ if ( uri.startsWith( prefix ) )
{
- String s = altPrefixes.get(prefix) ;
+ String s = altPrefixes.get( prefix );
if ( newStart == null || newStart.length() < s.length() )
{
- oldStart = prefix ;
- newStart = s ;
+ oldStart = prefix;
+ newStart = s;
}
}
}
@@ -252,19 +251,16 @@ public class LocationMapper
public int hashCode()
{
int x = 0 ;
-
-
- for ( Iterator<String> iter = altLocations.keySet().iterator() ; iter.hasNext() ; )
+
+ for ( String k : altLocations.keySet() )
{
- String k = iter.next() ;
- String v = altLocations.get(k) ;
- x = x ^ k.hashCode() ^ v.hashCode() ;
+ String v = altLocations.get( k );
+ x = x ^ k.hashCode() ^ v.hashCode();
}
- for ( Iterator<String> iter = altPrefixes.keySet().iterator() ; iter.hasNext() ; )
+ for ( String k : altPrefixes.keySet() )
{
- String k = iter.next() ;
- String v = altPrefixes.get(k) ;
- x = x ^ k.hashCode() ^ v.hashCode() ;
+ String v = altPrefixes.get( k );
+ x = x ^ k.hashCode() ^ v.hashCode();
}
return x ;
}
@@ -281,20 +277,22 @@ public class LocationMapper
if ( altPrefixes.size() != other.altPrefixes.size() )
return false ;
-
- for ( Iterator<String> iter = altLocations.keySet().iterator() ; iter.hasNext() ; )
+
+ for ( String k : altLocations.keySet() )
+ {
+ String v = altLocations.get( k );
+ if ( !other.altLocations.get( k ).equals( v ) )
+ {
+ return false;
+ }
+ }
+ for ( String k : altPrefixes.keySet() )
{
- String k = iter.next() ;
- String v = altLocations.get(k) ;
- if ( ! other.altLocations.get(k).equals(v) )
- return false ;
- }
- for ( Iterator<String> iter = altPrefixes.keySet().iterator() ; iter.hasNext() ; )
- {
- String k = iter.next() ;
- String v = altPrefixes.get(k) ;
- if ( ! other.altPrefixes.get(k).equals(v) )
- return false ;
+ String v = altPrefixes.get( k );
+ if ( !other.altPrefixes.get( k ).equals( v ) )
+ {
+ return false;
+ }
}
return true ;
}
@@ -303,18 +301,16 @@ public class LocationMapper
public String toString()
{
String s = "" ;
- for ( Iterator<String> iter = altLocations.keySet().iterator() ; iter.hasNext() ; )
+ for ( String k : altLocations.keySet() )
{
- String k = iter.next() ;
- String v = altLocations.get(k) ;
- s = s+"(Loc:"+k+"=>"+v+") " ;
+ String v = altLocations.get( k );
+ s = s + "(Loc:" + k + "=>" + v + ") ";
}
- for ( Iterator<String> iter = altPrefixes.keySet().iterator() ; iter.hasNext() ; )
+ for ( String k : altPrefixes.keySet() )
{
- String k = iter.next() ;
- String v = altPrefixes.get(k) ;
- s = s+"(Prefix:"+k+"=>"+v+") " ;
+ String v = altPrefixes.get( k );
+ s = s + "(Prefix:" + k + "=>" + v + ") ";
}
return s ;
}
@@ -329,28 +325,28 @@ public class LocationMapper
public void toModel(Model model)
{
-
- for ( Iterator<String> iter = altLocations.keySet().iterator() ; iter.hasNext() ; )
- {
- Resource r = model.createResource() ;
- Resource e = model.createResource() ;
- model.add(r, LocationMappingVocab.mapping, e) ;
-
- String k = iter.next() ;
- String v = altLocations.get(k) ;
- model.add(e, LocationMappingVocab.name, k) ;
- model.add(e, LocationMappingVocab.altName, v) ;
- }
- for ( Iterator<String> iter = altPrefixes.keySet().iterator() ; iter.hasNext() ; )
- {
- Resource r = model.createResource() ;
- Resource e = model.createResource() ;
- model.add(r, LocationMappingVocab.mapping, e) ;
- String k = iter.next() ;
- String v = altPrefixes.get(k) ;
- model.add(e, LocationMappingVocab.prefix, k) ;
- model.add(e, LocationMappingVocab.altPrefix, v) ;
+ for ( String s1 : altLocations.keySet() )
+ {
+ Resource r = model.createResource();
+ Resource e = model.createResource();
+ model.add( r, LocationMappingVocab.mapping, e );
+
+ String k = s1;
+ String v = altLocations.get( k );
+ model.add( e, LocationMappingVocab.name, k );
+ model.add( e, LocationMappingVocab.altName, v );
+ }
+
+ for ( String s : altPrefixes.keySet() )
+ {
+ Resource r = model.createResource();
+ Resource e = model.createResource();
+ model.add( r, LocationMappingVocab.mapping, e );
+ String k = s;
+ String v = altPrefixes.get( k );
+ model.add( e, LocationMappingVocab.prefix, k );
+ model.add( e, LocationMappingVocab.altPrefix, v );
}
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/LocatorURL.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/LocatorURL.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/LocatorURL.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/LocatorURL.java Tue Jun 24 09:06:50 2014
@@ -124,11 +124,13 @@ public class LocatorURL implements Locat
String uriSchemeName = getScheme(filenameOrURI) ;
if ( uriSchemeName == null )
return false ;
- uriSchemeName = uriSchemeName.toLowerCase(Locale.ENGLISH) ;
- for ( int i = 0 ; i < schemeNames.length ; i++ )
+ uriSchemeName = uriSchemeName.toLowerCase(Locale.ENGLISH) ;
+ for ( String schemeName : schemeNames )
{
- if ( uriSchemeName.equals(schemeNames[i]) )
- return true ;
+ if ( uriSchemeName.equals( schemeName ) )
+ {
+ return true;
+ }
}
return false ;
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/Metadata.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/Metadata.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/Metadata.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/Metadata.java Tue Jun 24 09:06:50 2014
@@ -37,7 +37,7 @@ import com.hp.hpl.jena.shared.JenaExcept
public class Metadata
{
private static Logger log = LoggerFactory.getLogger(Metadata.class) ;
- List<String> resources = new ArrayList<String>() ;
+ List<String> resources = new ArrayList<>() ;
Properties properties = new Properties() ;
public Metadata() { }
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/MonitorGraph.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/MonitorGraph.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/MonitorGraph.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/MonitorGraph.java Tue Jun 24 09:06:50 2014
@@ -34,7 +34,7 @@ import com.hp.hpl.jena.graph.impl.*;
public class MonitorGraph extends WrappedGraph {
/** The last known snapshot, a set of triples */
- protected Set<Triple> snapshot = new HashSet<Triple>();
+ protected Set<Triple> snapshot = new HashSet<>();
/** Constructor, wrap the given graph with a state monitor */
public MonitorGraph(Graph g) {
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/MonitorModel.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/MonitorModel.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/MonitorModel.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/MonitorModel.java Tue Jun 24 09:06:50 2014
@@ -54,13 +54,15 @@ public class MonitorModel extends ModelC
List<Triple> deletionsTemp = (deletions != null) ? new ArrayList<Triple>() : null;
((MonitorGraph)getGraph()).snapshot(additionsTemp, deletionsTemp);
if (additions != null) {
- for (Iterator<Triple> i = additionsTemp.iterator(); i.hasNext(); ) {
- additions.add( this.asStatement(i.next()));
+ for ( Triple anAdditionsTemp : additionsTemp )
+ {
+ additions.add( this.asStatement( anAdditionsTemp ) );
}
}
if (deletions != null) {
- for (Iterator<Triple> i = deletionsTemp.iterator(); i.hasNext(); ) {
- deletions.add( this.asStatement(i.next()));
+ for ( Triple aDeletionsTemp : deletionsTemp )
+ {
+ deletions.add( this.asStatement( aDeletionsTemp ) );
}
}
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/OneToManyMap.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/OneToManyMap.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/OneToManyMap.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/OneToManyMap.java Tue Jun 24 09:06:50 2014
@@ -45,7 +45,7 @@ public class OneToManyMap<From, To> impl
//////////////////////////////////
/** Encapsulated hash table stores the values */
- private Map<From, List<To>> m_table = new HashMap<From, List<To>>();
+ private Map<From, List<To>> m_table = new HashMap<>();
// Constructors
@@ -68,9 +68,10 @@ public class OneToManyMap<From, To> impl
// copy the contents of the existing map
// note we can't just use the copying constructor for hashmap
// as we don't want to share the arraylists that are the key values
- for (Iterator<From> i = map.keySet().iterator(); i.hasNext(); ) {
- From key = i.next();
- for (Iterator<To> j = map.getAll( key ); j.hasNext(); ) {
+ for ( From key : map.keySet() )
+ {
+ for ( Iterator<To> j = map.getAll( key ); j.hasNext(); )
+ {
put( key, j.next() );
}
}
@@ -110,9 +111,12 @@ public class OneToManyMap<From, To> impl
*/
@Override
public boolean containsValue( Object value ) {
- for (Iterator<List<To>> values = m_table.values().iterator(); values.hasNext(); ) {
- List<To> x = values.next();
- if (x.contains( value )) return true;
+ for ( List<To> x : m_table.values() )
+ {
+ if ( x.contains( value ) )
+ {
+ return true;
+ }
}
return false;
}
@@ -144,13 +148,14 @@ public class OneToManyMap<From, To> impl
public Set<Map.Entry<From, To>> entrySet() {
Set<Map.Entry<From, To>> s = CollectionFactory.createHashedSet();
- for (Iterator<From> e0 = m_table.keySet().iterator(); e0.hasNext(); ) {
- From key = e0.next();
+ for ( From key : m_table.keySet() )
+ {
List<To> values = m_table.get( key );
// add each key-value pair to the result set
- for (ListIterator<To> e1 = values.listIterator(); e1.hasNext(); ) {
- s.add( new Entry<From, To>( key, e1.next() ) );
+ for ( ListIterator<To> e1 = values.listIterator(); e1.hasNext(); )
+ {
+ s.add( new Entry<>( key, e1.next() ) );
}
}
@@ -223,8 +228,9 @@ public class OneToManyMap<From, To> impl
@Override public int hashCode() {
int hc = 0;
- for (Iterator<Map.Entry<From, To>> i = entrySet().iterator(); i.hasNext(); ) {
- hc ^= i.next().hashCode();
+ for ( Map.Entry<From, To> fromToEntry : entrySet() )
+ {
+ hc ^= fromToEntry.hashCode();
}
return hc;
@@ -266,7 +272,7 @@ public class OneToManyMap<From, To> impl
@Override
public To put( From key, To value ) {
List<To> entries = m_table.get( key );
- if (entries == null) entries = new ArrayList<To>();
+ if (entries == null) entries = new ArrayList<>();
// add the new value to the list of values held against this key
entries.add( value );
m_table.put( key, entries );
@@ -282,21 +288,24 @@ public class OneToManyMap<From, To> impl
@Override
public void putAll( Map<? extends From, ? extends To> m ) {
boolean many = (m instanceof OneToManyMap<?,?>);
-
- for (Iterator<? extends From> i = m.keySet().iterator(); i.hasNext(); ) {
- From key = i.next();
- if (many) {
+
+ for ( From key : m.keySet() )
+ {
+ if ( many )
+ {
// Bizare way to write it but this way makes all compilers happy.
- OneToManyMap<?,?> Z = (OneToManyMap<?,?>)m ;
- @SuppressWarnings("unchecked")
- OneToManyMap<? extends From, ? extends To> X = (OneToManyMap<? extends From, ? extends To>) Z ;
- Iterator<? extends To> j = X.getAll( key ) ;
-
- for (; j.hasNext(); ) {
+ OneToManyMap<?, ?> Z = (OneToManyMap<?, ?>) m;
+ @SuppressWarnings( "unchecked" ) OneToManyMap<? extends From, ? extends To> X =
+ (OneToManyMap<? extends From, ? extends To>) Z;
+ Iterator<? extends To> j = X.getAll( key );
+
+ for (; j.hasNext(); )
+ {
put( key, j.next() );
}
}
- else {
+ else
+ {
put( key, m.get( key ) );
}
}
@@ -354,8 +363,9 @@ public class OneToManyMap<From, To> impl
@Override
public int size() {
int size = 0;
- for (Iterator<From> i = m_table.keySet().iterator(); i.hasNext(); ) {
- size += m_table.get( i.next() ).size();
+ for ( From from : m_table.keySet() )
+ {
+ size += m_table.get( from ).size();
}
return size;
}
@@ -370,8 +380,9 @@ public class OneToManyMap<From, To> impl
@Override
public Collection<To> values() {
Set<To> s = CollectionFactory.createHashedSet();
- for (Iterator<From> e = m_table.keySet().iterator(); e.hasNext(); ) {
- s.addAll( m_table.get(e.next()) );
+ for ( From from : m_table.keySet() )
+ {
+ s.addAll( m_table.get( from ) );
}
return s;
}
@@ -383,21 +394,22 @@ public class OneToManyMap<From, To> impl
@Override public String toString() {
StringBuffer buf = new StringBuffer( "OneToManyMap{" );
String sep = "";
-
- for (Iterator<From> i = keySet().iterator(); i.hasNext(); ) {
- Object key = i.next();
+
+ for ( From key : keySet() )
+ {
buf.append( sep );
buf.append( key );
buf.append( "={" );
-
+
String sep1 = "";
- for (Iterator<To> j = getAll(key); j.hasNext(); ) {
+ for ( Iterator<To> j = getAll( key ); j.hasNext(); )
+ {
buf.append( sep1 );
buf.append( j.next() );
- sep1=",";
+ sep1 = ",";
}
- buf.append("}");
- sep=",";
+ buf.append( "}" );
+ sep = ",";
}
buf.append("}");
return buf.toString();
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/PrintUtil.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/PrintUtil.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/PrintUtil.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/PrintUtil.java Tue Jun 24 09:06:50 2014
@@ -84,8 +84,9 @@ public class PrintUtil {
* Remove a set of prefix mappings from the table of known short forms
*/
public static void removePrefixMap(Map<String, String> map) {
- for(Iterator<String> i = map.keySet().iterator(); i.hasNext(); ) {
- prefixMapping.removeNsPrefix( i.next() );
+ for ( String s : map.keySet() )
+ {
+ prefixMapping.removeNsPrefix( s );
}
}
@@ -176,7 +177,7 @@ public class PrintUtil {
* Print an n-space indent to the given output stream
*/
public static void printIndent(PrintWriter out, int indent) {
- StringBuffer spaces = new StringBuffer();
+ StringBuilder spaces = new StringBuilder();
for (int i = 0; i < indent; i++) spaces.append(" ");
out.print(spaces.toString());
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/ResourceUtils.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/ResourceUtils.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/ResourceUtils.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/ResourceUtils.java Tue Jun 24 09:06:50 2014
@@ -85,9 +85,9 @@ public class ResourceUtils {
* greater than another resource under the partial order.
*/
public static <T extends Resource> List<T> maximalLowerElements( Iterator<T> resources, Property rel, boolean inverse ) {
- List<T> in = new ArrayList<T>();
- List<T> out = new ArrayList<T>();
- List<T> drop = new ArrayList<T>();
+ List<T> in = new ArrayList<>();
+ List<T> out = new ArrayList<>();
+ List<T> drop = new ArrayList<>();
while (resources.hasNext()) {
in.add( resources.next() );
@@ -131,12 +131,12 @@ public class ResourceUtils {
* @return A list of the resources removed from the parameter list l
*/
public static <T extends Resource> List<T> removeEquiv( List<T> l, Property p, Resource ref ) {
- List<T> equiv = new ArrayList<T>();
+ List<T> equiv = new ArrayList<>();
- for (Iterator<T> i = l.iterator(); i.hasNext(); ) {
- T r = i.next();
-
- if (r.hasProperty( p, ref ) && ref.hasProperty( p, r )) {
+ for ( T r : l )
+ {
+ if ( r.hasProperty( p, ref ) && ref.hasProperty( p, r ) )
+ {
// resource r is equivalent to the reference resource
equiv.add( r );
}
@@ -161,9 +161,9 @@ public class ResourceUtils {
*/
public static <T extends Resource> List<List<T>> partition( List<T> l, Property p ) {
// first copy the input so we can mess with it
- List<T> source = new ArrayList<T>();
+ List<T> source = new ArrayList<>();
source.addAll( l );
- List<List<T>> parts = new ArrayList<List<T>>();
+ List<List<T>> parts = new ArrayList<>();
while (!source.isEmpty()) {
// each step through the loop we pick a random element, and
@@ -218,7 +218,7 @@ public class ResourceUtils {
boolean changeOccured = false ;
- List<Triple> triples = new ArrayList<Triple>(WINDOW_SIZE) ;
+ List<Triple> triples = new ArrayList<>(WINDOW_SIZE) ;
// An optimization to prevent concatenating the two find() operations together every time through the outer loop
boolean onFirstIterator = true;
@@ -300,7 +300,7 @@ public class ResourceUtils {
Set<Resource> seen = CollectionFactory.createHashedSet();
// queue of resources we have not yet visited
- List<RDFNode> queue = new LinkedList<RDFNode>();
+ List<RDFNode> queue = new LinkedList<>();
queue.add( root );
while (!queue.isEmpty()) {
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/Tokenizer.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/Tokenizer.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/Tokenizer.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/Tokenizer.java Tue Jun 24 09:06:50 2014
@@ -130,7 +130,7 @@ public class Tokenizer {
}
case LITERAL_START:
char delim = source.charAt(p-1);
- StringBuffer literal = new StringBuffer();
+ StringBuilder literal = new StringBuilder();
while (p < source.length()) {
char c = source.charAt(p);
if (c == '\\') {
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/URIref.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/URIref.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/URIref.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/URIref.java Tue Jun 24 09:06:50 2014
@@ -159,8 +159,9 @@ public class URIref extends Object {
/** For simple testing ...
*/
static public void main(String args[]) {
- for (int i=0; i<args.length; i++) {
- System.out.println(args[i] + " => " + decode(args[i]) + " => " + encode(decode(args[i])));
+ for ( String arg : args )
+ {
+ System.out.println( arg + " => " + decode( arg ) + " => " + encode( decode( arg ) ) );
}
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/cache/RandCache.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/cache/RandCache.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/cache/RandCache.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/cache/RandCache.java Tue Jun 24 09:06:50 2014
@@ -45,7 +45,7 @@ public class RandCache implements Cache,
RandCache(String name, int size) {
this.size = size;
try {
- map = new HashMap<Object, Object>(size * 100 / 75); // based on .75 loadfactor
+ map = new HashMap<>(size * 100 / 75); // based on .75 loadfactor
} catch (IllegalArgumentException e) {
if ("Illegal load factor: NaN".equals(e.getMessage())) {
// This strange construction needs explanation.
@@ -57,7 +57,7 @@ public class RandCache implements Cache,
// which is completely mysterious but at least enables the unit tests to pass.
// - der 4/5/04
logger.warn("Detected a NaN anomaly believed to be due to use of JDK 1.4.1");
- map = new HashMap<Object, Object>(size*100/75, 0.75f);
+ map = new HashMap<>(size*100/75, 0.75f);
} else {
throw e;
}
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/EarlyBindingIterator.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/EarlyBindingIterator.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/EarlyBindingIterator.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/EarlyBindingIterator.java Tue Jun 24 09:06:50 2014
@@ -25,7 +25,7 @@ import java.util.*;
public class EarlyBindingIterator<T> extends WrappedIterator<T> {
static private <X> Iterator<X> early(Iterator<X> it) {
- List<X> v = new ArrayList<X>();
+ List<X> v = new ArrayList<>();
while (it.hasNext()) v.add(it.next());
close(it);
return v.iterator();
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/Filter.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/Filter.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/Filter.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/Filter.java Tue Jun 24 09:06:50 2014
@@ -33,7 +33,7 @@ public abstract class Filter<T>
public abstract boolean accept( T o );
public ExtendedIterator<T> filterKeep( Iterator<T> it )
- { return new FilterKeepIterator<T>( this, it ); }
+ { return new FilterKeepIterator<>( this, it ); }
public Filter<T> and( final Filter<T> other )
{ return other.isAny() ? this : new Filter<T>()
Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/NiceIterator.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/NiceIterator.java?rev=1605034&r1=1605033&r2=1605034&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/NiceIterator.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/util/iterator/NiceIterator.java Tue Jun 24 09:06:50 2014
@@ -89,7 +89,7 @@ public class NiceIterator<T> implements
public static <T> ExtendedIterator<T> andThen( final Iterator<T> a, final Iterator<? extends T> b )
{
- final List<Iterator<? extends T>> pending = new ArrayList<Iterator<? extends T>>( 2 );
+ final List<Iterator<? extends T>> pending = new ArrayList<>( 2 );
pending.add( b );
return new NiceIterator<T>()
{
@@ -152,21 +152,21 @@ public class NiceIterator<T> implements
*/
@Override
public ExtendedIterator<T> filterKeep( Filter<T> f )
- { return new FilterKeepIterator<T>( f, this ); }
+ { return new FilterKeepIterator<>( f, this ); }
/**
make a new iterator, which is our elements that do not pass the filter
*/
@Override
public ExtendedIterator<T> filterDrop( final Filter<T> f )
- { return new FilterDropIterator<T>( f, this ); }
+ { return new FilterDropIterator<>( f, this ); }
/**
make a new iterator which is the elementwise _map1_ of the base iterator.
*/
@Override
public <U> ExtendedIterator<U> mapWith( Map1<T, U> map1 )
- { return new Map1Iterator<T, U>( map1, this ); }
+ { return new Map1Iterator<>( map1, this ); }
/**
If <code>it</code> is a Closableiterator, close it. Abstracts away from
@@ -202,7 +202,7 @@ public class NiceIterator<T> implements
*/
public static <T> Set<T> asSet( ExtendedIterator<T> it )
{
- Set<T> result = new HashSet<T>();
+ Set<T> result = new HashSet<>();
while (it.hasNext()) result.add( it.next() );
return result;
}
@@ -213,7 +213,7 @@ public class NiceIterator<T> implements
*/
public static <T> List<T> asList( ExtendedIterator<T> it )
{
- List<T> result = new ArrayList<T>();
+ List<T> result = new ArrayList<>();
while (it.hasNext()) result.add( it.next() );
return result;
}