thewebsemantic
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 |
Bean2RDF(com.hp.hpl.jena.ontology.OntModel m)
construct a new instance bound to OntModel m. |
Method Summary |
void |
delete(java.lang.Object bean)
|
com.hp.hpl.jena.rdf.model.Resource |
save(java.lang.Object bean)
Saves bean to jena model. |
com.hp.hpl.jena.rdf.model.Resource |
saveDeep(java.lang.Object bean)
Saves the entire object graph starting with bean. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Bean2RDF
public Bean2RDF(com.hp.hpl.jena.ontology.OntModel m)
- construct a new instance bound to OntModel m.
- Parameters:
m
- Jena OntModel instance
save
public com.hp.hpl.jena.rdf.model.Resource save(java.lang.Object bean)
- Saves bean to jena model.
- Parameters:
bean
-
- Returns:
- jena resource representing bean within the model
delete
public void delete(java.lang.Object bean)
saveDeep
public com.hp.hpl.jena.rdf.model.Resource saveDeep(java.lang.Object bean)
- Saves the entire object graph starting with bean.
- Parameters:
bean
-
- Returns: