org.openide.compiler
Class ExternalCompiler

java.lang.Object
  |
  +--org.openide.compiler.Compiler
        |
        +--org.openide.compiler.ExternalCompiler
All Implemented Interfaces:
Compilable

public class ExternalCompiler
extends Compiler

Compiles (probably Java) sources via an external compiler process. The path to the executable, classpath, error-matching expressions, etc. are configurable.


Inner Class Summary
static class ExternalCompiler.ErrorExpression
          Encapsulates several properties needed for processing the error output of an external compiler.
 
Inner classes inherited from class org.openide.compiler.Compiler
Compiler.Depth
 
Field Summary
static Object BUILD
          Constant for building.
protected static String CLASS_EXTENSION
          File extension for class files.
static Object CLEAN
          Constant for cleaning.
static Object COMPILE
          Constant for compilation.
static ExternalCompiler.ErrorExpression JAVAC
          Error parsing for Sun's Javac.
static ExternalCompiler.ErrorExpression JIKES
          Error parsing for IBM's Jikes (with the +E switch).
static ExternalCompiler.ErrorExpression JVC
          Error parsing for Microsoft's JVC.
 
Fields inherited from class org.openide.compiler.Compiler
DEPTH_INFINITE, DEPTH_ONE, DEPTH_ZERO
 
Fields inherited from interface org.openide.compiler.Compilable
MUTEX
 
Constructor Summary
ExternalCompiler(Compiler[] dependencies, FileObject fo, Object type, NbProcessDescriptor nbDescriptor, ExternalCompiler.ErrorExpression err)
          Create an external compiler with dependencies.
ExternalCompiler(CompilerJob job, FileObject fo, Object type, NbProcessDescriptor nbDescriptor, ExternalCompiler.ErrorExpression err)
          Create an external compiler.
ExternalCompiler(File file, Object type, NbProcessDescriptor nbDescriptor, ExternalCompiler.ErrorExpression err)
          Create an external compiler for a given java.io.File.
ExternalCompiler(FileObject fo, Object type, NbProcessDescriptor nbDescriptor, ExternalCompiler.ErrorExpression err)
          Create an external compiler.
ExternalCompiler(FileSystem fs, String resourceName, Object type, NbProcessDescriptor nbDescriptor, ExternalCompiler.ErrorExpression err)
          Create an external compiler for an object in repository that still does not exists.
ExternalCompiler(String resourceName, Object type, NbProcessDescriptor nbDescriptor, ExternalCompiler.ErrorExpression err)
          Create an external compiler for an object in repository need not exist in present.
 
Method Summary
 Class compilerGroupClass()
          Get the associated CompilerGroup container class.
 Object compilerGroupKey()
          Produce a refined key for external compilers.
protected  Object compilerType()
          Deprecated. While subclassing this method and specifying a type will still work, it is no longer recommended. Instead, please use Compiler.compilerGroupKey() and make all compiler-specific state available to the compiler group via other means (such as getter methods).
 boolean equals(Object o)
          Two external compilers are the same if they have been constructed with the same arguments.
 NbProcessDescriptor getCompilerDescriptor()
          Get the description of the compiler executable.
 ExternalCompiler.ErrorExpression getErrorExpression()
          Get the error expression used to parse error output from this compiler.
 String getFileName()
          Get the name of the file to be compiled.
protected  FileObject getFileObject()
          Get the file object to be compiled
 int hashCode()
           
protected  boolean isUpToDate()
          Check whether the compiler is up to date.
 String toString()
           
 
Methods inherited from class org.openide.compiler.Compiler
compilers, dependsOn, dependsOn, dependsOn
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

JAVAC

public static final ExternalCompiler.ErrorExpression JAVAC
Error parsing for Sun's Javac.

JVC

public static final ExternalCompiler.ErrorExpression JVC
Error parsing for Microsoft's JVC.

JIKES

public static final ExternalCompiler.ErrorExpression JIKES
Error parsing for IBM's Jikes (with the +E switch).

COMPILE

public static final Object COMPILE
Constant for compilation.

BUILD

public static final Object BUILD
Constant for building.

CLEAN

public static final Object CLEAN
Constant for cleaning. Not supported by this class however.

CLASS_EXTENSION

protected static final String CLASS_EXTENSION
File extension for class files.
Constructor Detail

ExternalCompiler

public ExternalCompiler(FileObject fo,
                        Object type,
                        NbProcessDescriptor nbDescriptor,
                        ExternalCompiler.ErrorExpression err)
Create an external compiler.
Parameters:
fo - a file to compile
type - the type of compilation (COMPILE or BUILD)
nbDescriptor - a description of an external compiler executable
err - a regular expression to scan for compiler errors
Throws:
IllegalArgumentException - if the file object is invalid

ExternalCompiler

public ExternalCompiler(CompilerJob job,
                        FileObject fo,
                        Object type,
                        NbProcessDescriptor nbDescriptor,
                        ExternalCompiler.ErrorExpression err)
