<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cyberborean Chronicles &#187; RDFBeans</title>
	<atom:link href="http://blog.cyberborean.org/tag/rdfbeans/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.cyberborean.org</link>
	<description>by Alex Alishevskikh</description>
	<lastBuildDate>Wed, 18 Jan 2012 07:52:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>RDFBeans 2.0</title>
		<link>http://blog.cyberborean.org/2011/04/07/rdfbeans-2-0</link>
		<comments>http://blog.cyberborean.org/2011/04/07/rdfbeans-2-0#comments</comments>
		<pubDate>Thu, 07 Apr 2011 05:46:56 +0000</pubDate>
		<dc:creator>Alex Alishevskikh</dc:creator>
				<category><![CDATA[Howtos]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[RDF]]></category>
		<category><![CDATA[RDFBeans]]></category>
		<category><![CDATA[Semantic Web]]></category>

		<guid isPermaLink="false">http://blog.cyberborean.org/?p=695</guid>
		<description><![CDATA[The second edition of RDFBeans Java-to-RDF databinding framework is finally out. In 2.0 version the library underwent major refactoring to clean and enhance the API and provide new databinding techniques. RDFBeans is an open-source object-RDF databinding and persistence library for the Semantic Web development with Java language. It provides a framework for mapping an object-oriented [...]]]></description>
			<content:encoded><![CDATA[<p>The second edition of <a href="http://rdfbeans.sourceforge.net">RDFBeans</a> Java-to-RDF databinding framework is finally out. In 2.0 version the library underwent major refactoring to clean and enhance the API and provide new databinding techniques.</p>
<div class="excerpt fullwidth">
RDFBeans is an open-source object-RDF databinding and persistence library for the Semantic Web development with Java language. It provides a framework for mapping an object-oriented domain model to RDF resource descriptions. </p>
<p>For more information, see:</p>
<ul>
<li><a href="http://rdfbeans.sf.net">The project web-site</a></li>
<li><a href="http://rdfbeans.sourceforge.net/apidocs/index.html">Javadocs</a></li>
<li><a href="http://rdfbeans.sourceforge.net/download.html">How to get the sourcecode or configure Maven dependency</a></li>
</ul>
</div>
<p><span id="more-695"></span></p>
<h2>RDFBean interfaces and dynamic proxying</h2>
<p>Along with <a href="http://rdfbeans.sourceforge.net/usage.html#Working_with_RDFBean_classes">traditional JavaBean-like persisting technique</a> using RDFBean classes, the version 2.0 introduces new approach to object-RDF mapping: <a href="http://rdfbeans.sourceforge.net/usage.html#Working_with_RDFBean_interfaces">RDFBean interfaces</a>.</p>
<p>It works simply: you define an interface of your domain model object and annotate it just like an RDFBean class:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@RDFNamespaces<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;foaf = http://xmlns.com/foaf/0.1/&quot;</span><span style="color: #009900;">&#41;</span>
@RDFBean<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;foaf:Person&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> IPerson <span style="color: #009900;">&#123;</span>
&nbsp;
    @RDFSubject
    <span style="color: #003399;">String</span> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    @RDF<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;foaf:name&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #003399;">String</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">void</span> setName<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    @RDF<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;foaf:mbox&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #003399;">String</span> getEmail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">void</span> setEmail<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> email<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Then you instantiate the <code>RDFBeanManager</code> (was <code>RDFBinding</code> in RDFBeans 1.x) upon an RDF2Go Model and create a <em>dynamic proxy object</em> with your interface:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">ModelFactory modelFactory <span style="color: #339933;">=</span> RDF2Go.<span style="color: #006633;">getModelFactory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Model model <span style="color: #339933;">=</span> modelFactory.<span style="color: #006633;">createModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
model.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>        
RDFBeanManager manager <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RDFBeanManager<span style="color: #009900;">&#40;</span>model<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
IPerson person <span style="color: #339933;">=</span> manager.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://example.com/persons/jdoe&quot;</span>, IPerson.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>The methods of this proxy object are directed immediately to the underlying RDF triples, so that</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">person.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;John Doe&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
person.<span style="color: #006633;">setEmail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;john@example.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>will cause adding the statements to the model:</p>
<pre>
&lt;http://example.com/persons/jdoe&gt; a &lt;http://xmlns.com/foaf/0.1/Person&gt; ;
	&lt;http://xmlns.com/foaf/0.1/name&gt; "John Doe" ;
	&lt;http://xmlns.com/foaf/0.1/mbox&gt; "john@example.com" ;
</pre>
<p>Similarly, the getter methods will return values retrieved directly from these statements.</p>
<h2>RDFBean annotations</h2>
<p>The <a href="http://rdfbeans.sourceforge.net/rdfbean.html">annotations scheme</a> has changed, so the old classes will be incompatible with RDFBeans 2.0. As you can see in the example above, <code>@RDF</code> annotation is now applied to the getter methods but not to the field declaration like in the previous versions.</p>
<p>You also can notice new annotation, <code>@RDFNamespaces</code>, which defines a list of URI prefixes to be used in other RDFBean annotations declared in a given class or interface. This includes class and property URIs, as well as RDFBean identifiers:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@RDFNamespaces<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> 
	<span style="color: #0000ff;">&quot;foaf = http://xmlns.com/foaf/0.1/&quot;</span>,
	<span style="color: #0000ff;">&quot;persons = http://example.com/persons/&quot;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
@RDFBean<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;foaf:Person&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> IPerson <span style="color: #009900;">&#123;</span>
&nbsp;
	@RDFSubject<span style="color: #009900;">&#40;</span>prefix <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;persons:&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #003399;">String</span> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...</pre></div></div>

<p>Annotations are now inherited from superclasses and interfaces that makes the RDFBeans markup compatible with complex domain-specific object models. See how the <code>Thing</code>, <code>Agent</code> and <code>Person</code> classes of the <a href="http://rdfbeans.svn.sourceforge.net/viewvc/rdfbeans/tags/2.0/src/test/java/com/viceversatech/rdfbeans/test/foafexample/entities/">FOAF example</a> are organized to mimic the <code>owl:Thing → foaf:Agent → foaf:Person</code> subclassing in RDF-Schema.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cyberborean.org/2011/04/07/rdfbeans-2-0/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RDFBeans: Now on Sourceforge</title>
		<link>http://blog.cyberborean.org/2009/08/04/rdfbeans-now-on-sourceforge</link>
		<comments>http://blog.cyberborean.org/2009/08/04/rdfbeans-now-on-sourceforge#comments</comments>
		<pubDate>Tue, 04 Aug 2009 10:44:07 +0000</pubDate>
		<dc:creator>Alex Alishevskikh</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[RDF]]></category>
		<category><![CDATA[RDFBeans]]></category>
		<category><![CDATA[Semantic Web]]></category>

		<guid isPermaLink="false">http://blog.cyberborean.org/?p=471</guid>
		<description><![CDATA[RDFBeans framework (see &#8220;Simple RDF data binding&#8220;) is a Sourceforge project now: http://rdfbeans.sourceforge.net]]></description>
			<content:encoded><![CDATA[<p>RDFBeans framework (see &#8220;<a rel="bookmark" href="../2009/02/06/simple-rdf-data-binding">Simple RDF data binding</a>&#8220;) is a Sourceforge project now:</p>
<p class="hand"><a href="http://rdfbeans.sourceforge.net">http://rdfbeans.sourceforge.net</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cyberborean.org/2009/08/04/rdfbeans-now-on-sourceforge/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple RDF data binding</title>
		<link>http://blog.cyberborean.org/2009/02/06/simple-rdf-data-binding</link>
		<comments>http://blog.cyberborean.org/2009/02/06/simple-rdf-data-binding#comments</comments>
		<pubDate>Fri, 06 Feb 2009 19:52:45 +0000</pubDate>
		<dc:creator>Alex Alishevskikh</dc:creator>
				<category><![CDATA[Howtos]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[RDF]]></category>
		<category><![CDATA[RDFBeans]]></category>
		<category><![CDATA[Semantic Web]]></category>

		<guid isPermaLink="false">http://blog.cyberborean.org/?p=315</guid>
		<description><![CDATA[A large part of SW development is representing the information as RDF for persistence and interoperability. It&#8217;s usually done with lots of the glue code to map the programming object model to RDF triples and vice versa. Update: RDFBeans is an open-source object-RDF databinding and persistence library for the Semantic Web development with Java language. [...]]]></description>
			<content:encoded><![CDATA[<p>A large part of SW development is representing the information as RDF for persistence and interoperability. It&#8217;s usually done with lots of the glue code to map the programming object model to RDF triples and vice versa.</p>
<p><span id="more-315"></span></p>
<div class="excerpt">
<p><span class="upd"><strong>Update:</strong></span> RDFBeans is an open-source object-RDF databinding and persistence library for the Semantic Web development with Java language. It provides a framework for mapping an object-oriented domain model to RDF resource descriptions. </p>
<p>Information on this page is likely outdated. Please refer to:</p>
<ul>
<li><a href="http://rdfbeans.sf.net">The project web-site</a></li>
<li><a href="http://rdfbeans.sourceforge.net/apidocs/index.html">Javadocs</a></li>
<li><a href="http://rdfbeans.sourceforge.net/download.html">How to get the sourcecode or configure Maven dependency</a></li>
</ul>
<p>All posts about RDFBeans framework are <a href="/tag/rdfbeans">here</a>.
</div>
<p>Working on my current project, I had to deal with a rich object model  which is persisted into a RDF triple-store, so quickly I stuck in writing the object-triples translation code. I thought it would be a good idea to automate this by providing a simple data binding framework for transparent mapping of the Java objects to RDF (like <a href="http://www.hibernate.org/">Hibernate</a> and other tools does so for SQL or XML) with the following requirements in mind:</p>
<ul>
<li>It should be easy to make existing classes compatible with the framework with minimum modifications. This should not affect the business object model (no special interfaces and superclasses) and should not interfere with common <a class="zem_slink" title="JavaBean" rel="wikipedia" href="http://en.wikipedia.org/wiki/JavaBean">JavaBeans</a>-oriented frameworks (like Spring, etc.). Any <a class="zem_slink" title="JavaBean" rel="wikipedia" href="http://en.wikipedia.org/wiki/JavaBean">JavaBean</a>-like <a class="zem_slink" title="Plain Old Java Object" rel="wikipedia" href="http://en.wikipedia.org/wiki/Plain_Old_Java_Object">POJO</a> class can be  RDF-serializable just with few <a class="zem_slink" title="Java annotation" rel="wikipedia" href="http://en.wikipedia.org/wiki/Java_annotation">Java annotations</a> added.</li>
<li>No predefined ontologies and RDF-schemas are required.</li>
<li>Class information is stored in the RDF model for transparent instantiation of the objects.</li>
<li>Cascade binding for related objects should be supported.</li>
<li>Basic Java Collection types should be supported.</li>
</ul>
<p>This framework is implemented using Java annotations and Reflection APIs and works with major RDF triple-stores  (via <a href="http://semanticweb.org/wiki/RDF2Go">RDF2GO</a> abstraction layer).</p>
<h2>RDF Beans</h2>
<p>In order to be mapped to an RDF resource, a Java class must obey certain conventions:</p>
<ul>
<li>The class must have a public default (no-argument) constructor.</li>
<li>The class declaration must have a <code>@RDFBean</code> annotation to associate it with appropriate <a class="zem_slink" title="RDF Schema" rel="wikipedia" href="http://en.wikipedia.org/wiki/RDF_Schema">RDFS</a> class:

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;">@RDFBean<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://xmlns.com/foaf/0.1/Person&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Person <span style="color: #009900;">&#123;</span> ...</pre></div></div>

</li>
</ul>
<p>See also: <a href="http://cyberborean.org/files/rdfbeans/1.0/examples/Person.java">A RDFBean class example</a>.</p>
<h3>Properties</h3>
<p>The class properties must be accessible using standard getter and setter methods. The properties are mapped to their RDF counterparts with <code>@RDF</code> annotations:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@RDF<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://xmlns.com/foaf/0.1/name&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #003399;">String</span> name<span style="color: #339933;">;</span>
&nbsp;
@RDF<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://xmlns.com/foaf/0.1/mbox&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #003399;">String</span> email<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> name<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setName<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span> <span style="color: #339933;">=</span> name<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getEmail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> email<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setEmail<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> email<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">email</span> <span style="color: #339933;">=</span> email<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p>The argument of <code>@RDF</code> is a valid URI of a RDF property (predicate) in a domain of the specified RDFS class.  The following types of properties are permitted:</p>
<ul>
<li>A Literal (<code>String, Boolean, Date, Integer, Float, Double, Long, Short, Byte, java.net.URI</code>)</li>
<li>Another RDFBean class</li>
<li>A Java Collection (List or Set) of Literals or RDFBeans</li>
</ul>
<p>Literal values are represented in RDF with corresponding <a class="zem_slink" title="XML schema" rel="wikipedia" href="http://en.wikipedia.org/wiki/XML_schema">XML-Schema</a> datatypes and Collections with RDF Containers (<a href="http://www.w3.org/TR/rdf-schema/#ch_bag">rdf:Bag</a> or <a href="http://www.w3.org/TR/rdf-schema/#ch_seq">rdf:Seq</a> depending on a Collection type). References to other RDFBean objects will be kept as RDF object properties and the values will be represented as separate RDF resources.</p>
<h3>RDF subject</h3>
<p>There must be a special String property to hold an unique URI value to identify the RDF resource (the subject URI). It must be accessible with getter and setter methods and be marked with <code>@RDFSubject</code> annotation:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@RDFSubject
<span style="color: #003399;">String</span> id<span style="color: #339933;">;</span></pre></div></div>

<p>The property value must be a valid absolute URI, otherwise you can use the <code>prefix</code> argument for a common prefix to construct URIs from arbitrary String identifiers:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@RDFSubject<span style="color: #009900;">&#40;</span>prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://example.com/persons#&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #003399;">String</span> id<span style="color: #339933;">;</span></pre></div></div>

<h2>Data Binding</h2>
<p>RDFBeans data binding framework is based on <a href="http://semanticweb.org/wiki/RDF2Go">RDF2Go API</a> which creates an abstraction layer above physical RDF storages. It makes an RDF model independent from specific RDF frameworks (such as <a class="zem_slink" title="Sesame (framework)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Sesame_%28framework%29">Sesame</a> and <a class="zem_slink" title="Jena (framework)" rel="homepage" href="http://jena.sourceforge.net/">Jena</a>), thus it can work with any, if a RDF2Go adapter is implemented.  The data binding is performed using single <code>RDFBinding</code> class, which is initialized with existing RDF2Go model:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.cyberborean.rdfbeans.RDFBinding</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.ontoware.rdf2go.RDF2Go</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.ontoware.rdf2go.model.Model</span><span style="color: #339933;">;</span>
...
<span style="color: #006633;">Model</span> model <span style="color: #339933;">=</span> RDF2Go.<span style="color: #006633;">getModelFactory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">createModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
model.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
RDFBinding binding <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RDFBinding<span style="color: #009900;">&#40;</span>model<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The <code>marshal</code> method converts a Java object into a RDF resource in the model:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">Person person <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
person.<span style="color: #006633;">setId</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://example.com/staff#johndoe&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
person.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;John Doe&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
person.<span style="color: #006633;">setEmail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;johndoe@example.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...
<span style="color: #006633;">binding</span>.<span style="color: #006633;">marshal</span><span style="color: #009900;">&#40;</span>person<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This code will create a set of RDF statements representing the properties of the given object in the model:</p>

<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;">&lt;http://example.com/staff#johndoe&gt; &lt;http://www.w3.org/<span style="">1999</span>/02/<span style="">22</span>-rdf-syntax-ns#type&gt; &lt;http://xmlns.com/foaf/<span style="">0.1</span>/Person&gt; .
&lt;http://example.com/staff#johndoe&gt; &lt;http://xmlns.com/foaf/<span style="">0.1</span>/name&gt; &quot;John Doe&quot;^^&lt;http://www.w3.org/<span style="">2001</span>/XMLSchema#string&gt; .
&lt;http://example.com/staff#johndoe&gt; &lt;http://xmlns.com/foaf/<span style="">0.1</span>/mbox&gt; &quot;johndoe@example.com&quot;^^&lt;http://www.w3.org/<span style="">2001</span>/XMLSchema#string&gt; .</pre></div></div>

<p>Additionally, it adds a special statement to associate the RDFS class with Java:</p>

<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;">&lt;http://xmlns.com/foaf/<span style="">0.1</span>/Person&gt; &lt;http://cyberborean.org/rdfbeans/<span style="">1.0</span>/bindingClass&gt; &quot;com.example.Person&quot; .</pre></div></div>

<p>The <code>marshal</code> method inspects the properties which link the object with other RDFBeans and initiates their cascade binding to the RDF model, thus simplifying the development and ensuring referential integrity of the RDFBeans.</p>
<p>To reconstruct a Java object from RDF model, there is <code>unmarshal</code> method:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.ontoware.rdf2go.model.node.URI</span><span style="color: #339933;">;</span>
...
<span style="color: #006633;">URI</span> subject <span style="color: #339933;">=</span> model.<span style="color: #006633;">createURI</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://example.com/staff#johndoe&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Person person <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Person<span style="color: #009900;">&#41;</span> binding.<span style="color: #006633;">unmarshal</span><span style="color: #009900;">&#40;</span>subject<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The method creates new instance of the Java class (defined by <code>http://cyberborean.org/rdfbeans/1.0/bindingClass</code> property) and fill the properties with data from the RDF model. If a property holds a reference to another RDFBean, it results into cascade unmarshalling of related objects, thus restoring the original object model.</p>
<h2>Code</h2>
<ul>
<li><a href="http://cyberborean.org/files/rdfbeans/1.0/">RDFBeans JAR and source code</a></li>
<li><a href="http://cyberborean.org/files/rdfbeans/1.0/apidocs/">Javadocs</a></li>
</ul>
<p><strong>[Update: 2009-08-04]</strong></p>
<p>RDFBeans framework is released on SourceForge: <a href="http://rdfbeans.sourceforge.net/">http://rdfbeans.sourceforge.net</a>. The API has been changed, please check the <a href="http://rdfbeans.sourceforge.net/usage.html">documentation</a> and <a href="http://rdfbeans.sourceforge.net/apidocs/index.html">Javadocs</a> for details.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cyberborean.org/2009/02/06/simple-rdf-data-binding/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

