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 javax.swing.event.EventListenerList;

/** Cluster of compiler objects that actually runs the compilation.
* Should be implemented by a module author in conjunction with {@link Compiler}.
* 

* The group is created by obtaining a class name from * {@link Compiler#compilerGroupClass} * and instantiating it. Then all compilers * that use the same class are added to the group with {@link #add}. *

* The group can assume that everything is prepared for compilation. * It can be invoked by actions to compile, build or * clean. * * @author Jaroslav Tulach */ public abstract class CompilerGroup extends Object { /** listener support */ private EventListenerList listeners; /** Add a compiler to the group. Should absorb all information * contained in the compiler. *

This method is important for module authors, as it should * keep track of the essential data from the compiler added to it, * so that the group knows what files (e.g.) to compile. * * @param c the compiler to consume * @exception IllegalArgumentException if the compiler * does not belong to this group (the group's class is not * assignable to the one returned from {@link Compiler#compilerGroupClass}) */ public abstract void add (Compiler c) throws IllegalArgumentException; /** Start compilation. Should check which files really need to be * compiled and compile only those. The compilation should be synchronous * (i.e. occupy this thread). *

* The compilation should report its progress to status listeners and report * all errors to error listeners. * * @return true if successful, false if the compilation failed */ public abstract boolean start (); /** Add a listener. * @param l the listener to add */ public final synchronized void addCompilerListener (CompilerListener l) { if (listeners == null ) { listeners = new javax.swing.event.EventListenerList(); } listeners.add (org.openide.compiler.CompilerListener.class, l); } /** Remove a listener. * @param l the listener to remove */ public final synchronized void removeCompilerListener (CompilerListener l) { if (listeners == null) return; listeners.remove (org.openide.compiler.CompilerListener.class, l); } /** Fire a progress event to all listeners. * @param ev the event to fire */ protected final void fireProgressEvent (ProgressEvent ev) { if (this.listeners == null) return; Object[] listeners = this.listeners.getListenerList (); for (int i = listeners.length-2; i>=0; i-=2) { if (listeners[i]==org.openide.compiler.CompilerListener.class) { ((org.openide.compiler.CompilerListener)listeners[i+1]).compilerProgress (ev); } } } /** Fires an error event to all listeners. * @param ev the event to fire */ protected final void fireErrorEvent (ErrorEvent ev) { if (this.listeners == null) return; Object[] listeners = this.listeners.getListenerList (); for (int i = listeners.length-2; i>=0; i-=2) { if (listeners[i]==org.openide.compiler.CompilerListener.class) { ((org.openide.compiler.CompilerListener)listeners[i+1]).compilerError (ev); } } } }

... 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.