To get started with EMF and UML, you need at least a dependency to the following jars:
- org.eclipse.emf.common
- org.eclipse.emf.ecore
- org.eclipse.uml2.uml
Then you can load your first EMF model with the following code:
File file = new File("path")
ResourceSet resourceSet = new ResourceSetImpl();
// Register the various metamodels that will be used, here we are using UML
resourceSet.getPackageResgitry().put(UMLPackage.NS_URI, UMLPackage.eINSTANCE);
// Load the resource
URI uri = URI.createFileURI(file.getAbsolutePath());
Resource resource = resourceSet.getResource(uri, false);
// Iterate on the content of the whole resource
TreeIterator<EObject> iterator = resource.getAllContents();
while (iterator.hasNext()) {
EObject eObject = iterator.next();
}
Parsing and evaluating OCL code on EObjects (EMF basic element) would be a bit more complicated, you can have a look at OCL's documentation and wiki for more information: https://wiki.eclipse.org/OCL#Example_Code