org.eclipse.emf.ecore.xmi.XMLResource Java Examples
The following examples show how to use
org.eclipse.emf.ecore.xmi.XMLResource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RadarTypeResourceFactoryImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates an instance of the resource. <!-- begin-user-doc --> <!-- * end-user-doc --> * * @generated */ @Override public Resource createResource( URI uri ) { XMLResource result = new RadarTypeResourceImpl( 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; }
Example #2
Source File: ProcessDiagramEditorUtil.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated */ public static View findView(DiagramEditPart diagramEditPart, EObject targetElement, LazyElement2ViewMap lazyElement2ViewMap) { boolean hasStructuralURI = false; if (targetElement.eResource() instanceof XMLResource) { hasStructuralURI = ((XMLResource) targetElement.eResource()).getID(targetElement) == null; } View view = null; LinkedList<EditPart> editPartHolder = new LinkedList<EditPart>(); if (hasStructuralURI && !lazyElement2ViewMap.getElement2ViewMap().isEmpty()) { view = lazyElement2ViewMap.getElement2ViewMap().get(targetElement); } else if (findElementsInDiagramByID(diagramEditPart, targetElement, editPartHolder) > 0) { EditPart editPart = editPartHolder.get(0); view = editPart.getModel() instanceof View ? (View) editPart.getModel() : null; } return (view == null) ? diagramEditPart.getDiagramView() : view; }
Example #3
Source File: AbstractPortableURIsTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Before public void setUp() throws Exception { globalStateMemento = GlobalRegistries.makeCopyOfGlobalState(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); resourceSet = new XtextResourceSet(); resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/")); resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this); resourceSet.setClasspathURIContext(getClasspathURIContext()); }
Example #4
Source File: ActorFilterConfRepositoryStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected Release getRelease(final Migrator targetMigrator, final Resource resource) { final Map<Object, Object> loadOptions = new HashMap<Object, Object>(); //Ignore unknown features loadOptions.put(XMIResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE); final XMLOptions options = new XMLOptionsImpl(); options.setProcessAnyXML(true); loadOptions.put(XMLResource.OPTION_XML_OPTIONS, options); try { resource.load(loadOptions); } catch (final IOException e) { BonitaStudioLog.error(e, CommonRepositoryPlugin.PLUGIN_ID); } final String modelVersion = getModelVersion(resource); for (final Release release : targetMigrator.getReleases()) { if (release.getLabel().equals(modelVersion)) { return release; } } return targetMigrator.getReleases().iterator().next(); //First release of all time }
Example #5
Source File: ActorFilterImplFileStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void doSave(Object content) { if (content instanceof ConnectorImplementation) { Resource emfResource = getEMFResource(); emfResource.getContents().clear(); DocumentRoot root = ConnectorImplementationFactory.eINSTANCE.createDocumentRoot(); root.setConnectorImplementation((ConnectorImplementation) EcoreUtil.copy((EObject) content)); emfResource.getContents().add(root); try { Map<String, Object> options = new HashMap<>(); options.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); options.put(XMLResource.OPTION_ENCODING, "UTF-8"); options.put(XMLResource.OPTION_XML_VERSION, "1.0"); emfResource.save(options); } catch (IOException e) { BonitaStudioLog.error(e); } } }
Example #6
Source File: OrganizationFileStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void doSave(final Object content) { if (content instanceof Organization) { final Resource emfResource = getEMFResource(); emfResource.getContents().clear(); final DocumentRoot root = OrganizationFactory.eINSTANCE.createDocumentRoot(); root.setOrganization((Organization) EcoreUtil.copy((EObject) content)); emfResource.getContents().add(root); try { final Map<Object, Object> options = new HashMap<>(); options.put(XMLResource.OPTION_ENCODING, "UTF-8"); options.put(XMLResource.OPTION_XML_VERSION, "1.0"); if (emfResource instanceof XMLResourceImpl) { options.putAll(((XMLResourceImpl) emfResource).getDefaultSaveOptions()); } emfResource.save(options); } catch (final IOException e) { BonitaStudioLog.error(e); } } }
Example #7
Source File: ProfileResourceFactoryImpl.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ @Override public Resource createResource ( final URI uri ) { final XMLResource result = new ProfileResourceImpl ( 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 ); result.getDefaultSaveOptions ().put ( XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.PlatformSchemeAware () ); return result; }
Example #8
Source File: DcResourceFactoryImpl.java From fixflow with Apache License 2.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Resource createResource(URI uri) { XMLResource result = new DcResourceImpl(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; }
Example #9
Source File: ProcessConfigurationFileStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void doSave(final Object content) { final Resource resource = getEMFResource(); if (content instanceof Configuration) { resource.getContents().clear(); resource.getContents().add(EcoreUtil.copy((Configuration) content)); } try { final Map<String, String> options = new HashMap<String, String>(); options.put(XMLResource.OPTION_ENCODING, "UTF-8"); options.put(XMLResource.OPTION_XML_VERSION, "1.0"); resource.save(options); resource.unload(); } catch (final IOException e) { BonitaStudioLog.error(e); } }
Example #10
Source File: DiResourceFactoryImpl.java From fixflow with Apache License 2.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Resource createResource(URI uri) { XMLResource result = new DiResourceImpl(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; }
Example #11
Source File: ModelXMLProcessor.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates and returns a new resource for saving or loading an ODA Design object. * @param uri the URI of the resource to create * @return a new resource * @since DTP 1.6 * @generated NOT */ public Resource createResource( URI uri ) { ResourceSet resourceSet = createResourceSet(); // Register the Design package to ensure it is available during loading. resourceSet.getPackageRegistry().put( ModelPackage.eNS_URI, ModelPackage.eINSTANCE ); XMLResource resource = (XMLResource) resourceSet.createResource( uri ); // Use the OPTION_SCHEMA_LOCATION_IMPLEMENTATION option to avoid pre-registration // of the generated packages resource.getDefaultSaveOptions() .put( XMLResource.OPTION_SCHEMA_LOCATION_IMPLEMENTATION, Boolean.FALSE ); return resource; }
Example #12
Source File: ModelResourceFactoryImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Resource createResource(URI uri) { XMLResource result = new ModelResourceImpl(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; }
Example #13
Source File: SerializerImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
protected DesignValues read( InputStream is ) throws IOException { ModelXMLProcessor xmlProcessor = new ModelXMLProcessor( ); Resource resource = xmlProcessor.createResource( URI .createFileURI( "test.designValue" ) ); //$NON-NLS-1$ try { Map options = new HashMap( ); options.put( XMLResource.OPTION_ENCODING, "UTF-8" ); //$NON-NLS-1$ resource.load( is, options ); } catch ( IOException ex ) { throw ex; } DocumentRoot docRoot = (DocumentRoot) resource.getContents( ).get( 0 ); return docRoot.getDesignValues( ); }
Example #14
Source File: DefinitionConfigurationFileStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void doSave(final Object content) { if(content instanceof ConnectorConfiguration){ final Resource emfResource = getEMFResource() ; emfResource.getContents().clear() ; emfResource.getContents().add(EcoreUtil.copy((EObject) content)) ; final Map<Object, Object> options = new HashMap<Object, Object>(); options.put(XMLResource.OPTION_ENCODING, "UTF-8"); options.put(XMLResource.OPTION_XML_VERSION, "1.0"); if (emfResource instanceof XMLResourceImpl) { options.putAll(((XMLResourceImpl) emfResource).getDefaultSaveOptions()); } try { emfResource.save(options); } catch (final IOException e) { BonitaStudioLog.error(e) ; } } }
Example #15
Source File: ConnectorImplFileStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void doSave(Object content) { if (content instanceof ConnectorImplementation) { Resource emfResource = getEMFResource(); emfResource.getContents().clear(); DocumentRoot root = ConnectorImplementationFactory.eINSTANCE.createDocumentRoot(); root.setConnectorImplementation((ConnectorImplementation) EcoreUtil.copy((EObject) content)); emfResource.getContents().add(root); try { Map<String, Object> options = new HashMap<>(); options.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); options.put(XMLResource.OPTION_ENCODING, "UTF-8"); options.put(XMLResource.OPTION_XML_VERSION, "1.0"); emfResource.save(options); } catch (IOException e) { BonitaStudioLog.error(e); } } }
Example #16
Source File: BpmnDiResourceFactoryImpl.java From fixflow with Apache License 2.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Resource createResource(URI uri) { XMLResource result = new BpmnDiResourceImpl(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; }
Example #17
Source File: LayoutResourceFactoryImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public Resource createResource( URI uri ) { XMLResource result = new LayoutResourceImpl( 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; }
Example #18
Source File: ShadowModelValidationJob.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void cloneResource(final IProgressMonitor monitor, final Resource shadowResource) throws ExecutionException { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); try { TransactionUtil.getEditingDomain(resource).runExclusive(() -> { try { XMISaveImpl saver = new XMISaveImpl(new XMIHelperImpl((XMLResource) resource)); saver.save((XMLResource) resource, bout, Collections.emptyMap()); bout.flush(); } catch (Throwable tt) { tt.printStackTrace(); } }); } catch (InterruptedException e1) { e1.printStackTrace(); } try { shadowResource.load(new ByteArrayInputStream(bout.toByteArray()), Collections.emptyMap()); } catch (IOException e) { e.printStackTrace(); } }
Example #19
Source File: TypeResourceFactoryImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public Resource createResource( URI uri ) { XMLResource result = new TypeResourceImpl( 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; }
Example #20
Source File: ComponentResourceFactoryImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public Resource createResource( URI uri ) { XMLResource result = new ComponentResourceImpl( 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; }
Example #21
Source File: ProcessConfigurationRepositoryStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected Release getRelease(final Migrator targetMigrator, final Resource resource) { final Map<Object, Object> loadOptions = new HashMap<Object, Object>(); //Ignore unknown features loadOptions.put(XMIResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE); final XMLOptions options = new XMLOptionsImpl(); options.setProcessAnyXML(true); loadOptions.put(XMLResource.OPTION_XML_OPTIONS, options); String modelVersion = null; try { resource.load(loadOptions); modelVersion = getModelVersion(resource); } catch (final IOException e) { BonitaStudioLog.error(e, CommonRepositoryPlugin.PLUGIN_ID); } finally { resource.unload(); } for (final Release release : targetMigrator.getReleases()) { if (release.getLabel().equals(modelVersion)) { return release; } } return targetMigrator.getReleases().iterator().next(); //First release of all time }
Example #22
Source File: SerializerImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
public ChartPreferences loadPreferences( InputStream is ) throws IOException { // Create and setup local ResourceSet ResourceSet rsChart = new ResourceSetImpl( ); rsChart.getResourceFactoryRegistry( ) .getExtensionToFactoryMap( ) .put( "chart", new ModelResourceFactoryImpl( ) ); //$NON-NLS-1$ // Create resources to represent the disk files to be used to store the // models Resource rChart = rsChart.createResource( URI.createFileURI( "test.chart" ) ); //$NON-NLS-1$ Map<String, Object> options = new HashMap<String, Object>( ); options.put( XMLResource.OPTION_ENCODING, "UTF-8" ); //$NON-NLS-1$ rChart.load( is, options ); return (ChartPreferences) rChart.getContents( ).get( 0 ); }
Example #23
Source File: ModelWriter.java From orcas with Apache License 2.0 | 6 votes |
public static String getSkriptXml( Model pModel ) { Resource.Factory.Registry lRegistry = Resource.Factory.Registry.INSTANCE; Map<String,Object> lMap = lRegistry.getExtensionToFactoryMap(); lMap.put( "xml", new XMLResourceFactoryImpl() ); ResourceSet lResourceSet = new ResourceSetImpl(); Resource lResource = lResourceSet.createResource( URI.createFileURI( "*.xml" ) ); ((XMLResource)lResource).getDefaultSaveOptions(); lResource.getContents().add( pModel ); try { ByteArrayOutputStream lByteArrayOutputStream = new ByteArrayOutputStream(); lResource.save( lByteArrayOutputStream, Collections.EMPTY_MAP ); return new String( lByteArrayOutputStream.toByteArray() ); } catch( IOException e ) { throw new RuntimeException( e ); } }
Example #24
Source File: XtextFileLoader.java From orcas with Apache License 2.0 | 6 votes |
@SuppressWarnings( "unchecked" ) public T loadModelXml( String pFilename, String pNamespaceUri, EPackage pEPackage ) { EPackage.Registry.INSTANCE.put( pNamespaceUri, pEPackage ); Resource.Factory.Registry lRegistry = Resource.Factory.Registry.INSTANCE; Map<String, Object> lMap = lRegistry.getExtensionToFactoryMap(); lMap.put( "xml", new XMLResourceFactoryImpl() ); ResourceSet lResourceSet = new ResourceSetImpl(); Resource lResource = lResourceSet.createResource( URI.createFileURI( pFilename ) ); ((XMLResource) lResource).getDefaultSaveOptions(); try { lResource.load( Collections.EMPTY_MAP ); } catch( IOException e ) { throw new RuntimeException( e ); } return (T) lResource.getContents().get( 0 ); }
Example #25
Source File: AttributeResourceFactoryImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> <!-- * end-user-doc --> * @generated */ @Override public Resource createResource( URI uri ) { XMLResource result = new AttributeResourceImpl( 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; }
Example #26
Source File: DataResourceFactoryImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public Resource createResource( URI uri ) { XMLResource result = new DataResourceImpl( 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; }
Example #27
Source File: ModelResourceFactoryImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> <!-- * end-user-doc --> * @generated */ @Override public Resource createResource( URI uri ) { XMLResource result = new ModelResourceImpl( 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; }
Example #28
Source File: DcResourceFactoryImpl.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Creates an instance of the resource. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Resource createResource(URI uri) { XMLResource result = new DcResourceImpl(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); //Ignore Unknown Feature result.getDefaultLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE); return result; }
Example #29
Source File: SerializerImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
public Chart read( URI uri ) throws IOException { // Create and setup local ResourceSet ResourceSet rsChart = new ResourceSetImpl( ); rsChart.getResourceFactoryRegistry( ) .getExtensionToFactoryMap( ) .put( "chart", new ModelResourceFactoryImpl( ) ); //$NON-NLS-1$ // Create resources to represent the disk files to be used to store the // models Resource rChart = null; rChart = rsChart.createResource( uri ); Map<String, Object> options = new HashMap<String, Object>( ); options.put( XMLResource.OPTION_ENCODING, "UTF-8" ); //$NON-NLS-1$ rChart.load( options ); return (Chart) rChart.getContents( ).get( 0 ); }
Example #30
Source File: SerializerImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
public void savePreferences( ChartPreferences preferences, OutputStream os ) throws IOException { // Create and setup local ResourceSet ResourceSet rsChart = new ResourceSetImpl( ); rsChart.getResourceFactoryRegistry( ) .getExtensionToFactoryMap( ) .put( "chart", new ModelResourceFactoryImpl( ) ); //$NON-NLS-1$ // Create resources to represent the disk files to be used to store the // models Resource rChart = rsChart.createResource( URI.createFileURI( "test.chart" ) ); //$NON-NLS-1$ // Add the chart to the resource rChart.getContents( ).add( preferences ); Map<String, Object> options = new HashMap<String, Object>( ); options.put( XMLResource.OPTION_ENCODING, "UTF-8" ); //$NON-NLS-1$ // Save the resource to disk rChart.save( os, options ); }