-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
340 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/anqit/spanqit/graphpattern/BNodeTriplePattern.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.anqit.spanqit.graphpattern; | ||
|
||
import com.anqit.spanqit.rdf.RdfBlankNode.PropertiesBlankNode; | ||
import com.anqit.spanqit.rdf.RdfObject; | ||
import com.anqit.spanqit.rdf.RdfPredicate; | ||
|
||
/** | ||
* A triple pattern formed by a property-list blank node | ||
* | ||
* @see <a href="https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#QSynBlankNodes"> | ||
* blank node syntax</a> | ||
*/ | ||
class BNodeTriplePattern implements TriplePattern<BNodeTriplePattern> { | ||
private PropertiesBlankNode bnode; | ||
|
||
BNodeTriplePattern(PropertiesBlankNode subject) { | ||
this.bnode = subject; | ||
} | ||
|
||
@Override | ||
public BNodeTriplePattern andHas(RdfPredicate predicate, RdfObject... objects) { | ||
bnode.andHas(predicate, objects); | ||
|
||
return this; | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public String getQueryString() { | ||
return bnode.getQueryString() + SUFFIX; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 28 additions & 54 deletions
82
src/main/java/com/anqit/spanqit/graphpattern/TriplePattern.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,28 @@ | ||
package com.anqit.spanqit.graphpattern; | ||
|
||
import com.anqit.spanqit.core.QueryElementCollection; | ||
import com.anqit.spanqit.rdf.RdfObject; | ||
import com.anqit.spanqit.rdf.RdfPredicate; | ||
import com.anqit.spanqit.rdf.RdfSubject; | ||
|
||
/** | ||
* A SPARQL Triple Pattern. | ||
* | ||
* @see <a | ||
* href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#QSynTriples"> | ||
* Triple pattern syntax</a> | ||
*/ | ||
public class TriplePattern extends QueryElementCollection<RdfPredicateRdfObjectListPair> implements GraphPattern { | ||
private RdfSubject subject; | ||
|
||
TriplePattern(RdfSubject subject, RdfPredicate predicate, | ||
RdfObject... objects) { | ||
super(" ;\n\t"); | ||
this.subject = subject; | ||
andHas(predicate, objects); | ||
} | ||
|
||
/** | ||
* Using the predicate-object and object list mechanisms, expand this triple pattern to include | ||
* triples consisting of this subject, and the given predicate and object(s) | ||
* | ||
* @param predicate the predicate of the triple to add | ||
* @param objects the object or objects of the triple to add | ||
* | ||
* @return this triple pattern | ||
* | ||
* @see <a href="https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#predObjLists"> | ||
* Predicate-Object Lists</a> | ||
* @see <a href="https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#objLists"> | ||
* Object Lists</a> | ||
*/ | ||
public TriplePattern andHas(RdfPredicate predicate, RdfObject... objects) { | ||
elements.add(new RdfPredicateRdfObjectListPair(predicate, objects)); | ||
|
||
return this; | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public String getQueryString() { | ||
return subject.getQueryString() + " " + super.getQueryString() + " ."; | ||
} | ||
} | ||
package com.anqit.spanqit.graphpattern; | ||
|
||
import com.anqit.spanqit.rdf.RdfObject; | ||
import com.anqit.spanqit.rdf.RdfPredicate; | ||
|
||
/** | ||
* Denotes a SPARQL Triple Pattern | ||
* | ||
* @param <T> the type of triple pattern; used to support fluency | ||
* | ||
* @see <a | ||
* href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#QSynTriples"> | ||
* Triple pattern syntax</a> | ||
* @see <a href="https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#QSynBlankNodes"> | ||
* blank node syntax</a> | ||
*/ | ||
public interface TriplePattern<T extends TriplePattern<T>> extends GraphPattern { | ||
static String SUFFIX = " ."; | ||
|
||
/** | ||
* add predicate-object lists describing this triple pattern's subject | ||
* | ||
* @param predicate the predicate to use to describe this triple pattern's subject | ||
* @param objects the corresponding object(s) | ||
* @return this triple pattern | ||
*/ | ||
public T andHas(RdfPredicate predicate, RdfObject... objects); | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/com/anqit/spanqit/graphpattern/TriplesSameSubject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.anqit.spanqit.graphpattern; | ||
|
||
import com.anqit.spanqit.rdf.Rdf; | ||
import com.anqit.spanqit.rdf.RdfObject; | ||
import com.anqit.spanqit.rdf.RdfPredicate; | ||
import com.anqit.spanqit.rdf.RdfPredicateObjectListCollection; | ||
import com.anqit.spanqit.rdf.RdfSubject; | ||
|
||
/** | ||
* A SPARQL Triple Pattern. | ||
* | ||
* @see <a | ||
* href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#QSynTriples"> | ||
* Triple pattern syntax</a> | ||
*/ | ||
class TriplesSameSubject implements TriplePattern<TriplesSameSubject> { | ||
private RdfSubject subject; | ||
private RdfPredicateObjectListCollection predicateObjectLists = Rdf.predicateObjectListCollection(); | ||
|
||
TriplesSameSubject(RdfSubject subject, RdfPredicate predicate, RdfObject... objects) { | ||
this.subject = subject; | ||
andHas(predicate, objects); | ||
} | ||
|
||
/** | ||
* Using the predicate-object and object list mechanisms, expand this triple pattern to include | ||
* triples consisting of this subject, and the given predicate and object(s) | ||
* | ||
* @param predicate the predicate of the triple to add | ||
* @param objects the object or objects of the triple to add | ||
* | ||
* @return this triple pattern | ||
* | ||
* @see <a href="https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#predObjLists"> | ||
* Predicate-Object Lists</a> | ||
* @see <a href="https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#objLists"> | ||
* Object Lists</a> | ||
*/ | ||
@Override | ||
public TriplesSameSubject andHas(RdfPredicate predicate, RdfObject... objects) { | ||
predicateObjectLists.andHas(predicate, objects); | ||
|
||
return this; | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public String getQueryString() { | ||
return subject.getQueryString() + " " + predicateObjectLists.getQueryString() + SUFFIX; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.anqit.spanqit.rdf; | ||
|
||
/** | ||
* A class with static methods to create basic RDF objects | ||
*/ | ||
public class Rdf { | ||
|
||
private Rdf() { } | ||
|
||
public static RdfPredicateObjectListCollection predicateObjectListCollection() { | ||
return new RdfPredicateObjectListCollection(); | ||
} | ||
} |
Oops, something went wrong.