public class SPINUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
TYPE_CLASS_VAR_NAME
The name of the variable that will be used in type binding
triple patterns (?this rdf:type ?TYPE_CLASS)
|
| Constructor and Description |
|---|
SPINUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addQueryOrTemplateCalls(org.apache.jena.rdf.model.Resource cls,
org.apache.jena.rdf.model.Property predicate,
List<QueryOrTemplateCall> results)
Collects all queries or template calls at a given class.
|
static String |
addThisTypeClause(String str)
Inserts a statement ?this a ?TYPE_CLASS .
|
static void |
applyBindings(Map<org.apache.jena.rdf.model.Property,org.apache.jena.rdf.model.RDFNode> map,
Map<String,org.apache.jena.rdf.model.RDFNode> bindings)
Applies variable bindings, replacing the values of one map with
the values from a given variables map.
|
static void |
bindThis(org.apache.jena.query.QueryExecution qexec,
org.apache.jena.rdf.model.RDFNode value)
Binds the variable ?this with a given value.
|
static boolean |
containsThis(CommandWithWhere command)
Checks whether a given query mentions the variable ?this anywhere.
|
static org.apache.jena.rdf.model.RDFNode |
getFirstResult(org.apache.jena.query.QueryExecution qexec)
Executes a given SELECT query and returns the first value of the first result
variable, if any exists.
|
static String |
getQueryString(org.apache.jena.rdf.model.RDFNode node,
boolean usePrefixes)
Deprecated.
for the same reason as
TemplateCall.getQueryString() |
static Map<org.apache.jena.rdf.model.Statement,String> |
getQueryStringMap(org.apache.jena.rdf.model.Resource subject,
org.apache.jena.rdf.model.Property property)
Gets a Map of all query strings defined as values of a given property.
|
static Collection<String> |
getQueryStrings(org.apache.jena.rdf.model.Resource subject,
org.apache.jena.rdf.model.Property property)
Deprecated.
for the same reasons as
TemplateCall.getQueryString() |
static Set<org.apache.jena.rdf.model.Resource> |
getURIResources(Printable query) |
static boolean |
isLibraryOntology(org.apache.jena.graph.Graph graph,
URI baseURI)
Checks whether a given Graph is a spin:LibraryOntology.
|
static boolean |
isRootClass(org.apache.jena.rdf.model.Resource cls) |
static Map<String,org.apache.jena.rdf.model.RDFNode> |
mapProperty2VarNames(Map<org.apache.jena.rdf.model.Property,org.apache.jena.rdf.model.RDFNode> map)
Converts a map from Properties to RDFNode values to a Map from variable
names (Strings) to those values, for quicker look up.
|
public static final String TYPE_CLASS_VAR_NAME
public static void addQueryOrTemplateCalls(org.apache.jena.rdf.model.Resource cls,
org.apache.jena.rdf.model.Property predicate,
List<QueryOrTemplateCall> results)
cls - the class to get the queries atpredicate - the predicate such as spin:ruleresults - the List to add the results topublic static String addThisTypeClause(String str)
str - the input Stringpublic static void applyBindings(Map<org.apache.jena.rdf.model.Property,org.apache.jena.rdf.model.RDFNode> map, Map<String,org.apache.jena.rdf.model.RDFNode> bindings)
map - the Map to modifybindings - the current variable bindingspublic static void bindThis(org.apache.jena.query.QueryExecution qexec,
org.apache.jena.rdf.model.RDFNode value)
qexec - the QueryExecution to modifyvalue - the value to bind ?this withpublic static boolean containsThis(CommandWithWhere command)
command - the query to testpublic static org.apache.jena.rdf.model.RDFNode getFirstResult(org.apache.jena.query.QueryExecution qexec)
qexec - the QueryExecution to executepublic static String getQueryString(org.apache.jena.rdf.model.RDFNode node, boolean usePrefixes)
TemplateCall.getQueryString()node - the RDFNode to convertusePrefixes - true to use qname abbreviationsIllegalArgumentException - if the node is not a valid SPIN Query or a Stringpublic static Collection<String> getQueryStrings(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property property)
TemplateCall.getQueryString()subject - the subject to get the values ofproperty - the property to querypublic static Map<org.apache.jena.rdf.model.Statement,String> getQueryStringMap(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property property)
subject - the subject to get the values ofproperty - the property to querypublic static Set<org.apache.jena.rdf.model.Resource> getURIResources(Printable query)
public static boolean isLibraryOntology(org.apache.jena.graph.Graph graph,
URI baseURI)
graph - the Graph to testbaseURI - the base URI of the Graph (to find the library ontology)public static boolean isRootClass(org.apache.jena.rdf.model.Resource cls)
public static Map<String,org.apache.jena.rdf.model.RDFNode> mapProperty2VarNames(Map<org.apache.jena.rdf.model.Property,org.apache.jena.rdf.model.RDFNode> map)
map - the old MapCopyright © 2017 TopQuadrant, Inc.. All rights reserved.