org.topbraid.core.model
Class Statements

java.lang.Object
  extended by org.topbraid.core.model.Statements

public class Statements
extends java.lang.Object

A utility class for common operations concering Statements.

Author:
Holger Knublauch

Constructor Summary
Statements()
           
 
Method Summary
static void addObjectStatements(java.util.Set<com.hp.hpl.jena.rdf.model.Resource> reachedResources, com.hp.hpl.jena.rdf.model.Resource subject, com.hp.hpl.jena.rdf.model.Model model, java.util.Set<com.hp.hpl.jena.rdf.model.Statement> statements)
          Collects all Statements by a transitive traversal of the anonymous objects of statements with the resource as subject.
static void addStatements(java.util.Collection results, com.hp.hpl.jena.rdf.model.Model model, com.hp.hpl.jena.rdf.model.Resource subject, com.hp.hpl.jena.rdf.model.Property predicate)
           
static void delete(java.util.Iterator it)
           
static void delete(com.hp.hpl.jena.rdf.model.Statement statement)
          Deletes a Statement from an OntModel.
static void deleteWithDependingObjects(com.hp.hpl.jena.rdf.model.Statement statement)
          Deletes a Statement and all depending objects (such as anonymous superclasses).
static void deleteWithDependingObjects(com.hp.hpl.jena.rdf.model.StmtIterator it)
           
static java.util.Set<com.hp.hpl.jena.rdf.model.Resource> getDependingResources(java.util.Iterator resources)
           
static java.util.Set<com.hp.hpl.jena.rdf.model.Resource> getDependingResources(com.hp.hpl.jena.rdf.model.Resource resource)
           
static java.util.Set getDependingStatements(java.util.Iterator resources)
          Gets all Statements that need to be deleted if a given set of resources is deleted.
static java.util.Set getDependingStatements(java.util.Iterator resources, boolean includeObjectRefs)
           
static java.util.Set getDependingStatements(com.hp.hpl.jena.rdf.model.Resource resource)
           
static java.util.Set<com.hp.hpl.jena.rdf.model.Statement> getObjectStatements(com.hp.hpl.jena.rdf.model.Resource subject)
          Gets all statements that have a given subject, including all its depending statements in case they are about bnodes.
static com.hp.hpl.jena.graph.Graph getSourceGraph(com.hp.hpl.jena.rdf.model.Statement statement)
           
static java.util.List<com.hp.hpl.jena.rdf.model.Statement> getStatements(com.hp.hpl.jena.rdf.model.Resource subject, com.hp.hpl.jena.rdf.model.Property predicate)
          Gets an ordered list of Statements containing the properties of a given resource/predicate combination.
static boolean isDeletable(com.hp.hpl.jena.rdf.model.Statement statement)
          Checks if a Statement can be deleted.
static boolean isDeletable(com.hp.hpl.jena.rdf.model.StmtIterator it)
           
static boolean isInferred(com.hp.hpl.jena.rdf.model.Statement statement)
          Checks if a Statement is inferred, i.e.
static boolean isNotFromBaseModel(com.hp.hpl.jena.rdf.model.Statement statement)
          Checks if a Statement is imported.
static boolean isSystem(com.hp.hpl.jena.rdf.model.Statement statement)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Statements

public Statements()
Method Detail

addObjectStatements

public static void addObjectStatements(java.util.Set<com.hp.hpl.jena.rdf.model.Resource> reachedResources,
                                       com.hp.hpl.jena.rdf.model.Resource subject,
                                       com.hp.hpl.jena.rdf.model.Model model,
                                       java.util.Set<com.hp.hpl.jena.rdf.model.Statement> statements)
Collects all Statements by a transitive traversal of the anonymous objects of statements with the resource as subject. For example, this would find all anonymous superclasses or other expressions which depend on the subject as an object.

Parameters:
reachedResources -
subject - the subject to begin traversal at
model - the model to query
statements - the Set where the resulting Statements will be added to

addStatements

public static void addStatements(java.util.Collection results,
                                 com.hp.hpl.jena.rdf.model.Model model,
                                 com.hp.hpl.jena.rdf.model.Resource subject,
                                 com.hp.hpl.jena.rdf.model.Property predicate)

delete

public static void delete(java.util.Iterator it)

delete

public static void delete(com.hp.hpl.jena.rdf.model.Statement statement)
Deletes a Statement from an OntModel. This method is necessary because in the Jena API only one dedicated Graph can be edited. Whenever a Statement shall be deleted, this method is the safest way. Otherwise, the underlying triple may not be deleted even if an event is dispatched.

Parameters:
statement - the Statement to delete

deleteWithDependingObjects

public static void deleteWithDependingObjects(com.hp.hpl.jena.rdf.model.Statement statement)
Deletes a Statement and all depending objects (such as anonymous superclasses).

Parameters:
statement - the Statement to delete

deleteWithDependingObjects

public static void deleteWithDependingObjects(com.hp.hpl.jena.rdf.model.StmtIterator it)

getDependingResources

public static java.util.Set<com.hp.hpl.jena.rdf.model.Resource> getDependingResources(java.util.Iterator resources)

getDependingResources

public static java.util.Set<com.hp.hpl.jena.rdf.model.Resource> getDependingResources(com.hp.hpl.jena.rdf.model.Resource resource)

getDependingStatements

public static java.util.Set getDependingStatements(com.hp.hpl.jena.rdf.model.Resource resource)

getDependingStatements

public static java.util.Set getDependingStatements(java.util.Iterator resources)
Gets all Statements that need to be deleted if a given set of resources is deleted. This includes all Statements where the resources appears as subject, predicate or object, but also the following:

Parameters:
node -
Returns:

getDependingStatements

public static java.util.Set getDependingStatements(java.util.Iterator resources,
                                                   boolean includeObjectRefs)

getSourceGraph

public static com.hp.hpl.jena.graph.Graph getSourceGraph(com.hp.hpl.jena.rdf.model.Statement statement)

getObjectStatements

public static java.util.Set<com.hp.hpl.jena.rdf.model.Statement> getObjectStatements(com.hp.hpl.jena.rdf.model.Resource subject)
Gets all statements that have a given subject, including all its depending statements in case they are about bnodes.

Parameters:
subject - the subject to get the object statements of
Returns:
a set of statements

getStatements

public static java.util.List<com.hp.hpl.jena.rdf.model.Statement> getStatements(com.hp.hpl.jena.rdf.model.Resource subject,
                                                                                com.hp.hpl.jena.rdf.model.Property predicate)
Gets an ordered list of Statements containing the properties of a given resource/predicate combination.

Parameters:
subject - the subject
predicate - the predicate
Returns:
a List of Statements

isDeletable

public static boolean isDeletable(com.hp.hpl.jena.rdf.model.StmtIterator it)

isDeletable

public static boolean isDeletable(com.hp.hpl.jena.rdf.model.Statement statement)
Checks if a Statement can be deleted. A Statement can be deleted if its origin model is editable.

Parameters:
statement - the Statement to check
Returns:
true if statement can be deleted

isNotFromBaseModel

public static boolean isNotFromBaseModel(com.hp.hpl.jena.rdf.model.Statement statement)
Checks if a Statement is imported.

Parameters:
statement - the Statement to check
Returns:
true if statement is not from the current base model

isInferred

public static boolean isInferred(com.hp.hpl.jena.rdf.model.Statement statement)
Checks if a Statement is inferred, i.e. if it is stored in an inference Graph.

Parameters:
statement - the Statement to check
Returns:
true if statement is inferred

isSystem

public static boolean isSystem(com.hp.hpl.jena.rdf.model.Statement statement)