Book a Demo

Author Topic: How to get access to Class Template Parameters through the ea Java interface ?  (Read 25401 times)

lmeylan

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Hello,

I'm currently using the Java ea interface, things are working well, but I'm struggling for getting the list of template parameters attached to a given class. The method "GetTemplateParameters()"attached to the Element Class is said retrieving a Collection, but the type of object contained in this Collection is not given. This method is not documented (or at least I haven't found it in the Sparx documentation). When I try to iterate on this Collection to get individual elements, I systematically obtain "null" element.
Thanks for helping fixing this point.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
The property TemplateParameters is documented here (the Java API create Get/Set operations for all properties)

https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/automation/element2.html

It also contains a link to the TemplateParameter class: https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/automation/templateparameter_class.html

Geert

lmeylan

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Thanks for the answer, however this doesn't answer my point fully.
Where I struglle, is that I get the size of the TemplateParameters (sparx) Collection.
I can then iterate, and get elements of the collection with GetAt() method.

However when I try to cast the resulting Object with "org.sparx.TemplateParameter", Java scratches and just provides a null Object.
This doesn't happen for other Collections where the same approach is working..

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Thanks for the answer, however this doesn't answer my point fully.
Where I struglle, is that I get the size of the TemplateParameters (sparx) Collection.
I can then iterate, and get elements of the collection with GetAt() method.

However when I try to cast the resulting Object with "org.sparx.TemplateParameter", Java scratches and just provides a null Object.
This doesn't happen for other Collections where the same approach is working..
I've never used the template parameters, much less using the Java interface.
What type are the object in the collection, if not TemplateParameters?
Have you tried contacting sparx support?

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
I also never used that but for curiosity gave it a shot with Python. No issues. So maybe a Java issue? You should contact Sparx support.

q.