KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > enode > ExtensibleLookup


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 Nokia. Portions Copyright 2003-2004 Nokia.
17  * All Rights Reserved.
18  */

19
20 package org.netbeans.api.enode;
21
22 import org.openide.ErrorManager;
23 import org.openide.util.Lookup;
24
25 import org.netbeans.modules.enode.ExtensibleLookupImpl;
26
27 /**
28  * Special lookup capable of reading its content from the system
29  * file system. The lookup is bound to an instance of ExtensibleNode.
30  * @author David Strupl
31  */

32 public class ExtensibleLookup extends Lookup {
33
34     /**
35      * As the implementation is "hidden" from the API this
36      * is a reference to an object with real implementation.
37      */

38     private ExtensibleLookupImpl impl;
39
40     /**
41      * Node to which this lookup is bound.
42      */

43     private ExtensibleNode myNode;
44     
45     /**
46      * This public constructor needs an ExtensibleNode as paramater.
47      * The path is to the objects found by this lookup is computed from
48      * the result of calling method ExtensibleNode.getPath() on the
49      * associated node.
50      */

51     public ExtensibleLookup(ExtensibleNode en) {
52         myNode = en;
53     }
54     
55     /**
56      * The default constructor - you have to call setNode to pass ExtensibleNode
57      * instance for the lookup to know from where to take the objects.
58      */

59     public ExtensibleLookup() {
60     }
61     
62     /**
63      * Associates the lookup object with the node.
64      */

65     public void setNode(ExtensibleNode en) {
66         myNode = en;
67         if (impl != null) {
68             impl.setExtensibleNode(myNode);
69         }
70     }
71     
72     /**
73      *
74      */

75     public Object JavaDoc lookup(Class JavaDoc clazz) {
76         initializeImpl();
77         return impl.lookup(clazz);
78     }
79     
80     /**
81      *
82      */

83     public Result lookup(Template template) {
84         initializeImpl();
85         return impl.lookup(template);
86     }
87     
88     /**
89      * Lazy initialization of the implementation reference.
90      */

91     private void initializeImpl() {
92         if (impl == null) {
93             impl = new ExtensibleLookupImpl();
94             impl.setExtensibleNode(myNode);
95         }
96     }
97     
98 }
99
Popular Tags