public IScope getScope(EObject context, EReference reference) {
   if (context == null) throw new NullPointerException("context");
   if (context.eResource() == null)
     throw new IllegalArgumentException("context must be contained in a resource");
   IScope globalScope = getGlobalScope(context.eResource(), reference);
   return internalGetScope(globalScope, globalScope, context, reference);
 }
  public void selectionChanged(IAction action, ISelection selection) {
    selectedURI = null;
    selectedFile = null;
    action.setEnabled(false);
    if (selection instanceof IStructuredSelection == false || selection.isEmpty()) {
      return;
    }
    try {
      Object o = ((IStructuredSelection) selection).getFirstElement();
      if (o instanceof IFile) {
        selectedFile = (IFile) ((IStructuredSelection) selection).getFirstElement();
        selectedURI = URI.createPlatformResourceURI(selectedFile.getFullPath().toString(), true);

      } else if (o instanceof EditPart) {
        EObject e = (EObject) ((EditPart) o).getModel();
        if (e.eResource() == null) return;
        selectedURI = e.eResource().getURI();
        selectedFile = ResourceHelper.uriToFile(selectedURI);

      } else {
        return;
      }

      action.setEnabled(true);
    } catch (ClassCastException e) {
      // just catch, do nothing
    } catch (NullPointerException e) {
      // just catch, do nothing
    }
  }
 private String getXmiId(EObject obj) {
   if (obj.eResource() instanceof XMLResource) {
     return ((XMLResource) obj.eResource()).getID(obj);
   } else {
     return null;
   }
 }
  /*
   * @see org.teiid.query.metadata.QueryMetadataInterface#getExtensionProperties(java.lang.Object)
   */
  @Override
  public Properties getExtensionProperties(Object metadataID) {
    CoreArgCheck.isInstanceOf(MetadataRecord.class, metadataID);
    MetadataRecord metadataRecord = (MetadataRecord) metadataID;

    String uuid = metadataRecord.getUUID();
    EObject eObj = lookupEObject(uuid);

    Properties extProps = new Properties();

    // Create get annotation for the EObject and lookup properties
    if (eObj != null && eObj.eResource() != null && eObj.eResource() instanceof EmfResource) {
      EmfResource emfResource = (EmfResource) eObj.eResource();
      ModelContents contents = new ModelContents(emfResource);
      Annotation annotation = contents.getAnnotation(eObj);
      if (annotation != null) {
        Iterator entryIter = annotation.getTags().entrySet().iterator();
        while (entryIter.hasNext()) {
          Map.Entry entry = (Map.Entry) entryIter.next();
          extProps.setProperty((String) entry.getKey(), (String) entry.getValue());
        }
      }
    }

    return extProps;
  }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.subPackageNonRegForFilters.parts.TestFilterPropertiesEditionPart#initTestRT(EObject
  *     current, EReference containingFeature, EReference feature)
  */
 public void initTestRT(EObject current, EReference containingFeature, EReference feature) {
   if (current.eResource() != null && current.eResource().getResourceSet() != null)
     this.resourceSet = current.eResource().getResourceSet();
   if (containingFeature != null)
     testRTEditUtil = new EMFListEditUtil(current, containingFeature, feature);
   else testRTEditUtil = new EMFListEditUtil(current, feature);
   this.testRT.setInput(testRTEditUtil.getVirtualList());
 }
  protected static EObject[] findRoots(EObject source) {
    if (source.eResource() == null || source.eResource().getResourceSet() == null) {
      return SemanticEMFContentProvider.findRoots(source);
    }

    // We have a full resourceSet : we return its contents
    return getRoots(source.eResource().getResourceSet());
  }
    private static URI getURI(EObject obj) {
      if (obj == null) return null;

      if (obj.eIsProxy()) return ((InternalEObject) obj).eProxyURI();
      else if (obj.eResource() != null) return obj.eResource().getURI();

      return null;
    }
 private Resource getResource(EObject context) {
   final ContextElementAdapter provider =
       (ContextElementAdapter)
           EcoreUtil.getExistingAdapter(context.eResource(), ContextElementAdapter.class);
   if (provider == null) {
     return context.eResource();
   } else {
     return provider.getElement().eResource();
   }
 }
 private String absolute(String path) {
   path = substitute(path);
   if (source.eResource().getURI().isPlatformResource()) {
     IFile f = WorkspaceSynchronizer.getFile(source.eResource());
     IFile resultFile = f.getProject().getFile(new Path(path));
     resultFile.getParent().getLocation().toFile().mkdirs();
     return resultFile.getLocation().toFile().getAbsolutePath();
   }
   return null;
 }
 private LinkedList<EObject> allContainers(EObject eObject) {
   final LinkedList<EObject> allContainers = Lists.newLinkedList();
   allContainers.add(eObject);
   EObject currentContainer = eObject.eContainer();
   final Resource resource = eObject.eResource();
   while (currentContainer != null && resource == currentContainer.eResource()) {
     allContainers.addFirst(currentContainer);
     currentContainer = currentContainer.eContainer();
   }
   return allContainers;
 }
