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] Class equality discussion on code generation feature

Paradies, Simon simon.paradies.ext at siemens.com
Mon Apr 6 02:42:51 PDT 2009


Hi,

I really like the code generation feature for wrapping Protégé instances into Java objects.
However, I wonder why two Java Objects obtained by the factory and associated with the same individual are not the same in the sense of the java '==' operator. Example (PersonFactory and Person are generated by Protégé; its OWL but would apply to Frames as well):
JenaOWLModel owlModel = ProtegeOWL.createJenaOWLModelFromURI("file:///C:/temp/person.owl");
		PersonFactory pf = new PersonFactory(owlModel);
		Person jd = pf.createPerson("JonDoe");
		Person jd1 = pf.getPerson("JonDoe");
		Person jd2 = pf.getPerson("JonDoe");
		RDFIndividual jdI1 = owlModel.getRDFIndividual("JonDoe");
		RDFIndividual jdI2 = owlModel.getRDFIndividual("JonDoe");
		System.out.println(jd1 == jd2);
		System.out.println(jd1.toString().equals(jd2.toString()));
		System.out.println(jdI1 == jdI2);
		System.out.println(jdI1.toString().equals(jdI2.toString()));

I get the following output:

false
true
true
true

The generated pf.getPerson() every time creates a new wrapping object.
I presume that to let the first comparison to be true would require a bit of effort (holding pointers to the already generated objects).
Why this works for RDFIndividuals but not for generated classes? Any thoughts or design decisions?

Thanks
Simon




More information about the protege-discussion mailing list