PROPOSAL: Extensions to XMIReader and XMIWriter interfaces
Martin Matula <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.mdr.devel |
|---|---|
| Message-ID | <[email protected]> |
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