|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.semanticdesktop.aperture.rdf.util.ModelUtil
public class ModelUtil
This class contains utility methods that facilitate the generation of various values from an RDF2Go model. The interface is deliberately similar to that of a ValueFactory, but this class can be used in situations when the code has to work directly with a model, without it being wrapped in an RDFContainer.
Constructor Summary | |
---|---|
ModelUtil()
|
Method Summary | |
---|---|
static Object |
convertNode(Node node,
Class<?> clazz)
Converts a node to an instance of the given class. |
static BlankNode |
createBlankNode(Model model)
|
static Literal |
createLiteral(Model model,
boolean value)
|
static Literal |
createLiteral(Model model,
byte value)
|
static Literal |
createLiteral(Model model,
double value)
|
static Literal |
createLiteral(Model model,
float value)
|
static Literal |
createLiteral(Model model,
int value)
|
static Literal |
createLiteral(Model model,
long value)
|
static Literal |
createLiteral(Model model,
short value)
|
static Literal |
createLiteral(Model model,
String label)
|
static Literal |
createLiteral(Model model,
String label,
URI datatype)
|
static Statement |
createStatement(Model model,
Resource subject,
URI predicate,
Node object)
|
static URI |
createURI(Model model,
String uri)
|
static URI |
createURI(Model model,
String namespaceUri,
String localName)
|
static Resource |
generateRandomResource(Model model)
This method creates resources that are used by the framework wherever a blank node is needed. |
static URI |
generateRandomURI(Model model)
This method creates URIs that are used by the framework wherever a random URI is needed. |
static List<Node> |
getAllPropertyValues(Model model,
Resource subject,
URI predicate)
Returns all values of a given property for the given resource. |
static Collection<Resource> |
getAllSubjectsWithProperty(Model model,
URI predicate,
Node object)
Returns all resources that have a given property with the given value. |
static List<Statement> |
getCBD(Resource node,
Model model,
boolean backwards)
Returns the Concise Bounded Description of a RDF Resource in a given Model. |
static String |
getFileName(URI uri)
Returns the file name from the uri. |
static String |
getLocalName(URI vx)
The RDF2Go interface doesn't support getting a local name from the URI. |
static Node |
getPropertyValue(Model model,
Resource subject,
URI predicate)
|
static Resource |
getSingleSubjectWithProperty(Model model,
URI predicate,
Node object)
Returns a resource that has a given property with the given value. |
static boolean |
hasStatement(Model model,
Resource subject,
URI predicate,
Node object)
|
static void |
readFileFromResource(Model model,
String path,
Syntax syntax)
Reads rdf from the resource at the given resource path to the given model |
static void |
removeAllPropertyValues(Model model,
Resource subject,
URI predicate)
Removes all values of the given property for the given resource. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ModelUtil()
Method Detail |
---|
public static Literal createLiteral(Model model, String label) throws ModelException
ModelException
public static Literal createLiteral(Model model, String label, URI datatype) throws ModelException
ModelException
public static Literal createLiteral(Model model, boolean value) throws ModelException
ModelException
public static Literal createLiteral(Model model, long value) throws ModelException
ModelException
public static Literal createLiteral(Model model, int value) throws ModelException
ModelException
public static Literal createLiteral(Model model, short value) throws ModelException
ModelException
public static Literal createLiteral(Model model, byte value) throws ModelException
ModelException
public static Literal createLiteral(Model model, double value) throws ModelException
ModelException
public static Literal createLiteral(Model model, float value) throws ModelException
ModelException
public static Statement createStatement(Model model, Resource subject, URI predicate, Node object)
public static URI createURI(Model model, String uri) throws ModelException
ModelException
public static URI createURI(Model model, String namespaceUri, String localName) throws ModelException
ModelException
public static BlankNode createBlankNode(Model model)
public static List<Statement> getCBD(Resource node, Model model, boolean backwards) throws ModelException
node
- The starting node.model
- The model holding the RDF Graph.backwards
- Indicates whether to traverse nodes backwards (null,null,RESOURCE).
ModelException
- Whenever access to the Model throws a ModelException.public static boolean hasStatement(Model model, Resource subject, URI predicate, Node object) throws ModelException
ModelException
public static Resource getSingleSubjectWithProperty(Model model, URI predicate, Node object)
model
- predicate
- object
-
NullPointerException
- if any of the arguments are null
ModelException
- if there are no, or more than one resources with the given property and the
given valuepublic static Collection<Resource> getAllSubjectsWithProperty(Model model, URI predicate, Node object)
model
- predicate
- object
-
public static Node getPropertyValue(Model model, Resource subject, URI predicate)
model
- The model to work with.subject
- The subject.predicate
- The property we would like to find.
public static List<Node> getAllPropertyValues(Model model, Resource subject, URI predicate)
model
- The model in which to look for values.subject
- The resource.predicate
- The property.
public static void removeAllPropertyValues(Model model, Resource subject, URI predicate)
model
- the model in which to look for valuessubject
- the resourcepredicate
- the propertypublic static Object convertNode(Node node, Class<?> clazz)
node
- the nodeclazz
- class to which the node should be converted, currently only primitive types are supported
and following RDF2Go classes: URI, Node and Literal
public static Resource generateRandomResource(Model model)
model
- a model for which the random resource should be generated
public static URI generateRandomURI(Model model)
model
- a model for which the random URI should be generated
public static void readFileFromResource(Model model, String path, Syntax syntax) throws FileNotFoundException, IOException, ModelException
model
- the model where the RDF data should be storedpath
- the resource pathsyntax
- the syntax
FileNotFoundException
- if the resource has not been foud
IOException
- if an I/O error occurs in the process
ModelException
- ...public static String getFileName(URI uri)
uri
-
public static String getLocalName(URI vx)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |