KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > xmi > XMIReferenceProvider


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.api.xmi;
20
21 import javax.jmi.reflect.RefObject;
22
23 /** Implementation of this interface can be passed to XMI producers/writers
24  * (using {@link XMIOutputConfig#setReferenceProvider} method) to enable custom controling of
25  * target documents the written object should go into and what XMI ID they should use.
26  * If an XMI producer supports this property, it will call {@link #getReference} method for each
27  * RefObject to be written into the document and either use the XMI ID returned (if
28  * the object should reside in the same document) or serialize only a href to the
29  * object (if it resides in a different XMI document).
30  *
31  * @author Martin Matula
32  */

33 public interface XMIReferenceProvider {
34     /** Method called by XMI producer for each object that is serialized or
35      * referenced from the generated XMI document. If the returned reference
36      * points to the same document as being written, xmi.id part of the returned
37      * reference will be used
38      * and wherever the element is referenced, simple xmi.idref
39      * with this xmi.id will be generated. If the returned reference
40      * points to a different file, href will be generated.
41      * Format of the generated href should be result of the following:
42      * <p><code>getDocumentURI() + "#" + getXmiId()</code></p>
43      * @param object Object to be serialized (or referenced).
44      * @return Structure representing reference to the object.
45      */

46     public XMIReference getReference(RefObject object);
47
48     /** Simple structure for representing XMI references to elements
49      * corresponding to an object.
50      */

51     public static final class XMIReference {
52         private final String JavaDoc systemId;
53         private final String JavaDoc xmiId;
54
55         /** Creates a new instance of XMIReference.
56          * @param systemId URI of the home document for the object.
57          * @param xmiId xmi.id of the object.
58          */

59         public XMIReference(String JavaDoc systemId, String JavaDoc xmiId) {
60             this.systemId = systemId;
61             this.xmiId = xmiId;
62         }
63
64         /** Returns URI (system ID) of the home document for the object.
65          * This method can return <code>null</code> which means that the
66          * XMIReferenceProvider does not control what file the object should go to,
67          * thus the writer should write it to the document that is being produced.
68          * @return Document URI
69          */

70         public String JavaDoc getSystemId() {
71             return systemId;
72         }
73         
74         /** Returns XMI ID for the object.
75          * @return xmi.id
76          */

77         public String JavaDoc getXmiId() {
78             return xmiId;
79         }
80     }
81 }
82
Popular Tags