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.spi.editor.mimelookup; 21 22 import org.openide.util.Lookup; 23 24 /** 25 * Provides an initialization of MimeLookup on either global or mime-type 26 * specific level. 27 * <br> 28 * The implementations of this class should be registed to default lookup by 29 * <a HREF="http://openide.netbeans.org/lookup/index.html"> META-INF/services registration</a>. 30 * <br> 31 * Such registered instance serves as a global level initializer 32 * which can further be asked for children by {@link #child(String)} 33 * which will lead to forming of a tree initializers hierarchy. 34 * <br> 35 * The contents provided by {@link #lookup()} of the global-level initializer 36 * (the one registered in the layer) will automatically appear 37 * in all the results returned by <code>MimeLookup</code> for any particular mime type. 38 * <br> 39 * Once someone asks for a <code>MimeLookup</code> for a specific mime-type 40 * by using {@link org.netbeans.api.editor.mimelookup.MimeLookup#getMimeLookup(String)} 41 * the global level initializer will be asked for {@link #child(String)} 42 * and the {@link #lookup()} on the returned children 43 * will define the result data (together with the global-level initializer's lookup). 44 * <br> 45 * This process can be arbitrarily nested for embedded mime-types. 46 * 47 * <p> 48 * An example implementation of MimeLookupInitializer 49 * that works over xml layer file system can be found at mime lookup module 50 * implementation <a HREF="http://editor.netbeans.org/source/browse/editor/mimelookup/src/org/netbeans/modules/editor/mimelookup/Attic/LayerMimeLookupImplementation.java">LayerMimeLookupInitializer</a> 51 * 52 * @author Miloslav Metelka, Martin Roskanin 53 * @deprecated Use {@link MimeDataProvider} instead. 54 */ 55 public interface MimeLookupInitializer { 56 57 /** 58 * Lookup providing mime-type sensitive or global-level data 59 * depending on which level this initializer is defined. 60 * 61 * @return Lookup or null, if there are no lookup-able objects for mime or global level. 62 */ 63 Lookup lookup(); 64 65 /** 66 * Retrieves a Lookup.Result of MimeLookupInitializers for the given sub-mimeType. 67 * 68 * @param mimeType mime-type string representation e.g. "text/x-java" 69 * @return non-null lookup result of MimeLookupInitializer(s). 70 * <br/> 71 * Typically there should be just one child initializer although if there 72 * will be more than one all of them will be taken into consideration. 73 * <br/> 74 * If there will be no specific initializers for the particular mime-type 75 * then an empty result should be returned. 76 */ 77 Lookup.Result child(String mimeType); 78 79 } 80