|
|||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
XMIReferenceProvider | Implementation of this interface can be passed to XMI producers/writers
(using XMIOutputConfig.setReferenceProvider(org.netbeans.api.xmi.XMIReferenceProvider) method) to enable custom controling of
target documents the written object should go into and what XMI ID they should use. |
XMIReferenceResolver | Implementation of this interface can be passed to XMI reader/consumer
(using XMIInputConfig.setReferenceResolver(org.netbeans.api.xmi.XMIReferenceResolver) method) to enable custom resolving of hrefs. |
XMIReferenceResolver.Client |
Class Summary | |
XMIInputConfig | Configuration class for objects taking XMI as input (e.g. |
XMIOutputConfig | Configuration class for objects producing XMI as output (e.g. |
XMIReader | Base class for enhanced XMI readers. |
XMIReaderFactory | Factory class for creating instances of XMI reader objects. |
XMIReferenceProvider.XMIReference | Simple structure for representing XMI references to elements corresponding to an object. |
XMIWriter | Base class for enhanced XMI writers. |
XMIWriterFactory | Factory for XMI writers. |
API classes and interfaces that are used for import/export of XMI documents into/from a JMI-compliant repository. Below is a description of the most common use-cases.
Here is a sample code that creates an empty instance of MOF and reads in an XMI containing some MOF metamodel:
// get the default repository MDRepository repository = MDRManager.getDefault().getDefaultRepository(); // start a write transaction boolean fail = true; repository.beginTrans(true); try { // create a new MOF extent RefPackage mof = repository.createExtent("MyMOFExtent"); // create an XMIReader XMIReader reader = XMIReaderFactory.getDefault().createXMIReader(); // read the document reader.read(new File("myxmifile.xmi").toURL().toString(), mof); // everything succeeded => set fail flag to false fail = false; } catch (Exception e) { System.out.println("Fatal error reading XMI."); e.printStackTrace(); } finally { // commit/rollback the transaction repository.endTrans(fail); }
// get the default repository MDRepository repository = MDRManager.getDefault().getDefaultRepository(); // declare an output stream FileOutputStream out = null; // start a read-only transaction repository.beginTrans(false); try { // get the extent RefPackage mof = repository.getExtent("MyMOFExtent"); // create an XMIWriter XMIWriter writer = XMIWriterFactory.getDefault().createXMIWriter(); // open a stream out = new FileOutputStream("myxmifile.xml"); // export the document (default version of XMI = 1.2) writer.write(out, mof, null); } catch (Exception e) { System.out.println("Fatal error reading XMI."); e.printStackTrace(); } finally { // release the transaction repository.endTrans(); // close the stream if necessary if (out != null) { try { out.close(); } catch (IOException e) { e.printStackTrace(); } } }
|
|||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |