org.eclipse.emf.importer.rose_2.6.0.v20120130-0943

16:43:39.939 INFO  jd.cli.Main - Decompiling org.eclipse.emf.importer.rose_2.6.0.v20120130-0943.jar
package org.eclipse.emf.importer.rose;

import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticException;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.converter.util.ConverterUtil;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.importer.ModelImporter;
import org.eclipse.emf.importer.ModelImporter.EPackageImportInfo;
import org.eclipse.emf.importer.rose.builder.RoseUtil;
import org.eclipse.emf.importer.rose.builder.UnitTreeNode;

public class RoseImporter
  extends ModelImporter
{
  protected Map<String, String> pathMap;
  protected boolean noQualify = false;
  protected boolean unsettablePrimitive = false;
  protected RoseUtil roseUtil;
  protected UnitTreeNode unitTreeNode;
  protected Map<EPackage, List<String>> roseEPackageInformationMap;
  
  public void dispose()
  {
    if (pathMap != null)
    {
      pathMap.clear();
      pathMap = null;
    }
    if (roseEPackageInformationMap != null)
    {
      roseEPackageInformationMap.clear();
      roseEPackageInformationMap = null;
    }
    super.dispose();
  }
  
  public String getID()
  {
    return "org.eclipse.emf.importer.rose";
  }
  
  public Map<String, String> getPathMap()
  {
    if (pathMap == null) {
      pathMap = new HashMap();
    }
    return pathMap;
  }
  
  public void setModelLocation(String location)
  {
    boolean isEqual = location == null ? 
      false : getModelLocation() == null ? true : 
      location.equals(getModelLocation());
    if (!isEqual) {
      getPathMap().clear();
    }
    super.setModelLocation(location);
  }
  
  public boolean isNoQualify()
  {
    return noQualify;
  }
  
  public void setNoQualify(boolean noQualify)
  {
    this.noQualify = noQualify;
  }
  
  public boolean isUnsettablePrimitive()
  {
    return unsettablePrimitive;
  }
  
  public void setUnsettablePrimitive(boolean unsettablePrimitive)
  {
    this.unsettablePrimitive = unsettablePrimitive;
  }
  
  public File computeRoseModelFile()
  {
    URI modelURI = getFirstModelLocationURI(true);
    if (modelURI != null)
    {
      File modelFile = new File(modelURI.isFile() ? modelURI.toFileString() : modelURI.toString());
      if (modelFile.isFile()) {
        return modelFile;
      }
    }
    return null;
  }
  
  public void clearEPackagesCollections()
  {
    super.clearEPackagesCollections();
    roseEPackageInformationMap = null;
  }
  
  public Diagnostic loadPathMap(Monitor monitor)
    throws Exception
  {
    clearEPackagesCollections();
    
    Diagnostic diagnostic = null;
    
    File roseModelFile = computeRoseModelFile();
    if (roseModelFile == null)
    {
      diagnostic = new BasicDiagnostic(4, 
        "org.eclipse.emf.converter", 264, 
        RoseImporterPlugin.INSTANCE.getString("_UI_SpecifyAValidRoseModel_message"), null);
    }
    else
    {
      String roseModelAbsolutePath = roseModelFile.getAbsolutePath();
      
      monitor.beginTask("", 2);
      monitor.subTask(RoseImporterPlugin.INSTANCE.getString("_UI_Loading_message", new Object[] { roseModelAbsolutePath }));
      
      Map<String, String> pathMap = getPathMap();
      boolean hasSymbolWithoutValue;
      do
      {
        roseUtil = createRoseUtil();
        roseUtil.getRoseEcoreBuilder().noQualify = noQualify;
        roseUtil.getRoseEcoreBuilder().unsettablePrimitive = unsettablePrimitive;
        
        roseUtil.getVariableToDirectoryMap().putAll(pathMap);
        unitTreeNode = roseUtil.createRoseUnitTreeAndTable(roseModelAbsolutePath, null);
        if (unitTreeNode == null)
        {
          diagnostic = new BasicDiagnostic(4, 
            "org.eclipse.emf.converter", 264, 
            RoseImporterPlugin.INSTANCE.getString("_UI_SpecifyAValidRoseModel_message"), null); break;
        }
        hasSymbolWithoutValue = adjustPathMap(roseUtil);
      } while (adjustKnownPathMapSymbols(roseModelAbsolutePath));
      if (!hasSymbolWithoutValue) {
        diagnostic = ConverterUtil.mergeDiagnostic(diagnostic, roseUtil.getDiagnostic());
      }
      if (getGenModelFileName() == null)
      {
        String fileName = unitTreeNode.getNodes().size() != 1 ? 
          roseModelFile.getName() : ((UnitTreeNode)unitTreeNode.getNodes().get(0)).getRoseFileName();
        
        int index = fileName.lastIndexOf(File.separatorChar);
        if (index >= 0) {
          fileName = fileName.substring(index + 1);
        }
        index = fileName.lastIndexOf(".");
        if (index >= 0) {
          fileName = fileName.substring(0, index);
        }
        setGenModelFileName(fileName + ".genmodel");
      }
    }
    return diagnostic != null ? diagnostic : Diagnostic.OK_INSTANCE;
  }
  
  protected boolean adjustPathMap(RoseUtil roseUtil)
  {
    boolean hasSymbolWithoutValue = false;
    Map<String, String> currentPathMap = getPathMap();
    Map<String, String> pathMap = new HashMap();
    for (Map.Entry<String, String> entry : roseUtil.getVariableToDirectoryMap().entrySet())
    {
      String symbol = (String)entry.getKey();
      if (symbol != null)
      {
        String value = (String)entry.getValue();
        if (value == null) {
          value = (String)currentPathMap.get(symbol);
        }
        pathMap.put(symbol, value);
        hasSymbolWithoutValue = (hasSymbolWithoutValue) || (value == null);
      }
    }
    currentPathMap.clear();
    currentPathMap.putAll(pathMap);
    return hasSymbolWithoutValue;
  }
  
  protected boolean adjustKnownPathMapSymbols(String roseModelAbsolutePath)
  {
    return false;
  }
  
  public boolean hasRoseGenPackageProperties(EPackage ePackage)
  {
    return (roseEPackageInformationMap != null) && (roseEPackageInformationMap.get(ePackage) != null);
  }
  
  protected Diagnostic doComputeEPackages(Monitor monitor)
    throws Exception
  {
    monitor.beginTask("", 2);
    Diagnostic diagnostic = loadPathMap(monitor);
    if (diagnostic.getSeverity() == 0) {
      if ((getPathMap().values().contains(null)) && (roseUtil.getDiagnostic().getSeverity() != 0))
      {
        diagnostic = new BasicDiagnostic(4, 
          "org.eclipse.emf.converter", 264, 
          RoseImporterPlugin.INSTANCE.getString("_UI_SpecifyTheSymbolLocations_message"), null);
      }
      else
      {
        roseUtil.createExtent4RoseUnitTree(unitTreeNode);
        roseUtil.processUnitTree(unitTreeNode);
        roseEPackageInformationMap = roseUtil.getEPackageToInformationMap();
        diagnostic = ConverterUtil.createDiagnostic(roseUtil.getDiagnostic(), "org.eclipse.emf.converter", 1);
        for (Map.Entry<EPackage, List<String>> entry : roseUtil.getEPackageToInformationMap().entrySet())
        {
          List<String> information = (List)entry.getValue();
          if (information != null)
          {
            ModelImporter.EPackageImportInfo ePackageInfo = getEPackageImportInfo((EPackage)entry.getKey());
            ePackageInfo.setBasePackage((String)information.get(0));
            ePackageInfo.setPrefix((String)information.get(1));
          }
        }
        traverseEPackages(unitTreeNode);
      }
    }
    monitor.done();
    return diagnostic;
  }
  
  protected void traverseEPackages(UnitTreeNode subNode)
  {
    List<EPackage> ePackagesList = subNode.getExtent();
    
    getEPackages().addAll(ePackagesList);
    for (EPackage ePackage : ePackagesList)
    {
      ModelImporter.EPackageImportInfo ePackageInfo = getEPackageImportInfo(ePackage);
      
      String ecoreFileName = null;
      String roseFileName = subNode.getRoseFileName();
      int indexOfSlash = roseFileName.lastIndexOf(File.separator);
      
      GenPackage genPackage = getGenPackage(ePackage);
      if (genPackage != null)
      {
        String ePackagePath = genPackage.getEcorePackage().eResource().getURI().lastSegment();
        ecoreFileName = URI.decode(ePackagePath);
      }
      else if ((roseFileName.endsWith(".cat")) && (indexOfSlash != -1))
      {
        String baseName = roseFileName.substring(indexOfSlash + 1, roseFileName.length() - 4);
        int indexOfDot = baseName.lastIndexOf(".");
        if (indexOfDot != -1) {
          baseName = baseName.substring(indexOfDot + 1);
        }
        ecoreFileName = baseName + ".ecore";
      }
      else if (subNode.getExtent().size() == 1)
      {
        ecoreFileName = subNode.getName() + ".ecore";
      }
      else
      {
        ecoreFileName = ePackage.getName() + ".ecore";
      }
      ePackageInfo.setEcoreFileName(ecoreFileName);
    }
    for (UnitTreeNode childTree : subNode.getNodes()) {
      traverseEPackages(childTree);
    }
  }
  
  protected void adjustGenModel(Monitor monitor)
  {
    super.adjustGenModel(monitor);
    
    GenModel genModel = getGenModel();
    String projectName = getModelProjectName();
    IPath genModelPath = getGenModelPath();
    URI modelURI = (URI)getModelLocationURIs().get(0);
    URI genModelURI = getGenModel().eResource().getURI();
    
    genModel.getForeignModel().add(makeRelative(modelURI, genModelURI).toFileString());
    IPath projectLocation = getWorkspaceRoot().getProject(projectName).getLocation();
    if (projectLocation != null) {
      projectLocation = projectLocation.removeLastSegments(1);
    } else {
      projectLocation = getGenModelProjectLocation();
    }
    for (Map.Entry<String, String> entry : getPathMap().entrySet())
    {
      String value = (String)entry.getValue();
      if (value != null)
      {
        genModel.getForeignModel().add((String)entry.getKey());
        if (new Path(value).equals(projectLocation))
        {
          value = "..";
          for (int depth = genModelPath.segmentCount(); depth > 2; depth--) {
            value = value + "/..";
          }
          genModel.getForeignModel().add(value);
        }
        else
        {
          genModel.getForeignModel().add(value);
        }
      }
    }
  }
  
  protected void handleOriginalGenModel()
    throws DiagnosticException
  {
    try
    {
      Iterator<String> values = getOriginalGenModel().getForeignModel().iterator();
      if (values.hasNext())
      {
        URI modelURI = null;
        String modelFile = (String)values.next();
        modelFile = modelFile.replace('\\', '/');
        if (modelFile.endsWith(".mdl"))
        {
          URI genModelFileURI = createFileURI(getOriginalGenModelPath().toString());
          modelURI = makeAbsolute(URI.createFileURI(modelFile), genModelFileURI);
          setModelLocation(modelURI.toString());
          while (values.hasNext())
          {
            String variable = (String)values.next();
            String value = (String)values.next();
            getPathMap().put(variable, value);
          }
        }
      }
    }
    catch (Exception exception)
    {
      RoseImporterPlugin.INSTANCE.log(exception);
    }
  }
  
  protected RoseUtil createRoseUtil()
  {
    RoseUtil roseUtil = new RoseUtil(createResourceSet().getURIConverter());
    getRoseEcoreBuildernoQualify = noQualify;
    getRoseEcoreBuilderunsettablePrimitive = unsettablePrimitive;
    return roseUtil;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.rose.RoseImporter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.rose;

public class RoseImporterApplication$PackageInfo
{
  public String name;
  public String nsPrefix;
  public String nsURI;
  public String base;
  public String prefix;
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.rose.RoseImporterApplication.PackageInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.rose;

import java.io.PrintStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.importer.ModelImporter;
import org.eclipse.emf.importer.ModelImporter.EPackageImportInfo;
import org.eclipse.emf.importer.ModelImporterApplication;

public class RoseImporterApplication
  extends ModelImporterApplication
{
  protected boolean noQualify;
  protected boolean unsettablePrimitive;
  protected Map<String, String> pathMap;
  protected Map<String, PackageInfo> nameToPackageInfo;
  protected Map<String, PackageInfo> nameToReferencedPackageInfo;
  
  public RoseImporter getRoseImporter()
  {
    return (RoseImporter)getModelImporter();
  }
  
  protected ModelImporter createModelImporter()
  {
    return new RoseImporter();
  }
  
  protected StringBuffer getUsage()
  {
    StringBuffer result = new StringBuffer();
    appendLine(result, "Usage: <model.mdl> [ <model.genmodel> [ -reload ] ] <OPTION>");
    appendLine(result, "<OPTION>          ::= [ <PROJECT-OPTION> ]  [ <PATHMAP> ]");
    appendLine(result, "                      { <PACKAGE> }+  { <REF-PACKAGE> }* { <REF-GEN-MODEL> }*");
    appendLine(result, "                      [ <TEMPLATE-PATH> ] [ <MODEL-PLUGIN-ID> ] [ <COPYRIGHT> ]");
    appendLine(result, "                      [ <SDO> ] [ <QUIET> ]");
    appendLine(result, "<PROJECT-OPTION>  ::= <MODEL-PROJECT> [ <EDIT-PROJECT> ] [ <EDITOR-PROJECT> ]");
    appendLine(result, "                      [ <TESTS-PROJECT> ]");
    appendLine(result, "<MODEL-PROJECT>   ::= -modelProject <model-directory> <fragment-path>");
    appendLine(result, "<EDIT-PROJECT>    ::= -editProject <edit-directory> <fragment-path>");
    appendLine(result, "<EDITOR-PROJECT>  ::= -editorProject <editor-directory> <fragment-path>");
    appendLine(result, "<TESTS-PROJECT>   ::= -testsProject <tests-directory> <fragment-path>");
    appendLine(result, "<PATHMAP>         ::= -pathMap { <symbol> <directory> }+");
    appendLine(result, "<PACKAGE>         ::= -package <name> [ <nsPrefix> <nsURI> <base> <prefix> ]");
    appendLine(result, "<REF-PACKAGE>     ::= <deprecated - use -refGenModel instead> -refPackage <name> [ <nsPrefix> <nsURI> <base> <prefix> ]");
    appendLine(result, "<REF-GEN-MODEL>   ::= -refGenModel <model.genmodel> { <nsURI> }+");
    appendLine(result, "<TEMPLATE-PATH>   ::= -templatePath <template-directory>");
    appendLine(result, "<MODEL-PLUGIN-ID> ::= -modelPluginID <plugin-ID>");
    appendLine(result, "<COPYRIGHT>       ::= -copyright <copyright-string>");
    appendLine(result, "<JDK-LEVEL>       ::= -jdkLevel <jdk level: 1.4 5.0 6.0>");
    appendLine(result, "<VALIDATE-MODEL>  ::= -validateModel <true|false>");
    appendLine(result, "<SDO>             ::= -sdo");
    appendLine(result, "<QUIET>           ::= -quiet");
    appendLine(result, "");
    appendLine(result, "For example:");
    appendLine(result, "");
    appendLine(result, "");
    appendLine(result, "  rose2genmodel");
    appendLine(result, "    ../../etools.company/src/rose/model.mdl");
    appendLine(result, "    result/model/Extended.genmodel");
    appendLine(result, "    -modelProject result src");
    appendLine(result, "    -editProject result.edit src");
    appendLine(result, "    -editorProject result.editor src");
    appendLine(result, "    -pathMap VABASE_PLUGINS_PATH C:/sandbox/unpackage2/eclipse/plugins");
    appendLine(result, "    -package extended Extended Extended.ecore org.example Extended");
    appendLine(result, "    -refPackage company Company Company.ecore org.sample Company");
    return result;
  }
  
  protected int processArgument(String[] arguments, int index)
  {
    if (arguments[index].equalsIgnoreCase("-pathmap"))
    {
      if (pathMap == null) {
        pathMap = new HashMap();
      }
      do
      {
        String variable = arguments[(++index)];
        String directory = arguments[(++index)];
        pathMap.put(variable, directory);
        if (index + 1 >= arguments.length) {
          break;
        }
      } while (!
      
        arguments[(index + 1)].startsWith("-"));
    }
    else if (arguments[index].equalsIgnoreCase("-package"))
    {
      if (nameToPackageInfo == null) {
        nameToPackageInfo = new HashMap();
      }
      index = processPackageInformation(arguments, index, nameToPackageInfo);
    }
    else if (arguments[index].equalsIgnoreCase("-refPackage"))
    {
      System.out.println("**** Instead of -refPackage you should be using -refGenModel");
      if (nameToReferencedPackageInfo == null) {
        nameToReferencedPackageInfo = new HashMap();
      }
      index = processPackageInformation(arguments, index, nameToReferencedPackageInfo);
    }
    else if (arguments[index].equalsIgnoreCase("-unsettablePrimitive"))
    {
      unsettablePrimitive = true;
    }
    else if (arguments[index].equalsIgnoreCase("-noQualify"))
    {
      noQualify = true;
    }
    else
    {
      return super.processArgument(arguments, index);
    }
    return index + 1;
  }
  
  protected int processPackageInformation(String[] arguments, int index, Map<String, PackageInfo> nameToPackageInfo)
  {
    int start = index;
    PackageInfo packageInfo = new PackageInfo();
    if ((index + 1 < arguments.length) && (!arguments[(index + 1)].startsWith("-")))
    {
      name = arguments[(++index)];
      if ((index + 1 < arguments.length) && (!arguments[(index + 1)].startsWith("-")))
      {
        nsPrefix = arguments[(++index)];
        if ((index + 1 < arguments.length) && (!arguments[(index + 1)].startsWith("-")))
        {
          nsURI = arguments[(++index)];
          if ((index + 1 < arguments.length) && (!arguments[(index + 1)].startsWith("-")))
          {
            base = arguments[(++index)];
            if ((index + 1 < arguments.length) && (!arguments[(index + 1)].startsWith("-"))) {
              prefix = arguments[(++index)];
            }
          }
        }
      }
      if ((index - start != 1) && (index - start != 5)) {
        throw new IllegalArgumentException("Error: Expecting either 1 or 5 arguments for " + arguments[start]);
      }
      nameToPackageInfo.put(name, packageInfo);
      nameToPackageInfo.put(name.toLowerCase(), packageInfo);
      return index;
    }
    throw new IllegalArgumentException("Error: No package name was specified for " + arguments[start]);
  }
  
  /* Error */
  protected void adjustModelImporter(org.eclipse.emf.common.util.Monitor monitor)
  {
    // Byte code:
    //   0: aload_1
    //   1: ldc 1
    //   3: iconst_2
    //   4: invokeinterface 344 3 0
    //   9: aload_0
    //   10: aload_1
    //   11: iconst_1
    //   12: invokestatic 312	org/eclipse/emf/codegen/util/CodeGenUtil:createMonitor	(Lorg/eclipse/emf/common/util/Monitor;I)Lorg/eclipse/emf/common/util/Monitor;
    //   15: invokespecial 320	org/eclipse/emf/importer/ModelImporterApplication:adjustModelImporter	(Lorg/eclipse/emf/common/util/Monitor;)V
    //   18: aload_0
    //   19: invokevirtual 333	org/eclipse/emf/importer/rose/RoseImporterApplication:getRoseImporter	()Lorg/eclipse/emf/importer/rose/RoseImporter;
    //   22: astore_2
    //   23: aload_0
    //   24: getfield 296	org/eclipse/emf/importer/rose/RoseImporterApplication:pathMap	Ljava/util/Map;
    //   27: ifnull +16 -> 43
    //   30: aload_2
    //   31: invokevirtual 325	org/eclipse/emf/importer/rose/RoseImporter:getPathMap	()Ljava/util/Map;
    //   34: aload_0
    //   35: getfield 296	org/eclipse/emf/importer/rose/RoseImporterApplication:pathMap	Ljava/util/Map;
    //   38: invokeinterface 340 2 0
    //   43: aload_2
    //   44: aload_0
    //   45: getfield 292	org/eclipse/emf/importer/rose/RoseImporterApplication:noQualify	Z
    //   48: invokevirtual 322	org/eclipse/emf/importer/rose/RoseImporter:setNoQualify	(Z)V
    //   51: aload_2
    //   52: aload_0
    //   53: getfield 293	org/eclipse/emf/importer/rose/RoseImporterApplication:unsettablePrimitive	Z
    //   56: invokevirtual 323	org/eclipse/emf/importer/rose/RoseImporter:setUnsettablePrimitive	(Z)V
    //   59: goto +12 -> 71
    //   62: astore_3
    //   63: aload_1
    //   64: invokeinterface 343 1 0
    //   69: aload_3
    //   70: athrow
    //   71: aload_1
    //   72: invokeinterface 343 1 0
    //   77: return
    // Line number table:
    //   Java source line #195	-> byte code offset #0
    //   Java source line #197	-> byte code offset #9
    //   Java source line #199	-> byte code offset #18
    //   Java source line #200	-> byte code offset #23
    //   Java source line #202	-> byte code offset #30
    //   Java source line #204	-> byte code offset #43
    //   Java source line #205	-> byte code offset #51
    //   Java source line #208	-> byte code offset #62
    //   Java source line #209	-> byte code offset #63
    //   Java source line #210	-> byte code offset #69
    //   Java source line #209	-> byte code offset #71
    //   Java source line #211	-> byte code offset #77
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	78	0	this	RoseImporterApplication
    //   0	78	1	monitor	org.eclipse.emf.common.util.Monitor
    //   22	30	2	roseImporter	RoseImporter
    //   62	8	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	62	62	finally
  }
  
  /* Error */
  protected void adjustEPackages(org.eclipse.emf.common.util.Monitor monitor)
  {
    // Byte code:
    //   0: aload_1
    //   1: ldc 1
    //   3: iconst_2
    //   4: invokeinterface 344 3 0
    //   9: aload_0
    //   10: aload_1
    //   11: iconst_1
    //   12: invokestatic 312	org/eclipse/emf/codegen/util/CodeGenUtil:createMonitor	(Lorg/eclipse/emf/common/util/Monitor;I)Lorg/eclipse/emf/common/util/Monitor;
    //   15: invokespecial 319	org/eclipse/emf/importer/ModelImporterApplication:adjustEPackages	(Lorg/eclipse/emf/common/util/Monitor;)V
    //   18: aload_0
    //   19: invokevirtual 333	org/eclipse/emf/importer/rose/RoseImporterApplication:getRoseImporter	()Lorg/eclipse/emf/importer/rose/RoseImporter;
    //   22: invokevirtual 324	org/eclipse/emf/importer/rose/RoseImporter:getEPackages	()Ljava/util/List;
    //   25: astore_2
    //   26: aload_0
    //   27: aload_2
    //   28: invokevirtual 329	org/eclipse/emf/importer/rose/RoseImporterApplication:traverseEPackages	(Ljava/util/List;)V
    //   31: aload_0
    //   32: invokevirtual 333	org/eclipse/emf/importer/rose/RoseImporterApplication:getRoseImporter	()Lorg/eclipse/emf/importer/rose/RoseImporter;
    //   35: aload_1
    //   36: iconst_1
    //   37: invokestatic 312	org/eclipse/emf/codegen/util/CodeGenUtil:createMonitor	(Lorg/eclipse/emf/common/util/Monitor;I)Lorg/eclipse/emf/common/util/Monitor;
    //   40: invokevirtual 326	org/eclipse/emf/importer/rose/RoseImporter:adjustEPackages	(Lorg/eclipse/emf/common/util/Monitor;)V
    //   43: goto +12 -> 55
    //   46: astore_3
    //   47: aload_1
    //   48: invokeinterface 343 1 0
    //   53: aload_3
    //   54: athrow
    //   55: aload_1
    //   56: invokeinterface 343 1 0
    //   61: return
    // Line number table:
    //   Java source line #218	-> byte code offset #0
    //   Java source line #219	-> byte code offset #9
    //   Java source line #221	-> byte code offset #18
    //   Java source line #222	-> byte code offset #26
    //   Java source line #223	-> byte code offset #31
    //   Java source line #226	-> byte code offset #46
    //   Java source line #227	-> byte code offset #47
    //   Java source line #228	-> byte code offset #53
    //   Java source line #227	-> byte code offset #55
    //   Java source line #229	-> byte code offset #61
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	62	0	this	RoseImporterApplication
    //   0	62	1	monitor	org.eclipse.emf.common.util.Monitor
    //   25	3	2	ePackages	List<EPackage>
    //   46	8	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	46	46	finally
  }
  
  protected void traverseEPackages(List<EPackage> ePackages)
  {
    for (EPackage ePackage : ePackages)
    {
      String packageName = ePackage.getName();
      boolean isReferencedEPackage = false;
      PackageInfo packageInfo = nameToPackageInfo == null ? null : 
        (PackageInfo)nameToPackageInfo.get(packageName);
      if ((packageInfo == null) && (nameToReferencedPackageInfo != null))
      {
        packageInfo = (PackageInfo)nameToReferencedPackageInfo.get(packageName);
        isReferencedEPackage = packageInfo != null;
      }
      if ((packageInfo != null) || (nameToPackageInfo == null)) {
        handleEPackage(ePackage, !isReferencedEPackage);
      }
      if (packageInfo != null)
      {
        if (!getRoseImporter().hasRoseGenPackageProperties(ePackage))
        {
          ePackage.setNsPrefix(nsPrefix);
          ePackage.setNsURI(nsURI);
        }
        ModelImporter.EPackageImportInfo ePackageInfo = getRoseImporter().getEPackageImportInfo(ePackage);
        if (ePackageInfo.getBasePackage() == null) {
          ePackageInfo.setBasePackage(base);
        }
        if (ePackageInfo.getPrefix() == null) {
          ePackageInfo.setPrefix(prefix);
        }
      }
      handleQualifiedEPackageName(ePackage);
      traverseEPackages(ePackage.getESubpackages());
    }
  }
  
  public static class PackageInfo
  {
    public String name;
    public String nsPrefix;
    public String nsURI;
    public String base;
    public String prefix;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.rose.RoseImporterApplication
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.rose;

import org.eclipse.emf.common.EMFPlugin.EclipsePlugin;

public class RoseImporterPlugin$Implementation
  extends EMFPlugin.EclipsePlugin
{
  public RoseImporterPlugin$Implementation()
  {
    RoseImporterPlugin.access$0(this);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.rose.RoseImporterPlugin.Implementation
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.rose;

import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.EMFPlugin.EclipsePlugin;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.importer.ImporterPlugin;

public final class RoseImporterPlugin
  extends EMFPlugin
{
  public static final RoseImporterPlugin INSTANCE = new RoseImporterPlugin();
  private static Implementation plugin;
  
  private RoseImporterPlugin()
  {
    super(new ResourceLocator[] { ImporterPlugin.INSTANCE });
  }
  
  public ResourceLocator getPluginResourceLocator()
  {
    return plugin;
  }
  
  public static Implementation getPlugin()
  {
    return plugin;
  }
  
  public static class Implementation
    extends EMFPlugin.EclipsePlugin
  {
    public Implementation()
    {
      RoseImporterPlugin.plugin = this;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.rose.RoseImporterPlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.rose.builder;

import java.util.Comparator;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EGenericType;

class RoseEcoreBuilder$1
  implements Comparator<Object>
{
  public int compare(Object o1, Object o2)
  {
    EClass c1 = (EClass)((o1 instanceof EGenericType) ? ((EGenericType)o1).getEClassifier() : o1);
    EClass c2 = (EClass)((o2 instanceof EGenericType) ? ((EGenericType)o2).getEClassifier() : o2);
    int count1 = c1.getEAllAttributes().size() + c1.getEAllReferences().size();
    int count2 = c2.getEAllAttributes().size() + c2.getEAllReferences().size();
    if (count1 < count2) {
      return 1;
    }
    if (count1 > count2) {
      return -1;
    }
    return c1.getName().compareTo(c2.getName());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.rose.builder.RoseEcoreBuilder.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.rose.builder;

import java.util.Comparator;
import java.util.List;
import org.eclipse.emf.ecore.EStructuralFeature;

class RoseEcoreBuilder$2
  implements Comparator<EStructuralFeature>
{
  RoseEcoreBuilder$2(RoseEcoreBuilder paramRoseEcoreBuilder) {}
  
  public int compare(EStructuralFeature o1, EStructuralFeature o2)
  {
    return this$0.eStructuralFeatures.indexOf(o1) - this$0.eStructuralFeatures.indexOf(o2);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.rose.builder.RoseEcoreBuilder.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.rose.builder;

import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EParameter;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreSwitch;

class RoseEcoreBuilder$3
  extends EcoreSwitch<Object>
{
  RoseEcoreBuilder$3(RoseEcoreBuilder paramRoseEcoreBuilder) {}
  
  public Object caseEPackage(EPackage ePackage)
  {
    return null;
  }
  
  public Object caseEClassifier(EClassifier eClassifier)
  {
    return null;
  }
  
  public Object caseEOperation(EOperation eOperation)
  {
    return null;
  }
  
  public Object caseEParameter(EParameter eParameter)
  {
    return null;
  }
  
  public Object caseEStructuralFeature(EStructuralFeature eStructuralFeature)
  {
    return null;
  }
  
  public Object caseEEnumLiteral(EEnumLiteral eEnumLiteral)
  {
    return null;
  }
  
  public Object defaultCase(EObject eObject)
  {
    for (EObject child : eObject.eContents()) {
      this$0.setIDs(eObject, child);
    }
    return this;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.rose.builder.RoseEcoreBuilder.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.rose.builder;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreSwitch;

class RoseEcoreBuilder$4
  extends EcoreSwitch<Object>
{
  RoseEcoreBuilder$4(RoseEcoreBuilder paramRoseEcoreBuilder) {}
  
  public Object caseEDataType(EDataType eDataType)
  {
    return this$0.validateEDataType(eDataType);
  }
  
  public Object caseEEnum(EEnum eEnum)
  {
    return this$0.validateEEnum(eEnum);
  }
  
  public Object caseEClass(EClass eClass)
  {
    return this$0.validateEClass(eClass);
  }
  
  public Object defaultCase(EObject eObject)
  {
    for (EObject child : eObject.eContents()) {
      this$0.validate(child);
    }
    return this;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.rose.builder.RoseEcoreBuilder.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.rose.builder;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.emf.codegen.util.CodeGenUtil;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.BasicEList.FastCompare;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.emf.common.util.UniqueEList;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EGenericType;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EParameter;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.ETypeParameter;
import org.eclipse.emf.ecore.ETypedElement;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.EcorePackage.Literals;
import org.eclipse.emf.ecore.util.EcoreSwitch;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.importer.rose.RoseImporterPlugin;
import org.eclipse.emf.importer.rose.RoseImporterPlugin.Implementation;
import org.eclipse.emf.importer.rose.parser.RoseNode;
import org.eclipse.emf.importer.rose.parser.Util;
import org.osgi.framework.Bundle;

public class RoseEcoreBuilder
  implements RoseVisitor
{
  public boolean noQualify = false;
  public boolean unsettablePrimitive = "true".equals(System.getProperty("EMF_UNSETTABLE_PRIMITIVE"));
  protected RoseUtil roseUtil;
  protected Set<EModelElement> bounded = new HashSet();
  protected Map<EStructuralFeature, String> eStructuralFeatureToXMLNamespaceMap = new HashMap();
  protected List<EStructuralFeature> eStructuralFeatures = new BasicEList.FastCompare();
  protected Map<EEnum, String> eEnums = new HashMap();
  protected Map<String, Object> idToParentMap = new HashMap();
  protected EReference ref1 = null;
  protected EReference ref2 = null;
  protected RoseNode role1 = null;
  protected RoseNode role2 = null;
  protected EGenericType eGenericType1;
  protected EGenericType eGenericType2;
  protected Set<EAttribute> attributesToConvert = new HashSet();
  protected Map<EModelElement, RoseNode> eModelElementToRoseNodeMap = new HashMap();
  
  public RoseEcoreBuilder(RoseUtil roseUtil)
  {
    this.roseUtil = roseUtil;
  }
  
  public void visitList(RoseNode roseNode) {}
  
  public void visitObject(RoseNode roseNode)
  {
    String roseNodeValue = roseNode.getValue();
    String objectKey = roseNode.getKey();
    String objectType = Util.getType(roseNodeValue);
    String objectName = Util.getName(roseNodeValue);
    
    RoseNode currentNode = roseNode;
    Object parent = currentNode.getNode();
    while (parent == null)
    {
      currentNode = currentNode.getParent();
      parent = currentNode.getNode();
    }
    visitObject(roseNode, roseNodeValue, objectKey, objectType, objectName, parent);
  }
  
  protected void visitObject(RoseNode roseNode, String roseNodeValue, String objectKey, String objectType, String objectName, Object parent)
  {
    if ((objectKey.equals("")) && (objectType.equals("Class_Category"))) {
      visitClassCategory(roseNode, roseNodeValue, objectKey, objectName, parent);
    } else if (objectType.equals("Class")) {
      visitClass(roseNode, roseNodeValue, objectKey, objectName, parent);
    } else if (objectType.equals("Operation")) {
      visitOperation(roseNode, roseNodeValue, objectKey, objectName, parent);
    } else if (objectType.equals("Parameter")) {
      visitParameter(roseNode, roseNodeValue, objectKey, objectName, parent);
    } else if (objectType.equals("Inheritance_Relationship")) {
      visitInheritanceRelationship(roseNode, roseNodeValue, objectKey, objectName, parent);
    } else if ((objectType.equals("ClassAttribute")) && ((!roseNode.isDerived()) || (!"reference".equals(roseNode.getStereotype())))) {
      visitClassattribute(roseNode, roseNodeValue, objectKey, objectName, parent);
    } else if (objectType.equals("Association")) {
      visitAssociation(roseNode, roseNodeValue, objectKey, objectName, parent);
    } else if ((objectType.equals("Role")) && (!objectName.startsWith("/"))) {
      visitRole(roseNode, roseNodeValue, objectKey, objectName, parent);
    }
  }
  
  protected void visitClassCategory(RoseNode roseNode, String roseNodeValue, String objectKey, String objectName, Object parent)
  {
    if (roseNode.isLoaded())
    {
      String id = roseNode.getRoseId();
      if (idToParentMap.containsKey(id)) {
        parent = idToParentMap.get(id);
      }
      EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
      if ((parent instanceof EPackage))
      {
        ((EPackage)parent).getESubpackages().add(ePackage);
      }
      else if ((parent instanceof EList))
      {
        EList<Object> list = (EList)parent;
        list.add(ePackage);
      }
      setEPackageProperties(roseNode, ePackage, objectName.toLowerCase());
    }
    else
    {
      idToParentMap.put(roseNode.getRoseId(), parent);
    }
  }
  
  protected void visitClass(RoseNode roseNode, String roseNodeValue, String objectKey, String objectName, Object parent)
  {
    if ((objectName == null) || (objectName.length() == 0))
    {
      String quid = roseNode.getRoseId();
      if (quid != null) {
        quid = quid.substring(1, quid.length() - 1);
      }
      objectName = "Unnamed" + quid;
      error(RoseImporterPlugin.INSTANCE.getString("_UI_UnnamedClass_message", new Object[] { objectName }));
    }
    RoseNode stereoTypeNode = roseNode.findNodeWithKey("stereotype");
    if (stereoTypeNode != null)
    {
      String stereoTypeValue = stereoTypeNode.getValue();
      stereoTypeValue = stereoTypeValue.substring(1, stereoTypeValue.length() - 1);
      if (stereoTypeValue.equals("Interface"))
      {
        EClass eClass = EcoreFactory.eINSTANCE.createEClass();
        String classifierName = roseNode.getClassifierName();
        if ((classifierName == null) || (classifierName.length() == 0)) {
          classifierName = validName(upperCaseName(objectName));
        }
        eClass.setName(classifierName);
        roseNode.setNode(eClass);
        setEClassProperties(roseNode, eClass);
        eClass.setInterface(true);
        eClass.setAbstract(true);
        build(roseNode, parent, eClass);
      }
      else if (stereoTypeValue.equalsIgnoreCase("enumeration"))
      {
        EEnum eEnum = EcoreFactory.eINSTANCE.createEEnum();
        String classifierName = roseNode.getClassifierName();
        if ((classifierName == null) || (classifierName.length() == 0)) {
          classifierName = validName(upperCaseName(objectName));
        }
        eEnum.setName(classifierName);
        roseNode.setNode(eEnum);
        setEEnumProperties(roseNode, eEnum);
        build(roseNode, parent, eEnum);
      }
      else if ((stereoTypeValue.equalsIgnoreCase("datatype")) || (stereoTypeValue.equalsIgnoreCase("primitive")))
      {
        EDataType eDataType = EcoreFactory.eINSTANCE.createEDataType();
        String classifierName = roseNode.getClassifierName();
        if ((classifierName == null) || (classifierName.length() == 0)) {
          classifierName = validName(upperCaseName(objectName));
        }
        eDataType.setName(classifierName);
        roseNode.setNode(eDataType);
        setEDataTypeProperties(roseNode, eDataType);
        build(roseNode, parent, eDataType);
        
        String uml2MOFCorbaType = roseNode.getUML2MOFCorbaType();
        if (uml2MOFCorbaType != null)
        {
          uml2MOFCorbaType = uml2MOFCorbaType.trim();
          int start = uml2MOFCorbaType.indexOf("typedef ");
          if (start != -1)
          {
            uml2MOFCorbaType = uml2MOFCorbaType.substring(8);
            
1 2 3 4 5 6

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd