RoyalandLoyal example [message #868788] |
Wed, 02 May 2012 10:42  |
Eclipse User |
|
|
|
In the RoyalandLoyal example, there is RoyalandLoyal.ocl file. I just want to know what tools or button/menu I should use to generate my xx.ocl file to validate the ecore model.
Thanks sincerely!
|
|
|
|
|
|
|
|
Re: RoyalandLoyal example [message #869956 is a reply to message #869907] |
Sat, 05 May 2012 02:39   |
Eclipse User |
|
|
|
The following shows the code example how we can parse xx.ocl file. I think it just you suggested me before to write some java prior.
I want to modify the codes in the ocl document guide. But some words puzzled. The notation denotes that "get an OCL text file via some hypothetical API", I just wonder what API should I use. Can you give some reference?
The eclipse reminds me to create getWorkspaceFile class. If there is any code already I can use?
Thanks
--------------------------------------------------------------------------------
OCL<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, Constraint, EClass, EObject> ocl;
ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
// get an OCL text file via some hypothetical API
IFile file = getWorkspaceFile("/ocl/constraints.ocl");
InputStream in = file.getContents();
Map<String, Constraint> constraintMap = new HashMap<String, Constraint>();
// parse the contents as an OCL document
try {
OCLInput document = new OCLInput(in, file.getCharset());
List<Constraint> constraints = ocl.parse(input);
for (Constraint next : constraints) {
constraintMap.put(next.getName(), next);
OCLExpression<EClassifier> body = next.getSpecification().getBodyExpression();
System.out.printf("%s: %s%n", next.getName(), body);
}
} finally {
in.close();
}
[Updated on: Sat, 05 May 2012 02:42] by Moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05904 seconds