Ignore:
Timestamp:
11/01/05 17:35:40 (19 years ago)
Author:
remar
Message:
  • getType gets the type by querying the OMC server
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt/src/org/modelica/mdt/internal/core/ModelicaClass.java

    r92 r111  
    22
    33import org.modelica.mdt.core.IModelicaClass;
     4import org.modelica.mdt.internal.corba.InitializationException;
     5import org.modelica.mdt.internal.corba.OMCProxy;
    46
    57/**
     
    1012public class ModelicaClass extends ModelicaElement implements IModelicaClass
    1113{
    12     private String hostPackage;
     14    private String parentPackage;
    1315    private String className;
    1416    private Type type;
     17   
     18    private boolean typeKnown = false;
    1519   
    1620    protected ModelicaClass(String name, String pkg)
    1721    {
    1822        className = name;
    19         hostPackage = pkg;
     23        parentPackage = pkg;
    2024        type = Type.CLASS;
    2125    }
     
    2832    public String getPackage()
    2933    {
    30         return hostPackage;
     34        return parentPackage;
    3135    }
    3236   
    33     public Type getType()
     37    public Type getType() throws InitializationException
    3438    {
     39        System.out.println("Trying to fetch type");
     40        if(typeKnown == false)
     41        {
     42            String fullName = null;
     43            if(parentPackage == null)
     44                fullName = className;
     45            else
     46                fullName = parentPackage + "." + className;
     47           
     48            if(OMCProxy.sendExpression("isType(" + fullName + ")").contains("true"))
     49                type = Type.TYPE;
     50            else if(OMCProxy.sendExpression("isConnector(" + fullName + ")").contains("true"))
     51                type = Type.CONNECTOR;
     52            else if(OMCProxy.sendExpression("isModel(" + fullName + ")").contains("true"))
     53                type = Type.MODEL;
     54            else if(OMCProxy.sendExpression("isRecord(" + fullName + ")").contains("true"))
     55                type = Type.RECORD;
     56            else if(OMCProxy.sendExpression("isBlock(" + fullName + ")").contains("true"))
     57                type = Type.BLOCK;
     58            else if(OMCProxy.sendExpression("isFunction(" + fullName + ")").contains("true"))
     59                type = Type.FUNCTION;
     60           
     61            typeKnown = true;
     62        }
     63       
     64        System.out.println("Type is" + type);
    3565        return type;
    3666    }
Note: See TracChangeset for help on using the changeset viewer.