Writing "isA" method

13 views
Skip to first unread message

Drew

unread,
Jun 2, 2010, 1:03:04 PM6/2/10
to OpenAnzo
Hi,

I would like to write an "isA" method to determine if a given URI is
an instance or a subclass of another given URI.

E.g.:
if B is a subclass of A
and C is an instance of B
then isA(C, A) would be true

When I try to use the "find" method (e.g., find("C", "rdf:type",
null), I never see a statement listing "C a A", because I guess only
the statement "C a B" is explicitly stored. I have been experimenting
with the Statement.entails() method (on the result) to see if it can
tell me that therefore "C isA A", but either I am using it incorrectly
or maybe misunderstanding its purpose. Is there any example code of
its use? Or if this is completely the wrong track, do I just need to
implement my own "isA" method by hand that simply recursively executes
"finds" (until it gets to "class" or something)?

Thanks very much in advance for any help or direction you can give.

(P.S. BTW, my ultimate goal is to write a method that can return
_all_ instances & subclasses of a given URI.... If I could figure out
"isA", I was just planning to call it on every resource in the graph
to test if it should be included in the results. If there's a more
straightforward way that I'm missing, that would help a lot as well.)
Reply all
Reply to author
Forward
0 new messages