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-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.openide.compiler;


import org.openide.execution.*;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject;
import org.openide.util.NbBundle;

/** Compiler type that compiles using ExternalCompiler.
* Compile and build cookies are supported.
*
* @author Jaroslav Tulach
*/
public class ExternalCompilerType extends CompilerType {

    private static final long serialVersionUID = -4934327582488427081L;

    /** property identifying the external compiler */
    public static final String PROP_EXTERNAL_COMPILER = "externalCompiler"; // NOI18N
    /** property identifying external compiler output format */
    public static final String PROP_ERROR_EXPRESSION = "errorExpression"; // NOI18N

    private static final NbProcessDescriptor DEFAULT_DESCRIPTOR = new NbProcessDescriptor(
                "{" + ExternalCompilerGroup.Format.TAG_JDKHOME + "}{" + // NOI18N
                ExternalCompilerGroup.Format.TAG_SEPARATOR + "}bin{" + ExternalCompilerGroup.Format.TAG_SEPARATOR + "}javac", // NOI18N
                "-classpath {" + ExternalCompilerGroup.Format.TAG_REPOSITORY + "}{" + ExternalCompilerGroup.Format.TAG_PATHSEPARATOR + "}" + // NOI18N
                "{" + ExternalCompilerGroup.Format.TAG_CLASSPATH + "}{" + ExternalCompilerGroup.Format.TAG_PATHSEPARATOR + "}" + // NOI18N
                "{" + ExternalCompilerGroup.Format.TAG_LIBRARY + "}{" + ExternalCompilerGroup.Format.TAG_PATHSEPARATOR + "}" + // NOI18N
                "{" + ExternalCompilerGroup.Format.TAG_BOOTCLASSPATH + "} " + // NOI18N
                "{" + ExternalCompilerGroup.Format.TAG_FILES + "}", // NOI18N
                NbBundle.getBundle (ExternalCompilerGroup.class).getString ("MSG_ExternalCompilerHint")
            );

    /** the descriptor to use for execution */
    private NbProcessDescriptor nbDescriptor = DEFAULT_DESCRIPTOR;
    /** error expression parser */
    private ExternalCompiler.ErrorExpression err = ExternalCompiler.JAVAC;

    /** Constructor */
    public ExternalCompilerType () {
    }

    /** Getter for process descriptor describing the compiler.
    */
    public NbProcessDescriptor getExternalCompiler () {
        return nbDescriptor;
    }

    /** Setter for process descriptor describing the compiler.
    */
    public void setExternalCompiler (NbProcessDescriptor nb) {
        NbProcessDescriptor old = nbDescriptor;
        nbDescriptor = nb;
        firePropertyChange (PROP_EXTERNAL_COMPILER, old, nb);
    }

    /** Changes error expression.
    */
    public void setErrorExpression (ExternalCompiler.ErrorExpression ee) {
        ExternalCompiler.ErrorExpression old = err;
        err = ee;
        firePropertyChange (PROP_ERROR_EXPRESSION, old, ee);
    }

    /** Getter for current error expression.
    */
    public ExternalCompiler.ErrorExpression getErrorExpression () {
        return err;
    }

    /** Starts the compilation.
    */
    public void prepareJob(CompilerJob job, Class type, DataObject obj) {
        if (type != ExternalCompiler.COMPILE && type != ExternalCompiler.BUILD)
            return;

        FileObject fo = obj.getPrimaryFile ();

        // adds the compiler to the job
        new ExternalCompiler(
                                 job, fo, type, nbDescriptor, err
                             );
    }

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