001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.spi.editor.mimelookup;
043:
044: import org.openide.util.Lookup;
045:
046: /**
047: * Provides an initialization of MimeLookup on either global or mime-type
048: * specific level.
049: * <br>
050: * The implementations of this class should be registed to default lookup by
051: * <a href="http://openide.netbeans.org/lookup/index.html"> META-INF/services registration</a>.
052: * <br>
053: * Such registered instance serves as a global level initializer
054: * which can further be asked for children by {@link #child(String)}
055: * which will lead to forming of a tree initializers hierarchy.
056: * <br>
057: * The contents provided by {@link #lookup()} of the global-level initializer
058: * (the one registered in the layer) will automatically appear
059: * in all the results returned by <code>MimeLookup</code> for any particular mime type.
060: * <br>
061: * Once someone asks for a <code>MimeLookup</code> for a specific mime-type
062: * by using {@link org.netbeans.api.editor.mimelookup.MimeLookup#getMimeLookup(String)}
063: * the global level initializer will be asked for {@link #child(String)}
064: * and the {@link #lookup()} on the returned children
065: * will define the result data (together with the global-level initializer's lookup).
066: * <br>
067: * This process can be arbitrarily nested for embedded mime-types.
068: *
069: * <p>
070: * An example implementation of MimeLookupInitializer
071: * that works over xml layer file system can be found at mime lookup module
072: * implementation <a href="http://editor.netbeans.org/source/browse/editor/mimelookup/src/org/netbeans/modules/editor/mimelookup/Attic/LayerMimeLookupImplementation.java">LayerMimeLookupInitializer</a>
073: *
074: * @author Miloslav Metelka, Martin Roskanin
075: * @deprecated Use {@link MimeDataProvider} instead.
076: */
077: @Deprecated
078: public interface MimeLookupInitializer {
079:
080: /**
081: * Lookup providing mime-type sensitive or global-level data
082: * depending on which level this initializer is defined.
083: *
084: * @return Lookup or null, if there are no lookup-able objects for mime or global level.
085: */
086: Lookup lookup();
087:
088: /**
089: * Retrieves a Lookup.Result of MimeLookupInitializers for the given sub-mimeType.
090: *
091: * @param mimeType mime-type string representation e.g. "text/x-java"
092: * @return non-null lookup result of MimeLookupInitializer(s).
093: * <br/>
094: * Typically there should be just one child initializer although if there
095: * will be more than one all of them will be taken into consideration.
096: * <br/>
097: * If there will be no specific initializers for the particular mime-type
098: * then an empty result should be returned.
099: */
100: Lookup.Result<MimeLookupInitializer> child(String mimeType);
101:
102: }
|