alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.openide.compiler;

import java.util.*;

import org.openide.ServiceType;
import org.openide.loaders.DataObject;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;

/** Base class defining method for compilation service.
*
* @author Jaroslav Tulach
*/
public abstract class CompilerType extends ServiceType {
    static final long serialVersionUID =-5093377800217789288L;

    public HelpCtx getHelpCtx () {
        return new HelpCtx (CompilerType.class);
    }

    /** Prepare a data object for compilation.
    * Implementations should create an instance of a
    * suitable subclass of {@link Compiler}, passing
    * the compiler job to the constructor so that the job may
    * register the compiler.
    *
    * @param job compiler job to add compilers to
    * @param type the type of compilation task to manage
    * ({@link org.openide.cookies.CompilerCookie.Compile}, etc.)
    * @param obj data object to prepare for compilation
    */
    public abstract void prepareJob (CompilerJob job, Class type, DataObject obj);

    /** Get all registered compilers.
    * @return enumeration of CompilerTypes
    * @deprecated Please use {@link org.openide.util.Lookup} instead.
    */
    public static Enumeration compilerTypes () {
        return Collections.enumeration(Lookup.getDefault().lookup(new Lookup.Template(CompilerType.class)).allInstances());
    }

    /** Find the
    * compiler type implemented as a given class, among the services registered to the
    * system.
    * 

* This should be used during (de-)serialization * of the specific compiler type for a data object: only store its class name * and then try to find the compiler implemented by that class later. * * @param clazz the class of the compiler type looked for * @return the desired compiler type or null if it does not exist * @deprecated Please use {@link org.openide.util.Lookup} instead. */ public static CompilerType find (Class clazz) { return (CompilerType)Lookup.getDefault().lookup(clazz); } /** Find the * compiler with requested name, among the services registered to the * system. *

* This should be used during (de-)serialization * of the specific compiler type for a data object: only store its name * and then try to find the debugger later. * * @param name (display) name of compiler to find * @return the desired compiler or null if it does not exist */ public static CompilerType find (String name) { ServiceType t = ((ServiceType.Registry)Lookup.getDefault().lookup(ServiceType.Registry.class)).find (name); if (t instanceof CompilerType) { return (CompilerType)t; } else { return null; } } /** Gets the default compiler type in the system. * @deprecated This is probably useless since compiler types normally apply * to specific data object types, so no single compiler would be * useful in all circumstances. */ public static CompilerType getDefault () { Enumeration en = compilerTypes (); return en.hasMoreElements()? (CompilerType)en.nextElement (): NoCompiler.getInstance(); } }

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.