Example #11
0
 public IResourceDescription getResourceDescription(final EObject o) {
   IResourceDescription _xblockexpression = null;
   {
     Resource _eResource = o.eResource();
     final IResourceDescriptions index = this.rdp.getResourceDescriptions(_eResource);
     Resource _eResource_1 = o.eResource();
     URI _uRI = _eResource_1.getURI();
     _xblockexpression = index.getResourceDescription(_uRI);
   }
   return _xblockexpression;
 }
Example #12
0
 /**
  * Retrieves the genModel from any EObject from the components model.
  *
  * @param eo any EObject from the components model.
  * @return the EMF genModel (intended to hold the ImportManager)
  */
 public GenModel getGenModel(EObject eo) {
   if (eo.eResource() != null && eo.eResource().getResourceSet() != null) {
     for (Resource resource : eo.eResource().getResourceSet().getResources()) {
       if (!resource.getContents().isEmpty()
           && resource.getContents().get(0) instanceof GenModel) {
         return (GenModel) resource.getContents().get(0);
       }
     }
   }
   throw new RuntimeException("Unable to retrieve gen model from " + eo);
 }
Example #13
0
 /**
  * Allows to construct a scope based on a single {@link EObject}. The constructed scope will
  * include the provided {@link EObject}, its direct and indirect contents ({@link
  * EObject#eAllContents()}) as well as its resource ({@link EObject#eResource}) in case one is
  * specified.
  *
  * @param eObject the {@link EObject} used to construct the scope.
  */
 public GenericMatchScope(EObject eObject) {
   eObjectsInScope.add(eObject);
   final Iterator<EObject> iterator = eObject.eAllContents();
   while (iterator.hasNext()) {
     final EObject next = iterator.next();
     eObjectsInScope.add(next);
     if (next.eResource() != null && !resourcesInScope.contains(next.eResource())) {
       resolveAll(next.eResource().getResourceSet());
       resourcesInScope.add(next.eResource());
     }
   }
 }
Example #14
0
 public List<IContainer> getVisibleContainers(final EObject o) {
   List<IContainer> _xblockexpression = null;
   {
     Resource _eResource = o.eResource();
     final IResourceDescriptions index = this.rdp.getResourceDescriptions(_eResource);
     Resource _eResource_1 = o.eResource();
     URI _uRI = _eResource_1.getURI();
     final IResourceDescription rd = index.getResourceDescription(_uRI);
     _xblockexpression = this.cm.getVisibleContainers(rd, index);
   }
   return _xblockexpression;
 }
 public void findLocalReferences(
     Set<? extends EObject> targets,
     IAcceptor<IReferenceDescription> acceptor,
     Predicate<IReferenceDescription> filter,
     IProgressMonitor monitor) {
   if (monitor != null && monitor.isCanceled()) return;
   if (targets != null && !targets.isEmpty()) {
     Set<Resource> targetResources = new HashSet<Resource>();
     for (EObject target : targets) {
       targetResources.add(target.eResource());
     }
     Map<EObject, Collection<Setting>> targetResourceInternalCrossRefs =
         CrossReferencer.find(targetResources);
     Map<EObject, URI> exportedElementsMap = null;
     SubMonitor subMonitor =
         SubMonitor.convert(monitor, Messages.ReferenceQuery_monitor, targets.size());
     for (EObject target : targets) {
       Collection<Setting> crossRefSettings = targetResourceInternalCrossRefs.get(target);
       if (crossRefSettings != null) {
         SubMonitor subSubMonitor = subMonitor.newChild(crossRefSettings.size());
         for (Setting crossRefSetting : crossRefSettings) {
           if (subSubMonitor.isCanceled()) return;
           EObject source = crossRefSetting.getEObject();
           if (crossRefSetting.getEStructuralFeature() instanceof EReference) {
             EReference reference = (EReference) crossRefSetting.getEStructuralFeature();
             int index = 0;
             if (reference.isMany()) {
               List<?> values = (List<?>) source.eGet(reference);
               for (int i = 0; i < values.size(); ++i) {
                 if (target == values.get(i)) {
                   index = i;
                   break;
                 }
               }
             }
             if (exportedElementsMap == null)
               exportedElementsMap = createExportedElementsMap(target.eResource());
             IReferenceDescription localReferenceDescription =
                 new DefaultReferenceDescription(
                     source,
                     target,
                     reference,
                     index,
                     findClosestExportedContainerURI(source, exportedElementsMap));
             if (filter == null || filter.apply(localReferenceDescription))
               acceptor.accept(localReferenceDescription);
           }
           subSubMonitor.worked(1);
         }
       }
     }
   }
 }
