use of org.eclipse.emf.ecore.xmi.XMIResource in project InformationSystem by ObeoNetwork.
the class DatabaseResourceFactoryImpl method createResource.
@Override
public Resource createResource(URI uri) {
XMIResource resource = new DatabaseResourceImpl(uri);
Map<Object, Object> saveOptions = resource.getDefaultSaveOptions();
saveOptions.put(XMLResource.OPTION_CONFIGURATION_CACHE, Boolean.TRUE);
saveOptions.put(XMLResource.OPTION_USE_CACHED_LOOKUP_TABLE, lookupTable);
Map<Object, Object> loadOptions = resource.getDefaultLoadOptions();
loadOptions.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.FALSE);
loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, parserPool);
loadOptions.put(XMLResource.OPTION_USE_XML_NAME_TO_FEATURE_MAP, nameToFeatureMap);
return resource;
}
use of org.eclipse.emf.ecore.xmi.XMIResource in project xtext-core by eclipse.
the class InjectableValidatorTest method testWrongResource.
@Test
public void testWrongResource() throws Exception {
Main main = LangATestLanguageFactory.eINSTANCE.createMain();
XMIResource xmiResource = new XMIResourceImpl();
xmiResource.getContents().add(main);
assertTrue(languageSpecificValidator.validate(main, new BasicDiagnostic(), null));
assertTrue(languageSpecificValidator.validate(main, new BasicDiagnostic(), context));
context.put(AbstractInjectableValidator.CURRENT_LANGUAGE_NAME, xtextResource.getLanguageName());
assertFalse(languageSpecificValidator.validate(main, new BasicDiagnostic(), context));
context.clear();
assertFalse(languageAgnosticValidator.validate(main, new BasicDiagnostic(), null));
assertFalse(languageAgnosticValidator.validate(main, new BasicDiagnostic(), context));
context.put(AbstractInjectableValidator.CURRENT_LANGUAGE_NAME, xtextResource.getLanguageName());
assertFalse(languageAgnosticValidator.validate(main, new BasicDiagnostic(), context));
}
use of org.eclipse.emf.ecore.xmi.XMIResource in project n4js by eclipse.
the class UserdataMapper method getDeserializedModuleFromDescription.
/**
* Reads the TModule stored in the given IEObjectDescription.
*/
public static TModule getDeserializedModuleFromDescription(IEObjectDescription eObjectDescription, URI uri) {
final String serializedData = eObjectDescription.getUserData(USERDATA_KEY_SERIALIZED_SCRIPT);
if (Strings.isNullOrEmpty(serializedData)) {
return null;
}
final XMIResource xres = new XMIResourceImpl(uri);
try {
final boolean binary = !serializedData.startsWith("<");
final ByteArrayInputStream bais = new ByteArrayInputStream(binary ? XMLTypeFactory.eINSTANCE.createBase64Binary(serializedData) : serializedData.getBytes(TRANSFORMATION_CHARSET_NAME));
xres.load(bais, getOptions(uri, binary));
} catch (Exception e) {
// $NON-NLS-1$
LOGGER.warn("error deserializing module from IEObjectDescription: " + uri);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("error deserializing module from IEObjectDescription=" + eObjectDescription + ": " + uri, // $NON-NLS-1$
e);
}
// IDE, so the format could be out of date (after an update of the IDE))
return null;
}
final List<EObject> contents = xres.getContents();
if (contents.isEmpty() || !(contents.get(0) instanceof TModule)) {
return null;
}
final TModule module = (TModule) contents.get(0);
xres.getContents().clear();
return module;
}
use of org.eclipse.emf.ecore.xmi.XMIResource in project InformationSystem by ObeoNetwork.
the class ToolkitsResourceFactoryImpl method createResource.
/**
* Creates an instance of the resource.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public Resource createResource(URI uri) {
XMIResource result = new ToolkitsResourceImpl(uri);
Map<Object, Object> saveOptions = result.getDefaultSaveOptions();
saveOptions.put(XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.PlatformSchemeAware());
saveOptions.put(XMLResource.OPTION_CONFIGURATION_CACHE, Boolean.TRUE);
saveOptions.put(XMLResource.OPTION_USE_CACHED_LOOKUP_TABLE, lookupTable);
Map<Object, Object> loadOptions = result.getDefaultLoadOptions();
loadOptions.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.FALSE);
loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, parserPool);
loadOptions.put(XMLResource.OPTION_USE_XML_NAME_TO_FEATURE_MAP, nameToFeatureMap);
return result;
}
use of org.eclipse.emf.ecore.xmi.XMIResource in project InformationSystem by ObeoNetwork.
the class ScaffoldResourceFactoryImpl method createResource.
/**
* Creates an instance of the resource.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public Resource createResource(URI uri) {
XMIResource resource = new ScaffoldResourceImpl(uri);
Map<Object, Object> saveOptions = resource.getDefaultSaveOptions();
saveOptions.put(XMLResource.OPTION_CONFIGURATION_CACHE, Boolean.TRUE);
saveOptions.put(XMLResource.OPTION_USE_CACHED_LOOKUP_TABLE, lookupTable);
saveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
saveOptions.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
Map<Object, Object> loadOptions = resource.getDefaultLoadOptions();
loadOptions.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.FALSE);
loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, parserPool);
loadOptions.put(XMLResource.OPTION_USE_XML_NAME_TO_FEATURE_MAP, nameToFeatureMap);
loadOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
return resource;
}
Aggregations