Create an external compiler.
Parameters:
job - the compiler job to add to
fo - a file to compile
type - the type of compilation (COMPILE or BUILD)
nbDescriptor - a description of an external compiler executable
err - a regular expression to scan for compiler errors
Throws:
IllegalArgumentException - if the file object is invalid

ExternalCompiler

public ExternalCompiler(Compiler[] dependencies,
                        FileObject fo,
                        Object type,
                        NbProcessDescriptor nbDescriptor,
                        ExternalCompiler.ErrorExpression err)
Create an external compiler with dependencies.
Parameters:
dependencies - an array of compilers that are to be invoked before this one.
fo - a file to compile
type - the type of compilation (COMPILE or BUILD)
nbDescriptor - a description of an external compiler executable
err - a regular expression to scan for compiler errors
Throws:
IllegalArgumentException - if the file object is invalid

ExternalCompiler

public ExternalCompiler(File file,
                        Object type,
                        NbProcessDescriptor nbDescriptor,
                        ExternalCompiler.ErrorExpression err)
Create an external compiler for a given java.io.File.
Parameters:
file - the file to compile
type - the type of compilation (COMPILE or BUILD)
nbDescriptor - a description of an external compiler executable
err - a regular expression to scan for compiler errors

ExternalCompiler

public ExternalCompiler(FileSystem fs,
                        String resourceName,
                        Object type,
                        NbProcessDescriptor nbDescriptor,
                        ExternalCompiler.ErrorExpression err)
Create an external compiler for an object in repository that still does not exists.
Parameters:
fs - file system to look on for resource
resourceName - the name of resource to look for
type - the type of compilation (COMPILE or BUILD)
nbDescriptor - a description of an external compiler executable
err - a regular expression to scan for compiler errors

ExternalCompiler

public ExternalCompiler(String resourceName,
                        Object type,
                        NbProcessDescriptor nbDescriptor,
                        ExternalCompiler.ErrorExpression err)
Create an external compiler for an object in repository need not exist in present. Looks on all filesystems.
Parameters:
resourceName - the name of resource to look for
type - the type of compilation (COMPILE or BUILD)
nbDescriptor - a description of an external compiler executable
err - a regular expression to scan for compiler errors
Method Detail

getCompilerDescriptor

public final NbProcessDescriptor getCompilerDescriptor()
Get the description of the compiler executable.
Returns:
the descriptor

getErrorExpression

public final ExternalCompiler.ErrorExpression getErrorExpression()
Get the error expression used to parse error output from this compiler.
Returns:
the error expression

getFileObject

protected final FileObject getFileObject()
Get the file object to be compiled
Returns:
the file object (can be null if constructor without file object argument has been used and the file object does not exists)

getFileName

public String getFileName()
Get the name of the file to be compiled.
Returns:
the file name

isUpToDate

protected boolean isUpToDate()
Description copied from class: Compiler
Check whether the compiler is up to date. This method is called from CompilerJob.isUpToDate() to skip a compilation when it is unnecessary.
Overrides:
isUpToDate in class Compiler
Following copied from class: org.openide.compiler.Compiler
Returns:
true if up-to-date; false if compilation is needed

toString

public String toString()
Overrides:
toString in class Object

compilerGroupClass

public Class compilerGroupClass()
Description copied from class: Compiler
Get the associated CompilerGroup container class. The compiler and compiler group should typically be implemented in parallel, though it is possible to subclass a compiler without subclassing the compiler group. The compiler group must be "expecting" a compiler of this class (or a superclass), or else it is free to fail in an unspecified way. All instances of the same compiler class must return the same result from this method.
Overrides:
compilerGroupClass in class Compiler
Returns:
ExternalCompilerGroup

compilerType

protected Object compilerType()
Deprecated. While subclassing this method and specifying a type will still work, it is no longer recommended. Instead, please use Compiler.compilerGroupKey() and make all compiler-specific state available to the compiler group via other means (such as getter methods).

Identifier for type of compiler. This method allows subclasses to specify the type this compiler belongs to. Compilers that belong to the same class will be compiled together by one external process.

It is necessary for all compilers of the same type to have same process descriptor and error expression.

This implementation returns the process descriptor, so all compilers with the same descriptor will be compiled at once.

Note that this method has no relation to CompilerTypes; the name is incidental.

Returns:
key to define type of the compiler
See Also:
ExternalCompilerGroup.createProcess(org.openide.execution.NbProcessDescriptor, java.lang.String[], java.lang.Object)

compilerGroupKey

public Object compilerGroupKey()
Produce a refined key for external compilers. Groups not only by the compiler group class, but by the result of compilerType() as well, and also by the error description. Specialized external compilers are encouraged to override this method directly according to the contract specified in Compiler.compilerGroupKey().
Overrides:
compilerGroupKey in class Compiler
Returns:
a composite key

equals

public boolean equals(Object o)
Two external compilers are the same if they have been constructed with the same arguments. If one has been constructed with the java.io.File argument and second with resource name then they are different.
Overrides:
equals in class Object
Following copied from interface: org.openide.compiler.Compilable
Parameters:
other - the other object
Returns:
true if both look like equal

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.