RE: PROPOSAL: Extensions to XMIReader and XMIWriter interfaces
"Vries, Michiel de" <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.mdr.devel |
|---|---|
| Message-ID | <D913221A882FD31198D90008C75D6909070705C3@cwnl-ams-pri01.nl.compuware.com> |
Hi Martin, The issues which we see are the following: - the HRefResolver needs to receive a little bit more information: we need to have the type of the object to be resolved. This to be able to create a placeholder for the object. - for reading we would like to have the xmi writer to write the most specific type to the output file, because in that case the reader knows the actual type for which a placeholder needs to be created. - for writing we need to have a link to the refObject and a String representing the current filename. In that way you can distinguish if the refObject needs to be in a different filename than the current one. Regards, Michiel. > -----Original Message----- > From: Martin Matula [mailto:[email protected]] > Sent: Wednesday, July 24, 2002 2:23 PM > To: [email protected] > Subject: PROPOSAL: Extensions to XMIReader and XMIWriter interfaces > > > Hi, > we would like to hear your comments on the following changes we would > like to make to the XMI API: > > 1) In XMI writter there is a need for being able to split XMI output > into several files. To make this possible, we would like to add the > following interface to MDR API: > > public interface XMIReferenceProvider { > /** Method called by XMIWriter whenever it needs to serialize > * given object or a reference to it. If the returned reference > * is not href, it will be used as xmi.id of that element > * and wherever the element is referenced, simple xmi.idref > * with this xmi.id will be generated. If the returned reference > * represents href, object will not be serialized and wherever > * it is referenced, href will be generated. > * @param object Object to be serialized (or referenced). > * @return Structure representing reference to the object. > */ > public XMIReference getXMIReference(RefObject object); > > /** Simple structure for representing XMI references to elements > * corresponding to an object. > */ > public static class XMIReference { > private final boolean href; > private final String reference; > > /** Represents XMI reference to an element > * @param reference Either xmi.id or href to an element. > * @param href Indicates that the reference > parameter contains > * href rather than xmi.id > */ > public XMIReference(String reference, boolean href) { > this.reference = reference; > this.href = href; > } > > /** Returns <code>true</code> if this object > * represents href rather than xmi.id. > * @return <code>true</code> if this object > * represents href. > */ > public boolean isHRef() { > return href; > } > > /** Returns xmi.id or href depending > * on what this object represents. > * @return xmi.id or href > public String getReference() { > return reference; > } > } > } > > Extend XMIWriter interface by adding the same write methods that it > already has but with additional parameter of type > XMIReferenceProvider. > > 2) Another thing that we would like to have is ability to > serialize more > RefPackages into one XMI file. This can be achieved by adding another > write methods that take RefPackage[] rather than RefPackage as a > parameter, or we can reuse method taking collection for this purpose. > Since it is not clear from the JMI spec. if objects other > than RefObject > can be passed to this method, I would rather go with the first option > (it is symetric with the read method we have added to XMIReader). > > 3) We would like to extend the XMIReader API by adding the following > interface: > > public interface HRefResolver { > /** > * Resolves external reference and returns correspondend object. > * > * @param baseURI URI of the document where href is used. > * This parameter is provided only if it is known by XMI Reader, > * otherwise <code>null</code> is passed. > * @param href Href reference to be resolved. > * > * @return Resolved instance or <code>null</code> if the instance > * should be resolved in a default way by XMIReader itself. > * > * @throws MalformedJMIException Thrown > * to indicate an error (element cannot be resolved, etc.) > */ > public RefObject resolve(String baseURI, String href) throws > MalformedXMIException; > } > > Extend XMIReader interface by adding the same read methods that it > already has but with additional parameter of type HRefResolver. > > Any comments are very welcome. > Martin > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > -- The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.