| java.lang.Object com.hp.hpl.jena.util.ResourceUtils
ResourceUtils | public class ResourceUtils (Code) | |
General utility methods that operate on RDF resources, but which are not specific
to a given model.
author: Ian Dickinson, HP Labs author: (email) version: CVS $Id: ResourceUtils.java,v 1.16 2008/01/02 12:07:44 andy_seaborne Exp $ |
Method Summary | |
public static List | maximalLowerElements(Collection resources, Property rel, boolean inverse)
Answer the maximal lower elements of the given collection, given the partial
ordering rel . | public static List | maximalLowerElements(Iterator resources, Property rel, boolean inverse)
Given a collection of resources, and a relation defining a partial order over
those resources, answer the sub-collection that contains only those elements
that appear in the maximal generator of the relation. | public static List | partition(List l, Property p) Answer a list of lists, which is a partition of the given
input list of resources. | public static Model | reachableClosure(Resource root) Answer a model that contains all of the resources reachable from a given
resource by any property, transitively. | public static List | removeEquiv(List l, Property p, Resource ref) Remove from the given list l of
Resource Resources , any Resource that is equivalent
to the reference resource ref under the relation p . | public static Resource | renameResource(Resource old, String uri) Answer a new resource that occupies the same position in the graph as the current
resource old , but that has the given URI. |
maximalLowerElements | public static List maximalLowerElements(Collection resources, Property rel, boolean inverse)(Code) | |
Answer the maximal lower elements of the given collection, given the partial
ordering rel . See
ResourceUtils.maximalLowerElements(Iterator,Property,boolean) for details.
Parameters: resources - A collection of resources Parameters: rel - A property defining a partial-ordering on resources Parameters: inverse - If true, we invert the given property (by reversing the orderof the arguments), which allows us to use eg subClassOf as a partial order operator for both sub-class and super-class relationships The collection that contains only those resources are notgreater than another resource under the partial order. |
maximalLowerElements | public static List maximalLowerElements(Iterator resources, Property rel, boolean inverse)(Code) | |
Given a collection of resources, and a relation defining a partial order over
those resources, answer the sub-collection that contains only those elements
that appear in the maximal generator of the relation. Specifically, a resource
x is excluded from the return value if there is another resource
y in the input collection such that y Rel x holds.
Parameters: resources - An iterator over a collection of resources Parameters: rel - A property defining a partial-ordering on resources Parameters: inverse - If true, we invert the given property (by reversing the orderof the arguments), which allows us to use eg subClassOf as a partial order operator for both sub-class and super-class relationships The list that contains only those resources are notgreater than another resource under the partial order. |
partition | public static List partition(List l, Property p)(Code) | | Answer a list of lists, which is a partition of the given
input list of resources. The equivalence relation is the predicate p.
So, two resources a and b
will be in the same partition iff
(a p b) && (b p a) .
Parameters: l - A list of resources Parameters: p - An equivalence predicate A list of lists which are the partitions of l under p |
reachableClosure | public static Model reachableClosure(Resource root)(Code) | | Answer a model that contains all of the resources reachable from a given
resource by any property, transitively. The returned graph is the sub-graph
of the parent graph of root, whose root node is the given root. Cycles are
permitted in the sub-graph.
Parameters: root - The root node of the sub-graph to extract A model containing all reachable RDFNodes from root by any property. |
removeEquiv | public static List removeEquiv(List l, Property p, Resource ref)(Code) | | Remove from the given list l of
Resource Resources , any Resource that is equivalent
to the reference resource ref under the relation p . Typically,
p will be owl:subClassOf or owl:subPropertyOf
or some similar predicate. A resource R is defined to be equivalent to ref
iff R p ref is true and ref p R is true.
The equivalent resources are removed from list l
in place, the return value is the list of removed resources.
Parameters: l - A list of resources from which the resources equivalent to ref will be removed Parameters: p - An equivalence predicate Parameters: ref - A reference resource A list of the resources removed from the parameter list l |
renameResource | public static Resource renameResource(Resource old, String uri)(Code) | | Answer a new resource that occupies the same position in the graph as the current
resource old , but that has the given URI. In the process, the existing
statements referring to old are removed. Since Jena does not allow the
identity of a resource to change, this is the closest approximation to a rename operation
that works.
Notes: This method does minimal checking, so renaming a resource
to its own URI is unpredictable. Furthermore, it is a general and simple approach, and
in given applications it may be possible to do this operation more efficiently. Finally,
if res is a property, existing statements that use the property will not
be renamed, nor will occurrences of res in other models.
Parameters: old - An existing resource in a given model Parameters: uri - A new URI for resource old, or null to rename old to a bNode A new resource that occupies the same position in the graph as old, but whichhas the new given URI. |
|
|