Class Bean2RDF
- java.lang.Object
-
- thewebsemantic.Base
-
- thewebsemantic.Bean2RDF
-
public class Bean2RDF extends Base
Converts a simple java bean to RDF, provided it's annotated with
Namespace. To make a bean persitable by jenabean, you are merely required to add the Namespace annotation. By default public bean properties are converted to rdf properties by appending "has" and proper casing the property name. For example, a bean with methods getName() and setName() would result in the RDF property "hasName", with the namespace given in the classes Namespace annotation.The default behavior for rdf property naming is overridden by using the RdfProperty annotation along with the getter method. The value supplied to the RdfProperty annotation is taken as the full RDF property URI.
The bean itself is typed using the Namespace annotation along with the bean name, for example, Book.class with namespace "http://example.org/" becomes rdf type "http://example.org/Book".
Here's a simple example of a bean that's ready to be saved:
package org.example; import thewebsemantic.Id; public Book { private String name; public void setName(String s) { name=s;} @Id public String getName() {return name;} }- See Also:
Namespace,Id,RdfProperty
-
-
Constructor Summary
Constructors Constructor Description Bean2RDF(org.apache.jena.rdf.model.Model m)construct a new instance bound to OntModelm.Bean2RDF(org.apache.jena.rdf.model.Model m, AnnotationHelper jpa)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete(Object bean)Deletesbeanfrom the model.voidn3()org.apache.jena.rdf.model.Resourcesave(Object bean)Savesbeanto jena model.org.apache.jena.rdf.model.ResourcesaveDeep(Object bean)Saves the entire object graph starting with bean.protected org.apache.jena.rdf.model.RDFNodetoRDFNode(Object o)-
Methods inherited from class thewebsemantic.Base
getModel, isBound, t, toRdfProperty
-
-
-
-
Field Detail
-
logger
public static Logger logger
-
-
Constructor Detail
-
Bean2RDF
public Bean2RDF(org.apache.jena.rdf.model.Model m)
construct a new instance bound to OntModelm.- Parameters:
m- Jena OntModel instance
-
Bean2RDF
public Bean2RDF(org.apache.jena.rdf.model.Model m, AnnotationHelper jpa)
-
-
Method Detail
-
save
public org.apache.jena.rdf.model.Resource save(Object bean)
Savesbeanto jena model.- Parameters:
bean-- Returns:
- jena resource representing bean within the model
-
delete
public void delete(Object bean)
Deletesbeanfrom the model.- Parameters:
bean-
-
saveDeep
public org.apache.jena.rdf.model.Resource saveDeep(Object bean)
Saves the entire object graph starting with bean.- Parameters:
bean-- Returns:
-
toRDFNode
protected org.apache.jena.rdf.model.RDFNode toRDFNode(Object o)
-
n3
public void n3()
-
-