Search in sources :

Example 16 with XMLResource

use of org.eclipse.emf.ecore.xmi.XMLResource in project webtools.servertools by eclipse.

the class ServerTypeResourceFactoryImpl method createResource.

/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public Resource createResource(URI uri) {
    XMLResource result = new ServerTypeResourceImpl(uri);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
    return result;
}
Also used : XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Example 17 with XMLResource

use of org.eclipse.emf.ecore.xmi.XMLResource in project kie-wb-common by kiegroup.

the class BPMFinderServiceImpl method toDefinitions.

private Definitions toDefinitions(final InputStream in) {
    try {
        ResourceSet resourceSet = new ResourceSetImpl();
        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new DroolsResourceFactoryImpl());
        resourceSet.getPackageRegistry().put(DroolsPackage.eNS_URI, DroolsPackage.eINSTANCE);
        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new Bpmn2ResourceFactoryImpl());
        resourceSet.getPackageRegistry().put("http://www.omg.org/spec/BPMN/20100524/MODEL", Bpmn2Package.eINSTANCE);
        XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
        outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
        outResource.setEncoding("UTF-8");
        Map<String, Object> options = new HashMap<String, Object>();
        options.put(XMLResource.OPTION_ENCODING, "UTF-8");
        outResource.load(in, options);
        DocumentRoot root = (DocumentRoot) outResource.getContents().get(0);
        return root.getDefinitions();
    } catch (Exception ex) {
        logger.warn("Cannot parse definitions due to", ex);
    }
    return null;
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) HashMap(java.util.HashMap) DocumentRoot(org.eclipse.bpmn2.DocumentRoot) DroolsResourceFactoryImpl(org.jboss.drools.util.DroolsResourceFactoryImpl) Bpmn2ResourceFactoryImpl(org.eclipse.bpmn2.util.Bpmn2ResourceFactoryImpl) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Example 18 with XMLResource

use of org.eclipse.emf.ecore.xmi.XMLResource in project tbd-studio-se by Talend.

the class HCatalogResourceFactoryImpl method createResource.

/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public Resource createResource(URI uri) {
    XMLResource result = new HCatalogResourceImpl(uri);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
    return result;
}
Also used : XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Example 19 with XMLResource

use of org.eclipse.emf.ecore.xmi.XMLResource in project tbd-studio-se by Talend.

the class HDFSResourceFactoryImpl method createResource.

/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public Resource createResource(URI uri) {
    XMLResource result = new HDFSResourceImpl(uri);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
    return result;
}
Also used : XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Example 20 with XMLResource

use of org.eclipse.emf.ecore.xmi.XMLResource in project archi by archimatetool.

the class CanvasResourceFactory method createResource.

/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public Resource createResource(URI uri) {
    XMLResource result = new CanvasResource(uri);
    // $NON-NLS-1$
    result.getDefaultSaveOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
    // $NON-NLS-1$
    result.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
    return result;
}
Also used : XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Aggregations

XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)38 HashMap (java.util.HashMap)12 ByteArrayInputStream (java.io.ByteArrayInputStream)8 StringWriter (java.io.StringWriter)8 InputStream (java.io.InputStream)6 EObject (org.eclipse.emf.ecore.EObject)5 DocumentRoot (org.jboss.drools.DocumentRoot)5 DocumentRoot (org.eclipse.bpmn2.DocumentRoot)3 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)3 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)3 IOException (java.io.IOException)2 Bpmn2ResourceFactoryImpl (org.eclipse.bpmn2.util.Bpmn2ResourceFactoryImpl)2 URI (org.eclipse.emf.common.util.URI)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 DroolsResourceFactoryImpl (org.jboss.drools.util.DroolsResourceFactoryImpl)2 BPSimDataType (bpsim.BPSimDataType)1 DocumentRoot (bpsim.DocumentRoot)1 ElementParameters (bpsim.ElementParameters)1 Parameter (bpsim.Parameter)1 Scenario (bpsim.Scenario)1