Search Mailing List Archives

Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-discussion] Instances of a slot

Jonathan Carter jonathan.carter at
Fri Oct 2 10:08:08 PDT 2009

Hi Marian,

Yes, you need to start with the Instance class. In this case, you get  
an Instance object for the "Ball" instance, e.g. (assuming we have a  
reference to the KnowledgeBase of the Project, 'knowledgebase')

aProductList = knowledgebase.getCls("Product").getDirectInstances()

// Iterate through aProductList to find "Ball" use getName() to find  
the name of the instance and use this object, named 'aBall'

Instance aBall = // THE INSTANCE, aProduct, IN aProductList WHERE  
aProduct.getName() = "Ball"

Slot aMadeOfSlot = knowledgebase.getSlot("madeOf")
Instance madeOf = aBall.getDirectOwnSlotValue(aMadeOfSlot)

As "madeOf" is an Instance slot, you will be returned an Instance  
object that you can then interrogate:

String materialOfBall = madeOf.getName()

Sorry for the mix of psuedo code and narrative but hopefully this  
makes sense
Let me know if you'd like more help



Jonathan Carter - Head of Technical Architecture
Enterprise Architecture Solutions Ltd

Proud sponsors of The Essential Project.
The free open-source Enterprise Architecture Management Platform

On 2 Oct 2009, at 17:50, Mariana Reyes Perez wrote:

> Hi all,
> I installed Protege 3.4.
> I am making a Plug-in. Is there a method or function to get the
> instances of a slot?
> I have 2 classes ("Product" and "Material") which are joined by the  
> slot
> (Type:Instance) "madeOf"
> Product has the instance "Ball" and Material has the instance  
> "Plastic"
> How do I traverse the slot from the instance "Ball" to get the value
> "plastic"?
> Thanks in advance
> Marian
> _______________________________________________
> protege-discussion mailing list
> protege-discussion at
> Instructions for unsubscribing:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the protege-discussion mailing list