Example #16
0
 /**
  * Determines the containing resource for the given eObject.
  *
  * @param eObject the {@link EObject} whose containing resource has to be found
  * @return the resource of the containing eObject or <code>null</code> in case the eObject does
  *     not specify a containing resource and none containing the eObject could be found in the
  *     internal list of resources in scope either.
  */
 private Resource getContainingResource(EObject eObject) {
   // stereotype applications may e.g. not specify an eResource but be contained within one.
   if (eObject.eResource() != null) {
     return eObject.eResource();
   }
   for (Resource resourceInScope : getResourcesInScope()) {
     if (ModelUtils.contains(resourceInScope, eObject)) {
       return resourceInScope;
     }
   }
   return null;
 }
    @SuppressWarnings("unchecked")
    public void widgetSelected(SelectionEvent e) {
      EObject currObject = (EObject) selection.get(0);
      listEObjects = new ArrayList<EObject>();

      if (currObject instanceof Requirement) {
        Attribute attribute =
            CurrentPreferenceHelper.getAttribute(
                (Requirement) currObject, comboAttribute.getText());
        EList<AttributeValue> values =
            (EList<AttributeValue>) comboAttribute.getData(comboAttribute.getText());

        if (attribute instanceof TextAttribute && values.size() > 0) {
          comboValue.setEnabled(true);
          textValue.setEnabled(false);
          Collection<String> choice =
              CurrentPreferenceHelper.getTextualValues((TextAttribute) attribute);
          comboValue.setItems(choice.toArray(new String[0]));
          comboValue.setSelection(new Point(0, comboValue.getText().length()));
        } else if (attribute instanceof AttributeAllocate) {
          comboValue.setEnabled(true);
          textValue.setEnabled(false);
          listEObjects.addAll(
              RequirementUtils.getAllObjects(EcorePackage.eINSTANCE.getEModelElement()));
          comboValue.setItems(listToArray(listEObjects));
          comboValue.setSelection(new Point(0, comboValue.getText().length()));
        } else if (attribute instanceof AttributeLink) {
          comboValue.setEnabled(true);
          textValue.setEnabled(false);
          listEObjects.addAll(RequirementUtils.getAllUpstreams(currObject.eResource()));
          listEObjects.addAll(RequirementUtils.getAllCurrents(currObject.eResource()));
          comboValue.setItems(listToArray(listEObjects));
          comboValue.setSelection(new Point(0, comboValue.getText().length()));
        } else if (attribute instanceof ObjectAttribute) {
          comboValue.setEnabled(true);
          textValue.setEnabled(false);
          listEObjects.addAll(RequirementUtils.getAllUpstreams(currObject.eResource()));
          listEObjects.addAll(RequirementUtils.getAllCurrents(currObject.eResource()));
          listEObjects.addAll(
              RequirementUtils.getAllObjects(EcorePackage.eINSTANCE.getEModelElement()));
          comboValue.setItems(listToArray(listEObjects));
          comboValue.setSelection(new Point(0, comboValue.getText().length()));
        } else {
          comboValue.setEnabled(false);
          textValue.setEnabled(true);
          comboValue.setItems(new String[0]);
        }
      }
    }
