Book a Demo

Author Topic: How to retrieve a method from a collection(JavaAPI  (Read 2993 times)

PatrickGerardi

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
How to retrieve a method from a collection(JavaAPI
« on: April 24, 2012, 10:29:15 pm »
Hi there

I have a collection of Diagram objects in the Java API and want to use the method GetElementID() to get the Element connected to each DiagramObject.

I cant seem to get to the method in the iterator.

This is my code, what can I do.

  // Get Diagram Object
              
               Collection<DiagramObject> DiagramObjectsD = null;
               DiagramObjectsD = getDiagram.GetDiagramObjects();
              
               Iterator<DiagramObject> itr =                               DiagramObjectsD.iterator();
                   Object DObject = null;
                  
                  
                  while (itr.hasNext());{
                  // How do i get to the DiagramObject.GetElement(ID)                  
                
                   DObject = itr.next();
                         DObject.toString();
                  
          
        System.out.println(DObject);

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to retrieve a method from a collection(Jav
« Reply #1 on: April 26, 2012, 03:14:43 pm »
You have to explicitly cast an object to EA.Operation (or whatever) before useing it.
EA.Collection is not a strong typed collection, so it always returns Object.

Geert

PatrickGerardi

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How to retrieve a method from a collection(Jav
« Reply #2 on: April 26, 2012, 03:17:11 pm »
Thanks Geert, Let me try that