Class 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
    • 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 OntModel m.
        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)
        Saves bean to jena model.
        Parameters:
        bean -
        Returns:
        jena resource representing bean within the model
      • delete

        public void delete​(Object bean)
        Deletes bean from 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()