Example #18
0
 public JvmType findDeclaredType(Class<?> clazz, EObject context) {
   if (context == null) throw new NullPointerException("context");
   if (context.eResource() == null)
     throw new NullPointerException("context must be contained in a resource");
   final ResourceSet resourceSet = context.eResource().getResourceSet();
   if (resourceSet == null) {
     // may be null if the editor was closed too early
     return null;
   }
   // make sure a type provider is configured in the resource set.
   typeProviderFactory.findOrCreateTypeProvider(resourceSet);
   URI uri = toCommonTypesUri(clazz);
   JvmType declaredType = (JvmType) resourceSet.getEObject(uri, true);
   return declaredType;
 }
    /** @generated */
    protected List getObjectsBeingDropped() {
      TransferData data = getCurrentEvent().currentDataType;
      Collection uris = new HashSet();

      List result = new ArrayList();
      Object transferedObject = getJavaObject(data);
      if (transferedObject instanceof IStructuredSelection) {
        IStructuredSelection selection = (IStructuredSelection) transferedObject;
        for (Iterator it = selection.iterator(); it.hasNext(); ) {
          Object nextSelectedObject = it.next();
          if (nextSelectedObject instanceof SqlmodelNavigatorItem) {
            View view = ((SqlmodelNavigatorItem) nextSelectedObject).getView();
            nextSelectedObject = view.getElement();
          } else if (nextSelectedObject instanceof IAdaptable) {
            IAdaptable adaptable = (IAdaptable) nextSelectedObject;
            nextSelectedObject = adaptable.getAdapter(EObject.class);
          }

          if (nextSelectedObject instanceof EObject) {
            EObject modelElement = (EObject) nextSelectedObject;
            Resource modelElementResource = modelElement.eResource();
            uris.add(
                modelElementResource
                    .getURI()
                    .appendFragment(modelElementResource.getURIFragment(modelElement)));
          }

          if (nextSelectedObject instanceof EObject) {
            result.add(nextSelectedObject);
          }
        }
      }
      return result;
    }
Example #20
0
 @Override
 protected String getCurrentLanguage(Map<Object, Object> context, EObject eObject) {
   Resource resource = eObject.eResource();
   if (resource instanceof InjectMembersResource)
     return ((InjectMembersResource) resource).getLanguageName();
   return super.getCurrentLanguage(context, eObject);
 }
