站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

XMIReferenceResolver (NetBeans MDR API) - NetBeans API Javadoc 5.0.0

 

org.netbeans.api.xmi
Interface XMIReferenceResolver


public interface 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. If an XMIReferenceResolver is registered for an XMI consumer, the XMI consumer will call register(java.lang.String, java.lang.String, javax.jmi.reflect.RefObject) for each object that it successfuly deserialized from the XMI file. At the end of the document the XMI consumer will call resolve(org.netbeans.api.xmi.XMIReferenceResolver.Client, javax.jmi.reflect.RefPackage, java.lang.String, org.netbeans.api.xmi.XMIInputConfig, java.util.Collection) passing all the hrefs found in the document and an object that implements XMIReferenceResolver.Client to receive callbacks. Implementation of XMIReferenceResolver should try to resolve these hrefs and make callbacks to the passed client (by calling XMIReferenceResolver.Client.resolvedReference(java.lang.String, javax.jmi.reflect.RefObject)) for each resolved href.

Note, that in some obscure cases, the XMI consumer may call register(java.lang.String, java.lang.String, javax.jmi.reflect.RefObject) method even during the execution of XMIReferenceResolver.Client.resolvedReference(java.lang.String, javax.jmi.reflect.RefObject) method in case when XMI consumer had to postpone creation of some object because of unresolved reference to an object within an attribute (i.e. if an unresolved object was part of an attribute value). IMPORTANT: During the whole XMI reading, the XMI consumer should hold a lock on the used XMIReferenceResolver instance to avoid concurrency problems.


Nested Class Summary
static interface XMIReferenceResolver.Client
           
 
Method Summary
 void register(String systemId, String xmiId, javax.jmi.reflect.RefObject object)
          Registers an object that can be resolved.
 void resolve(XMIReferenceResolver.Client client, javax.jmi.reflect.RefPackage extent, String systemId, XMIInputConfig configuration, Collection hrefs)
          Resolves external references and calls XMIReferenceResolver.Client.resolvedReference(java.lang.String, javax.jmi.reflect.RefObject) for each.
 

Method Detail

register

public void register(String systemId,
                     String xmiId,
                     javax.jmi.reflect.RefObject object)
Registers an object that can be resolved. This method should be called by XMI consumer each time it successfuly deserializes an object from XMI, given that the object was assigned an xmiId (for objects that do not have xmiId defined in XMI file this method should not be called).

Implementation of this interface should remember all the registered objects and use them for resolving hrefs.

Parameters:
systemId - URI of the document that called this method (the URI is essential for correct resolution of cyclic and relative references).
xmiId - XMI ID of the object deserialized from XMI. If XMI ID for the object is not available, this method should not be called.
object - Object deserialized from XMI.

resolve

public void resolve(XMIReferenceResolver.Client client,
                    javax.jmi.reflect.RefPackage extent,
                    String systemId,
                    XMIInputConfig configuration,
                    Collection hrefs)
             throws javax.jmi.xmi.MalformedXMIException,
                    IOException
Resolves external references and calls XMIReferenceResolver.Client.resolvedReference(java.lang.String, javax.jmi.reflect.RefObject) for each. Before returning from this method (only in case of outermost call to it - i.e. this does not hold for nested recursive calls from XMI consumers created from within this method) the instance of this class should be restored to its initial state (all registered references should be forgotten).

Parameters:
client - Implementation of callback method used for reference resolving notifications.
extent - Target package (for resolved objects).
systemId - URI of the document where href is used. This parameter is provided only if it is known by XMI consumer, otherwise null is passed.
configuration - Configuration to be used for XMI consumer used for reading external XMI document to resolve the href (if needed).
hrefs - References to be resolved.
Throws:
javax.jmi.xmi.MalformedXMIException - Thrown to indicate an error (element cannot be resolved, etc.)
IOException - I/O error during XMI reading.

 

Built on May 3 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.