# possible error in ontology-parsing? **Category:** [Reference Implementation: Java (archive)](https://discourse.openehr.org/c/reference-implementation-java-archive/154) **Created:** 2007-05-24 09:13 UTC **Views:** 1 **Replies:** 4 **URL:** https://discourse.openehr.org/t/possible-error-in-ontology-parsing/15575 --- ## Post #1 by @system I have following ontology snippet: ontology     primary\_language = <"en">     term\_definitions = <         \["en"\] = <             items = <                 \["at0"\]=<                         description=<"person name, birthdate, address, communications">                         text=<"person name, birthdate, address, communications">                 > When I do     archetype\.getOntology\(\)\.getLanguages\(\) or     archetype\.getOntology\(\)\.getPrimaryLanguage\(\) I get Nullpointer\-exceptions, when I do     archetype\.getOntology\(\)\.toString, I get --- ## Post #2 by @sebastian.garde Bert, I copy you in to a discussion Rong, Thomas and I had about this recently \- see below\. Regards Sebastian Rong Chen wrote: > Hi, > According to the latest AOM specification, the method > ArchetypeOntology\.getLanguages\(\) is not there anymore\. We need to > deprecate it in the next release\.On the other hand, there is a method > called terminologies\_available\(\), maybe we should also have > languages\_available\(\) in the specs and implementation code? Rong, you can leave it in the code if you want; the AOM doesn't stop you having extra methods\. Terminologies\_available\(\) will probably go the same way\. In the current AOM, the proper place to get languages\_available is from ARCHETYPE \(due to inheritance fom AUTHORED\_RESOURCE\) \- thomas --- ## Post #3 by @system Thanks, Sebastian, I appreciate this\. Please let me ask one question, because I work with results, I have to as a programmer\. I understand that languages are out of order, now\. Does this mean, we cannot give meaning \(=name\-attribute\) to a Locatable now, because we cannot use the ArchetypeOntology interface to find that out? Or is there an other way planned or already implemented to do this? Thanks Bert Sebastian Garde schreef: --- ## Post #4 by @sebastian.garde Bert, I am not sure I understand what you need, but you should be able to easily get the available languages: HashSet<String> availableLanguages = new HashSet<String>\(\); List termDefinitionlist = ontology\.getTermDefinitionsList\(\); for \(int k = 0; k < termDefinitionlist\.size\(\); k\+\+\) \{   OntologyDefinitions ontodefis = \(OntologyDefinitions\) termDefinitionlist\.get\(k\);   String termDefinitionLanguage = ontodefis\.getLanguage\(\);   availableLanguages\.add\(termDefinitionLanguage\); \}      This should give you all the available languages\. Rong may even consider to put this as a new indirect implementation for getLanguages\(\) in the java ref imp \- as Thomas said there can be additional methods and this one is certainly very handy to have To be totally sure that you don't 'miss' a language somewhere else in the archetype \(depending on what your needs are\) you could also look in the description part and the constraint part in addition: List li = anArchetype\.getDescription\(\)\.getDetails\(\); if \(li \!= null\) \{   for \(int i = 0; i < li\.size\(\); i\+\+\) \{     ResourceDescriptionItem languageGroup = \(ResourceDescriptionItem\) li\.get\(i\);     if \(languageGroup\.getLanguage\(\) \!= null\)       language = languageGroup\.getLanguage\(\)\.getCodeString\(\);       availableLanguages\.add\(language\);   \} \}          List constraintDefinitionList = ontology\.getConstraintDefinitionsList\(\); for \(int k = 0; k < constraintDefinitionList\.size\(\); k\+\+\) \{   OntologyDefinitions constraintdefis = \(OntologyDefinitions\) constraintDefinitionList\.get\(k\);   String constraintLanguage = constraintdefis\.getLanguage\(\);   availableLanguages\.add\(constraintLanguage\); \} Hope that helps Sebastian --- ## Post #5 by @system > Hope that helps > Sebastian >   Helps a lot, thanks Sebastian, I think I was too much seeinig it as a problem which needed to be solverd somewhere else, instead of looking for a solution mysel\. Thanks again kind regards Bert --- **Canonical:** https://discourse.openehr.org/t/possible-error-in-ontology-parsing/15575 **Original content:** https://discourse.openehr.org/t/possible-error-in-ontology-parsing/15575