Example #21
0
  @Override
  public IScope getScope(EObject context, EReference reference) {
    if (reference == XcssPackage.Literals.COLOR_CONSTANT__CONSTANT) {
      IJvmTypeProvider typeProvider =
          typeScopeProvider.getTypeProvider(context.eResource().getResourceSet());
      try {
        JvmType type = typeProvider.findTypeByName("org.eclipse.swt.SWT");
        return typeScopeProvider.createMemberScope(
            type,
            new Predicate<JvmMember>() {

              public boolean apply(JvmMember input) {
                if (!(input instanceof JvmField)) return false;
                JvmField field = (JvmField) input;
                if (!field.isStatic()) return false;
                return field.getSimpleName().startsWith("COLOR_");
              }
            },
            new Function<JvmMember, QualifiedName>() {
              public QualifiedName apply(JvmMember from) {
                return QualifiedName.create(from.getSimpleName().substring(6).toLowerCase());
              }
            },
            IScope.NULLSCOPE);
      } catch (TypeNotFoundException tnfe) {
        return IScope.NULLSCOPE;
      }
    }
    return super.getScope(context, reference);
  }
  @Override
  protected List<DiffElement> detectDifferences(EObject left, EObject right)
      throws InterruptedException {
    Map<String, Object> options = Collections.emptyMap();

    // We need here to detect and merge "local" changes. We'll use the "right" as ancestor
    Resource rightRes = right.eResource();
    Resource ancestorRes = null;
    if (rightRes != null) {
      try {
        ancestorRes = rightRes.getClass().newInstance();
        ancestorRes.setURI(rightRes.getURI());
      } catch (InstantiationException e) {
        fail("Couldn't copy '" + rightRes.getURI() + "' resource");
      } catch (IllegalAccessException e) {
        fail("Couldn't copy '" + rightRes.getURI() + "' resource");
      }
    }
    EObject ancestor = EcoreUtil.copy(right);
    if (ancestorRes != null) {
      ancestorRes.getContents().add(ancestor);
    }

    MatchModel match = MatchService.doMatch(left, right, ancestor, options);
    DiffModel diff = DiffService.doDiff(match, true);

    EList<DiffElement> differences = diff.getDifferences();
    return differences;
  }
  private void populateMappingInfo(EObject xmlEntity) {
    Resource resource = xmlEntity.eResource();

    // model contents for this resource
    ModelContents mdlContents = new ModelContents(resource);
    XmlDocument document = getXmlDocument(xmlEntity);
    currentDocumentName = document.getName();
    // fill the map with element to its mappingClass column value
    this.elementMap = new HashMap();
    this.elementFullNames = new HashSet();
    // get the mapping root associated with the transformation
    Iterator rootIter = mdlContents.getTransformations(document).iterator();
    while (rootIter.hasNext()) {
      MappingRoot mappingRoot = (MappingRoot) rootIter.next();
      // if there is a mapping root
      if (mappingRoot != null && mappingRoot instanceof TreeMappingRoot) {
        Iterator mappingIter = mappingRoot.getNested().iterator();
        while (mappingIter.hasNext()) {
          Mapping nestedMapping = (Mapping) mappingIter.next();
          // mapping Class columns
          List inputs = nestedMapping.getInputs();
          // xml elements
          List outputs = nestedMapping.getOutputs();
          if (!outputs.isEmpty() && !inputs.isEmpty()) {
            Object output = outputs.iterator().next();
            Object input = inputs.iterator().next();
            elementMap.put(output, input);
            if (output instanceof XmlElement) {
              elementFullNames.add(this.getFullName((EObject) output));
            }
          }
        }
      }
    }
  }
 public boolean initialize(EObject xtendMethod, IRenameElementContext context) {
   Assert.isLegal(xtendMethod instanceof XtendFunction);
   Assert.isLegal(((XtendFunction) xtendMethod).isDispatch());
   Assert.isLegal(context instanceof DispatchMethodRenameContext);
   ResourceSet resourceSet = xtendMethod.eResource().getResourceSet();
   Map<URI, IJavaElement> jvm2JavaElements =
       ((DispatchMethodRenameContext) context).getJvm2JavaElements();
   for (URI dispatchOperationURI : jvm2JavaElements.keySet()) {
     JvmOperation dispatchOperation =
         (JvmOperation) resourceSet.getEObject(dispatchOperationURI, true);
     XtendFunction xtendDispatchMethod = associations.getXtendFunction(dispatchOperation);
     if (xtendDispatchMethod != null) {
       if (equal(xtendDispatchMethod.getName(), dispatchOperation.getSimpleName())) {
         // synthetic dispatcher
         dispatchers.add(dispatchOperation);
       } else {
         // xtend dispatch method
         XtendDispatchMethodChildStrategy xtendChildStrategy = childStrategyProvider.get();
         xtendChildStrategy.initialize(xtendDispatchMethod, context);
         children.add(xtendChildStrategy);
       }
     } else {
       // a dispatch method form a Java class
       JavaDispatchMethodChildStrategy jvmChildStrategy = javaStrategyProvider.get();
       jvmChildStrategy.initialize(dispatchOperation, context);
       children.add(jvmChildStrategy);
     }
   }
   return !children.isEmpty();
 }
 public String[] getStack() {
   org.eclipse.emf.ecore.EObject next = interpreterDelegate.getNextObjectToInterprete();
   java.util.List<org.eclipse.emf.ecore.EObject> parents =
       new java.util.ArrayList<org.eclipse.emf.ecore.EObject>();
   org.eclipse.emf.ecore.EObject current = next;
   while (current != null) {
     parents.add(current);
     current = current.eContainer();
   }
   String[] stack = new String[parents.size()];
   int i = parents.size();
   for (org.eclipse.emf.ecore.EObject parent : parents) {
     String serializedStackElement =
         org.feature.multi.perspective.mapping.viewmapping.resource.mtext.util.MtextStringUtil
             .encode(
                 ',',
                 new String[] {
                   parent.eClass().getName(),
                   Integer.toString(stackFrameID),
                   parent.eResource().getURI().toString(),
                   Integer.toString(getLine(parent)),
                   Integer.toString(getCharStart(parent)),
                   Integer.toString(getCharEnd(parent))
                 });
     stack[--i] = serializedStackElement;
     stackFrameMap.put(stackFrameID++, parent);
   }
   return stack;
 }
  private static List<Context> findContexts(EObject source) {
    List<Context> contexts = new LinkedList<Context>();

    Context rootContext = null;
    if (source.eResource() != null) {
      for (Resource resource : source.eResource().getResourceSet().getResources()) {
        if (!resource.getContents().isEmpty() && resource.getContents().get(0) instanceof Context) {
          rootContext = (Context) resource.getContents().get(0);
          contexts.add(rootContext);
          break;
        }
      }
    }

    return PropertiesUtil.getDependencies(rootContext);
  }
