blob: 0777c8a5fc794d3d03a55ea4e97efd78ae34ac86 (
plain) (
blame)
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
|
/*****************************************************************************
* Copyright (c) 2017 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.resource;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.gmf.runtime.emf.core.internal.util.EMFCoreConstants;
/**
* The resource factory for the properties files.
*
* @since 3.0
*/
@SuppressWarnings("restriction")
public class TableResourceFactory extends XMIResourceFactoryImpl {
/** The save options. */
private static final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
static {
saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
saveOptions.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED);
saveOptions.put(XMLResource.OPTION_SAVE_TYPE_INFORMATION, true);
saveOptions.put(XMIResource.OPTION_ENCODING,"UTF-8"); //$NON-NLS-1$
saveOptions.put(XMIResource.OPTION_USE_XMI_TYPE, Boolean.TRUE);
saveOptions.put(XMLResource.OPTION_PROCESS_DANGLING_HREF, XMLResource.OPTION_PROCESS_DANGLING_HREF_DISCARD);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl#createResource(org.eclipse.emf.common.util.URI)
*/
@Override
public Resource createResource(final URI uri) {
final XMIResource resource = new TableResource(uri);
if (!resource.getEncoding().equals(EMFCoreConstants.XMI_ENCODING)) {
resource.setEncoding(EMFCoreConstants.XMI_ENCODING);
}
resource.getDefaultSaveOptions().putAll(saveOptions);
return resource;
}
}
|