[rdfweb-dev] NEEDED: SIMPLE FOAF->Javabeans conversion
Leigh Dodds
ldodds at ingenta.com
Fri May 7 08:43:16 UTC 2004
Julian Bond wrote:
> "Is there any sample code out there where someone has converted some
> bits of FOAF into Javabeans"
>
>
> I think it's highly unlikely anyone has a generic toolkit for doing this
> as I'm not even sure it would be possible. But it's possible that
> someone's built a specific app that processed specific parts of FOAF
> into a javabean and wouldn't mind sharing the code. It's also entirely
> possible that nobody's ever done that.
Didn't I provide this already? [1]. Here's the example code snippet that
I just sent Marc and Paul, its uses the classes from the FOAF-a-Matic:
Model model = ModelFactory.createDefaultModel();
model.read("some-foaf.rdf", "");
PersonBeanFactory factory = new PersonBeanFactory(model);
Person person = factory.getPrimaryPerson();
...
System.out.println(person.getHomepage());
List friends = factory.getFriends();
for (Iterator iter = friends.iterator(); iter.hasNext(); )
{
Person friend = (Person)iter.next();
System.out.println(person.getFirstName() + " knows " +
friend.getFirstName());
}
Like I said [1], it's not perfect, but the code is reasonably clear I
think and there are even a few test cases. If I get time over the
weekend I'll package it up separately.
Cheers,
L.
[1]. http://rdfweb.org/pipermail/rdfweb-dev/2004-May/013173.html
More information about the foaf-dev
mailing list