Example #27
0
 public JvmTypeReference resolveMultiType(JvmTypeReference reference, EObject context) {
   ITypeReferenceOwner owner =
       new StandardTypeReferenceOwner(services, context.eResource().getResourceSet());
   return new OwnedConverter(owner)
       .toLightweightReference(reference)
       .toJavaCompliantTypeReference();
 }
 /**
  * This method groups siblings into the following domains, and chooses only those siblings that
  * are in the same domain as the supplied object.
  *
  * <ul>
  *   <li>{@link Catalog} and {@link Schema} instances
  *   <li>{@link BaseTable} and {@link View} instances
  *   <li>{@link Procedure} instances
  *   <li>{@link ProcedureColumn} instances
  *   <li>{@link AccessPattern} instances
  *   <li>{@link UniqueKey}, {@link ForeignKey} and {@link Index} instances
  *   <li>
  *   <li>
  * </ul>
  */
 @Override
 public List getSiblingsForUniquenessCheck(final EObject eObject) {
   Object parent = eObject.eContainer();
   if (parent == null) {
     parent = eObject.eResource();
   }
   if (eObject instanceof Table) {
     return RelationalUtil.findTables(parent, ModelVisitorProcessor.DEPTH_ONE);
   } else if (eObject instanceof Procedure) {
     return RelationalUtil.findProcedures(parent, ModelVisitorProcessor.DEPTH_ONE);
   } else if (eObject instanceof ProcedureParameter) {
     return RelationalUtil.findProcedureParameters(parent, ModelVisitorProcessor.DEPTH_ONE);
   } else if (eObject instanceof Index) {
     return RelationalUtil.findIndexes(parent, ModelVisitorProcessor.DEPTH_ONE);
   } else if (eObject instanceof ForeignKey || eObject instanceof UniqueKey) {
     return RelationalUtil.findKeys(parent, ModelVisitorProcessor.DEPTH_ONE);
   } else if (eObject instanceof Column) {
     return RelationalUtil.findColumns(parent, ModelVisitorProcessor.DEPTH_ONE);
   } else if (eObject instanceof AccessPattern) {
     if (parent instanceof Table) {
       return ((Table) parent).getAccessPatterns();
     }
     return new LinkedList();
   } else if (eObject instanceof LogicalRelationship) {
     return RelationalUtil.findLogicalRelationships(parent, ModelVisitorProcessor.DEPTH_ONE);
   } else if (eObject instanceof Schema) {
     return RelationalUtil.findSchemas(parent, ModelVisitorProcessor.DEPTH_ONE);
   } else if (eObject instanceof Catalog) {
     return RelationalUtil.findCatalogs(parent, ModelVisitorProcessor.DEPTH_ONE);
   }
   return super.getSiblingsForUniquenessCheck(eObject);
 }
  private static IEditorInput getEditorInput(EObject item) {
    Resource res = item.eResource();
    for (EObject content : res.getContents()) {
      if (content == item) {
        return new FileEditorInput(WorkspaceSynchronizer.getFile(res));
      }
      if (content instanceof HierarchicalNode) {
        break;
      }
    }

    URI uri = EcoreUtil.getURI(item);
    String name = uri.lastSegment() + '#' + item.eResource().getContents().indexOf(item);
    IEditorInput input = new URIEditorInput(uri, name);
    return input;
  }
Example #30
0
 public static String getText(org.eclipse.emf.ecore.EObject eObject) {
   genericity.language.gbind.mopp.GbindMetaInformation metaInformation =
       new genericity.language.gbind.mopp.GbindMetaInformation();
   metaInformation.registerResourceFactory();
   org.eclipse.emf.ecore.resource.ResourceSet rs = null;
   genericity.language.gbind.IGbindTextResource resource =
       (genericity.language.gbind.IGbindTextResource) eObject.eResource();
   if (resource != null) {
     rs = resource.getResourceSet();
   }
   if (rs == null) {
     rs = new org.eclipse.emf.ecore.resource.impl.ResourceSetImpl();
   }
   if (resource == null) {
     org.eclipse.emf.common.util.URI uri =
         org.eclipse.emf.common.util.URI.createURI("temp." + metaInformation.getSyntaxName());
     resource = (genericity.language.gbind.IGbindTextResource) rs.createResource(uri);
   }
   java.io.ByteArrayOutputStream outputStream = new java.io.ByteArrayOutputStream();
   genericity.language.gbind.IGbindTextPrinter printer =
       metaInformation.createPrinter(outputStream, resource);
   try {
     printer.print(eObject);
   } catch (java.io.IOException e) {
     return null;
   }
   return outputStream.toString();
 }