-
Notifications
You must be signed in to change notification settings - Fork 85
/
CapellacommonResourceImpl.java
212 lines (195 loc) · 6.47 KB
/
CapellacommonResourceImpl.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*******************************************************************************
* Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.core.data.capellacommon.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xmi.XMLHelper;
import org.eclipse.emf.ecore.xmi.XMLLoad;
import org.eclipse.emf.ecore.xmi.XMLParserPool;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.XMLSave;
import org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
import org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl;
import org.polarsys.capella.common.data.core.gen.xmi.impl.CapellaXMLSaveImpl;
import org.polarsys.capella.common.data.modellingcore.ModelElement;
import org.polarsys.kitalpha.emde.xmi.XMIExtensionHelperImpl;
import org.polarsys.kitalpha.emde.xmi.XMIExtensionLoadImpl;
/**
* <!-- begin-user-doc -->
* The <b>Resource </b> associated with the package.
* <!-- end-user-doc -->
* @see org.polarsys.capella.core.data.capellacommon.util.CapellacommonResourceFactoryImpl
* @generated
*/
public class CapellacommonResourceImpl extends XMIResourceImpl {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private List<Object> lookupTable = new ArrayList<Object>();
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private XMLParserPool parserPool = new XMLParserPoolImpl();
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private Map<Object, Object> nameToFeatureMap = new HashMap<Object, Object>();
/**
* Creates an instance of the resource.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param uri the URI of the new resource.
* @generated
*/
public CapellacommonResourceImpl(URI uri) {
super(uri);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
protected void attachedHelper(EObject eObject) {
// Make sure specified object has its id generated.
if (eObject instanceof ModelElement) {
setID(eObject, ((ModelElement) eObject).getId());
} else if (null != eObject && null != eObject.eClass()) {
EAttribute attribute = eObject.eClass().getEIDAttribute();
if (attribute != null) {
Object id = eObject.eGet(attribute);
if (id instanceof String) {
setID(eObject, (String)id);
}
}
}
super.attachedHelper(eObject);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected XMLSave createXMLSave() {
return new CapellaXMLSaveImpl(createXMLHelper());
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected XMLHelper createXMLHelper() {
return new XMIExtensionHelperImpl(this);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected XMLLoad createXMLLoad() {
return new XMIExtensionLoadImpl((XMIExtensionHelperImpl) createXMLHelper());
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void init() {
super.init();
setTrackingModification(true);
// Save Options
getDefaultSaveOptions().put(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
getDefaultSaveOptions().put(XMLResource.OPTION_CONFIGURATION_CACHE, Boolean.TRUE);
getDefaultSaveOptions().put(XMLResource.OPTION_USE_CACHED_LOOKUP_TABLE, lookupTable);
getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
getDefaultSaveOptions().put(XMLResource.OPTION_SAVE_TYPE_INFORMATION, Boolean.TRUE);
getDefaultSaveOptions().put(XMLResource.OPTION_LINE_WIDTH, new Integer(80));
getDefaultSaveOptions().put(XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.PlatformSchemeAware());
getDefaultSaveOptions().put(XMLResource.OPTION_FLUSH_THRESHOLD, Integer.valueOf(0x01000000));
getDefaultSaveOptions().put(XMLResource.OPTION_USE_FILE_BUFFER, Boolean.TRUE);
// Load Options
getDefaultLoadOptions().put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
getDefaultLoadOptions().put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
getDefaultLoadOptions().put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.TRUE);
getDefaultLoadOptions().put(XMLResource.OPTION_USE_PARSER_POOL, parserPool);
getDefaultLoadOptions().put(XMLResource.OPTION_USE_XML_NAME_TO_FEATURE_MAP, nameToFeatureMap);
getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
getDefaultLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#getEObjectByID(java.lang.String)
* @generated
*/
@Override
protected EObject getEObjectByID(String id) {
if (idToEObjectMap == null)
return super.getEObjectByID(id);
return getIDToEObjectMap().get(id);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see org.eclipse.emf.ecore.resource.impl.ResourceImpl#getIntrinsicIDToEObjectMap()
* @generated
*/
@Override
@SuppressWarnings("unchecked")
public Map getIntrinsicIDToEObjectMap() {
return getIDToEObjectMap();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#doUnload()
* @generated
*/
@Override
protected void doUnload() {
super.doUnload();
this.idToEObjectMap = null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see org.eclipse.emf.ecore.resource.impl.ResourceImpl#setLoaded()
* @generated
*/
@Override
protected Notification setLoaded(boolean isLoaded) {
return super.setLoaded(isLoaded);
}
//end-capella-code
//end-capella-code
} //CapellacommonResourceImpl