foaf-beans 0.1

I’m pleased to announce the first iteration of a Java API for FOAF based around the Jena semantic web toolkit.
The API, which I’ve dubbed “foaf-beans”, is an attempt to provide a number of convenience classes that will allow Java developers to quickly get to grips with reading and writing FOAF data. With this in mind the API provides a thin layer of abstraction which hides much of the RDF processing, instead presenting the user with simple factory classes that create FOAFGraph and FOAFWriter objects for reading and writing respectively. These objects generate and process simple Java Beans that should play nicely with other Java APIs and toolkits (particularly JSP, JSTL, etc).


In this first version of the API, the FOAFGraph interface supports:

  • Loading FOAF data from disk or the network
  • Determining the primaryTopic of a FOAF document, either using an explicit property of a foaf:PersonalProfileDocument,
    or some guesswork
  • Listing all people mentioned in a document
  • Finding people with a specific property (identified by URI) or property and value
  • Working with general RDF graphs as well as foaf:PersonalProfileDocuments
  • Reading basic foaf:Person properties and foaf:knows relationships

The FOAFWriter interface supports:

  • Writing basic foaf:Person metadata, including foaf:knows relationships
  • Writing to files, or POSTing to a URI (this is shamefully untested, but “release early” and all that…)
  • Writing foaf:PersonalProfileDocument documents including admin:generatorAgent and other
    useful metadata

Developers familiar with Jena can directly make use of a number of utility classes that provide this functionality, so hopefully there’s something for everyone.
The next release of the API will incorporate at least the following:

  • Smushing — a major failing, but this is version 0.1
  • Dealing more sensibly with multiple properties of the same person (e.g. several ‘blogs, emails, etc)
  • Better documentation and examples

It’s also worth noting that the API doesn’t do any inferencing or schema processing. If you dip into the Jena specific classes then you can substitute a model containing schema information, however I want to expose this more explicitly through the API. The basic classes and interfaces also have some basic hooks that will allow me to wire in other RDF toolkits as and when I get time to play with them (Redland is top of my list).
The majority of the code has been reasonably well tested but I don’t expect it to be bug free, so tread carefully. In fact in time honoured tradition I expect there’s at least one school boy error in there somewhere which’ll have me scrabbling to post 0.1.1 sometime tomorrow. The code has mainly evolved from work I originally did on the Java version of the FOAF-a-Matic, and there are a number of JUnit test cases included which should illustrate how the API works.
I’m happy to take suggestions, patches, bug reports, whatever. It’s all Public Domain (although attribution would be nice) so do with it what you will.
Download foaf-beans-0.1-src.zip (7.5MB, includes Jena)
Download foaf-beans-0.1-nolibs-src.zip (~200kb, no Jena)

One thought on “foaf-beans 0.1

Comments are closed.