KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > editor > hyperlink > HyperlinkProviderManager


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
20 package org.netbeans.lib.editor.hyperlink;
21
22 import java.util.List JavaDoc;
23 import org.openide.util.Lookup;
24
25 /**
26  * This class provides a list of HyperlinkProvider(s) for a given mime type.
27  * <br>
28  * This class is first searched in the <code>Lookup</code>. If no implementation
29  * is found then a default implementation {@link DefaultHyperlinkProviderManager}
30  * is constructed.
31  *
32  * Besides the default implementation there is
33  * {@link org.netbeans.modules.editor.hyperlink.LayerHyperlinkProviderManager}
34  * in the editor module (non-library part)
35  * which reads the hyperlink providers for the mime-types
36  * from the xml layer in the System FS.
37  * <br>
38  * These two existing implementations should suffice for most uses.
39  *
40  * @author Jan Lahoda
41  */

42 public abstract class HyperlinkProviderManager {
43     
44     private static HyperlinkProviderManager defaultManager;
45     
46     /**
47      * Find the default hyperlink provider manager in the lookup (or construct
48      * a simple default implementation if not found).
49      *
50      * @return non-null manager.
51      */

52     public static synchronized HyperlinkProviderManager getDefault() {
53         if (defaultManager == null) {
54             defaultManager = createDefault();
55         }
56         return defaultManager;
57     }
58     
59     private static HyperlinkProviderManager createDefault() {
60         HyperlinkProviderManager mgr = (HyperlinkProviderManager)Lookup.getDefault().
61                 lookup(HyperlinkProviderManager.class);
62
63         if (mgr == null) { // not found in lookup -> use default
64
mgr = new DefaultHyperlinkProviderManager();
65         }
66         return mgr;
67     }
68     
69     /**
70      * Provide List of HyperlinkProvider(s) for a given mime type.
71      *
72      * @param mimeType mime type to test
73      * @param List of HyperlinkProvider(s) for a given mime type.
74      */

75     public abstract List JavaDoc/*<HyperlinkProvider>*/ getHyperlinkProviders(String JavaDoc mimeType);
76     
77 }
78
Popular Tags