/
UML402UMLResourceFactoryImpl.java
75 lines (64 loc) · 2.2 KB
/
UML402UMLResourceFactoryImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Copyright (c) 2014, 2018 CEA and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Kenn Hussey (CEA) - initial API and implementation
* Christian W. Damus (CEA) - 433149
* Kenn Hussey - 535301
*
*/
package org.eclipse.uml2.uml.internal.resource;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.uml2.uml.resource.UML402UMLExtendedMetaData;
import org.eclipse.uml2.uml.resource.UML402UMLResource;
import org.eclipse.uml2.uml.resource.UML402UMLResourceHandler;
import org.eclipse.uml2.uml.resource.UMLResource;
/**
* Resource factory that converts .uml models.
* <ul>
* <li>OMG: UML 2.4.x and UML 2.5</li>
* <li>API: UML2 4.x and UML2 5.0</li>
* </ul>
*
* @since 5.0
*/
public class UML402UMLResourceFactoryImpl
extends UMLResourceFactoryImpl
implements UML402UMLResource.Factory {
public UML402UMLResourceFactoryImpl() {
super();
}
@Override
public Resource createResourceGen(URI uri) {
UML402UMLResource result = new UML402UMLResourceImpl(uri);
result.setEncoding(UML402UMLResource.DEFAULT_ENCODING);
return result;
}
@Override
public Resource createResource(URI uri) {
UMLResource resource = (UMLResource) super.createResource(uri);
Map<Object, Object> defaultLoadOptions = resource
.getDefaultLoadOptions();
EPackage.Registry ePackageRegistry = new EPackageRegistryImpl(
EPackage.Registry.INSTANCE);
ExtendedMetaData extendedMetaData = new UML402UMLExtendedMetaData(
ePackageRegistry);
defaultLoadOptions.put(XMLResource.OPTION_EXTENDED_META_DATA,
extendedMetaData);
defaultLoadOptions.put(XMLResource.OPTION_LAX_FEATURE_PROCESSING,
Boolean.FALSE);
defaultLoadOptions.put(XMLResource.OPTION_RESOURCE_HANDLER,
new UML402UMLResourceHandler());
return resource;
}
}