Search in sources :

Example 21 with XMLResource

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

the class JsonResourceFactoryImpl method createResource.

/**
     * Creates an instance of the resource.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
@Override
public Resource createResource(URI uri) {
    XMLResource result = new JsonResourceImpl(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 22 with XMLResource

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

the class Bpmn2UnMarshaller method unmarshall.

public Graph unmarshall(final String content) throws IOException {
    final XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://" + UUID.uuid() + ".xml"));
    outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
    outResource.setEncoding("UTF-8");
    final Map<String, Object> options = new HashMap<String, Object>();
    options.put(XMLResource.OPTION_ENCODING, "UTF-8");
    outResource.load(new BufferedInputStream(new ByteArrayInputStream(content.getBytes("UTF-8"))), options);
    final DocumentRoot root = (DocumentRoot) outResource.getContents().get(0);
    final Definitions definitions = root.getDefinitions();
    return unmarshall(definitions, null);
}
Also used : HashMap(java.util.HashMap) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) DocumentRoot(org.eclipse.bpmn2.DocumentRoot) Definitions(org.eclipse.bpmn2.Definitions) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Example 23 with XMLResource

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

the class MdmpropertiesResourceFactoryImpl method createResource.

/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public Resource createResource(URI uri) {
    XMLResource result = new MdmpropertiesResourceImpl(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 24 with XMLResource

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

the class ColumnsetResourceFactoryImpl method createResource.

/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public Resource createResource(URI uri) {
    XMLResource result = new ColumnsetResourceImpl(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 25 with XMLResource

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

the class ResourceUtils method setUUID.

public static void setUUID(EObject parent, EObject eobject) {
    if (eobject.eResource() == null) {
        XMLResource xmlResource = parent != null && parent.eResource() != null ? (XMLResource) parent.eResource() : new XMLResourceImpl();
        xmlResource.getContents().add(eobject);
    }
    Resource res = eobject.eResource();
    if (res instanceof XMLResource) {
        ((XMLResource) res).setID(eobject, EcoreUtil.generateUUID());
    }
}
Also used : XMLResourceImpl(org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) Resource(org.eclipse.emf.ecore.resource.Resource) 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