public RefPackage execute(RefPackage refPackage) throws RuntimeException, IllegalArgumentException { for (RefClass metaClass : (Collection<RefClass>) refPackage.refAllClasses()) { result.addAll( metaClass.refAllOfClass() ); } return null; } });
public void execute(RefObject sourceObject) throws RuntimeException, IllegalArgumentException { RefObject result; result = targetRefClass.refCreateInstance(null); objectsMap.put( sourceObject, result ); }
/** * @param sourceExtent not null model extent where to lookup the metaclass in * @return non-null list of one element - the metaobject, describing the metaclass */ public Collection<RefObject> execute(RefPackage sourceExtent) throws JmiException { Collection<RefObject> result; // locate the meta class (in metaClass) within the metamodel result = new ArrayList<>(); result.add(Navigator.getMetaClass( sourceExtent, qualifiedName ).refMetaObject()); return result; } }
/** * Copy the instances of refClass to the targetExtent with the stated metamodel transformation, * collect the correspondence of original to copy objects in objectsMap * * @param targetExtent not null extent where to copy the instances of refClass * @param originalMetaClass not null source model class * @param objectsMap not null correspondence between an original and copy objects */ private void copyObjects(RefPackage targetExtent, RefClass originalMetaClass, Map<RefObject, RefObject> objectsMap) { Procedure<RefObject> construct; ClassName className; className = new ClassNameImpl((Classifier) originalMetaClass.refMetaObject()); construct = nameMapping.mapMetaClass( className, sourceExtent, targetExtent, objectsMap ); for (RefObject source : (Collection<RefObject>) originalMetaClass.refAllOfClass()) { try { construct.execute(source); // objectsMap is updated to bind the source to the produced object(s) if any } catch (Exception ex) { LOGGER.log(Level.SEVERE, "Copy object "+new PrintModelElement().execute( source )+" caused: ",ex); } } }
result = structClassClass.refCreateStruct(getName(), fieldValues );
result = enumClassClass.refGetEnum( enumClassName.getName(), getName() );
/** * @param source Navigate from this element, down the path */ public RefObject execute(RefObject source) throws IllegalArgumentException { RefObject result; // fond the source object if ( source == null ) { throw new IllegalArgumentException("Expected a non-null model element"); } // find the target extent result = source.refClass().refCreateInstance( null ); return result; } }
/** * @param sourceExtent not null extent */ public Collection<RefObject> execute(RefPackage sourceExtent) throws JmiException { Collection<RefObject> result; // locate the meta class (in metaClass) within the metamodel result = Navigator.getMetaClass( sourceExtent, metaclass ).refAllOfClass(); return result; } }
/** * This method requires an M1 object object and a StringBuilder where to describe the object. * * @param result is the buffer where to add the obect's description * @param object is the M1 object to investigate */ private void append(StringBuilder result, RefClass object, Set visited) { result.append( "RefClass ") .append( object.refMetaObject().refGetValue( "name" ) ); }
/** * The task's execution method. This method filters the model classes associated with metaclass and * executes the nested <template> tasks for the filtered classes collection. This * methods invokes the internal formatting tasks with the metaclass itself. * @param metaclass Path in the metamodel to the metaclass whose instances (in the model/extent) are to be * processed. Format of metaclass attribute: {<package>::} <meta class> */ public RefObject execute(String metaclass) throws IllegalArgumentException { RefClass refClass; RefObject result; if ( metaclass == null ) { throw new IllegalArgumentException( "Expected a non-null metaclass provided"); } refClass = Navigator.getMetaClass( extent, metaclass ); // non-null result = refClass.refCreateInstance( null ); return result; } }
/** * This method registers in the cache all instances of that class * @param classProxy not null */ public final void load(RefClass classProxy) { Iterator iterator; RefObject refObject; iterator = classProxy.refAllOfClass().iterator(); while ( iterator.hasNext() ) { refObject = (RefObject) iterator.next(); register(refObject); } }
/** * @return the result of eval() method of the class provided */ public final boolean eval(RefObject value) { boolean result; RefPackage extent; RefClass metaclass; extent = value.refOutermostPackage(); metaclass = Navigator.getMetaClass( extent, metaClassName ); result = value.refIsInstanceOf( metaclass.refMetaObject(), true ); return result; } }
public Multiplicity constructMultiplicity(int otherEndUpper) { Multiplicity result; MultiplicityRange range; result = (Multiplicity) multiplicity.getMetaClass( extent ).refCreateInstance( null ); range = (MultiplicityRange) multiplicityRange.getMetaClass( extent ).refCreateInstance( null ); range.setUpper( otherEndUpper ); result.getRange().add(range); return result; }
/** * @param modelElement is a non-null model element. * @return a non-null collection of tagged values bound to that model element */ private Collection<TaggedValue> allTaggedValues(ModelElement modelElement) { Collection<TaggedValue> result; TaggedValue tag; Iterator sourceIterator; result = new ArrayList<TaggedValue>(); sourceIterator = taggedValue.getMetaClass( extent ).refAllOfClass().iterator(); while ( sourceIterator.hasNext() ) { tag = (TaggedValue) sourceIterator.next(); if ( tag.getModelElement() == modelElement ) { result.add( tag ); } } return result; }
sourceMetaObject = (Classifier) originalModelClass.refMetaObject();
public Expression constructExpression(String body) { Expression result; result = (Expression) expression.getMetaClass( extent ).refCreateInstance( null ); result.setBody( body ); return result; }
/** * Copy the values of the attributes of the instances of refClass as corresponding values of corresponding attributes in * the corresponding instances * * @param targetExtent not null extent where to copy the instances of refClass * @param originalMetaClass not null source model class * @param objectsMap not null correspondence between an original and copy objects */ private void copyAttributes(RefPackage targetExtent, RefClass originalMetaClass, Map<RefObject, RefObject> objectsMap) { Collection<Procedure<RefObject>> copyAttributesOperations; copyAttributesOperations = collectCopyAttributeOperations(originalMetaClass, targetExtent, objectsMap); // TODO: Let A extends B, check if A.allOfClass() subclass of B.allOfClass() // TODO: If so, then DO NOT collect superclasses of A to collect their attributes, as this would // TODO: repeat copying the parent attributes for all its subclasses, which is slow for (RefObject source : (Collection<RefObject>) originalMetaClass.refAllOfClass()) { for (Procedure<RefObject> copy : copyAttributesOperations) { try { copy.execute(source); } catch (Exception ex) { LOGGER.log(Level.SEVERE, copy+" on "+new PrintModelElement().execute( source )+" caused: ", ex); } } } }
ownerClassifier = (Classifier) ownerRefClass.refMetaObject();
/** * @param source Navigate from this element, down the path */ public RefObject execute(RefObject source) throws IllegalArgumentException { RefObject result; RefClass refClass; String metaclass; // fond the source object if ( source == null ) { throw new IllegalArgumentException("Expected a non-null model element"); } metaclass = Navigator.getMetaClassName( source ); refClass = Navigator.getMetaClass( extent, metaclass ); // non-null result = refClass.refCreateInstance( null ); return result; } }
result = constructQualifiedName((ModelElement) ((RefObject) startFrom).refClass().refMetaObject());