Package spoon

Interface SpoonModelBuilder

    • Method Detail

      • build

        boolean build()
        Builds the program's model with this compiler's factory and stores the result into this factory. Note that this method should only be used once on a given factory.
        Returns:
        true if the Java was successfully compiled with the core Java compiler, false if some errors were encountered while compiling
        Throws:
        SpoonException - when a building problem occurs
        See Also:
        getSourceClasspath(), getTemplateClasspath()
      • build

        boolean build​(JDTBuilder builder)
        Builds the program's model with this compiler's factory and stores the result into this factory. Note that this method should only be used once on a given factory.
        Parameters:
        builder - Parameters given at JDT compiler.
        Returns:
        true if the Java was successfully compiled with the core Java compiler, false if some errors were encountered while compiling
        Throws:
        SpoonException - when a building problem occurs
        See Also:
        getSourceClasspath(), getTemplateClasspath()
      • compile

        boolean compile​(SpoonModelBuilder.InputType... types)
        Generates the bytecode associated to the classes stored in this compiler's factory. The bytecode is generated in the directory given by getBinaryOutputDirectory(). The array of types must be of size 0 or 1. If it's empty, the types of the factory are compiled. If it's InputType.FILES, the files given as input are compiled. Note that the varargs ... enables this version to be backward compatible for callers.
        See Also:
        getSourceClasspath()
      • instantiateAndProcess

        void instantiateAndProcess​(java.util.List<java.lang.String> processors)
        Takes a list of fully qualified name processors and instantiates them to process the Java model.
      • process

        void process​(java.util.Collection<Processor<? extends CtElement>> processors)
        Processes the Java model with the given processors.
      • generateProcessedSourceFiles

        void generateProcessedSourceFiles​(OutputType outputType)
        Generates the source code associated to the classes stored in this compiler's factory. The source code is generated in the directory given by getSourceOutputDirectory().
        Parameters:
        outputType - the output method
      • generateProcessedSourceFiles

        void generateProcessedSourceFiles​(OutputType outputType,
                                          Filter<CtType<?>> typeFilter)
        Generates the source code associated to the classes stored in this compiler's factory. The source code is generated in the directory given by getSourceOutputDirectory().
        Parameters:
        outputType - the output method
        typeFilter - Filter on CtType to know which type Spoon must print.
      • addInputSource

        void addInputSource​(java.io.File source)
        Adds a file/directory to be built. By default, the files could be Java source files or Jar files. Directories are processed recursively.
        Parameters:
        source - file or directory to add
      • addInputSource

        void addInputSource​(SpoonResource source)
        Adds a file/directory (as a SpoonResource) to be built. By default, the files could be Java source files or Jar files. Directories are processed recursively.
        Parameters:
        source - file or directory to add
      • addInputSources

        void addInputSources​(java.util.List<SpoonResource> resources)
        Adds a list of files/directories (as a SpoonResource to be built. By default, the files could be Java source files of Java files. Directories are processed recursively.
        Parameters:
        resources - files or directories to add.
      • getInputSources

        java.util.Set<java.io.File> getInputSources()
        Gets all the files/directories given as input sources to this builder (see addInputSource(File)).
      • addTemplateSource

        void addTemplateSource​(java.io.File source)
        Adds a file/directory to be used to build templates. By default, the files should be Java source files or Jar files containing the sources. Directories are processed recursively. Templates are set apart from the program to be processed for logical reasons. However, if a template was needed to be processed, it could be added as an input source.
        Parameters:
        source - file or directory to add
      • addTemplateSource

        void addTemplateSource​(SpoonResource source)
        Adds a file/directory (as a SpoonResource) to be used to build templates. By default, the files should be Java source files or Jar files containing the sources. Directories are processed recursively. Templates are set apart from the program to be processed for logical reasons. However, if a template was needed to be processed, it could be added as an input source.
        Parameters:
        source - file or directory to add
      • addTemplateSources

        void addTemplateSources​(java.util.List<SpoonResource> resources)
        Adds a list of files/directories (as a CtResource) to be used to build templates. By default, the files should be Java source files or Jar files containing the sources. Directories are processed recursively. Templates are set apart from the program to be processed for logical reasons. However, if a template was needed to be processed, it could be added as an input source.
        Parameters:
        resources - files or directories to add.
      • getTemplateSources

        java.util.Set<java.io.File> getTemplateSources()
        Gets all the files/directories given as template sources to this builder (see addTemplateSource(File)).
      • getSourceOutputDirectory

        java.io.File getSourceOutputDirectory()
        Gets the output directory of this compiler.
      • setBinaryOutputDirectory

        void setBinaryOutputDirectory​(java.io.File binaryOutputDirectory)
        Sets the output directory for binary generated.
        Parameters:
        binaryOutputDirectory - File for binary output directory.
      • getBinaryOutputDirectory

        java.io.File getBinaryOutputDirectory()
        Gets the binary output directory of the compiler.
      • getSourceClasspath

        java.lang.String[] getSourceClasspath()
        Gets the classpath that is used to build/compile the input sources.
      • setSourceClasspath

        void setSourceClasspath​(java.lang.String... classpath)
        Sets the classpath that is used to build/compile the input sources. Each element of the array is either a jar file or a folder containing bytecode files.
      • getTemplateClasspath

        java.lang.String[] getTemplateClasspath()
        Gets the classpath that is used to build the template sources. See setSourceClasspath(java.lang.String...) for the meaning of the returned string.
      • setTemplateClasspath

        void setTemplateClasspath​(java.lang.String... classpath)
        Sets the classpath that is used to build the template sources.
      • getFactory

        Factory getFactory()
        Returns the working factory
      • removeCompilationUnitFilter

        void removeCompilationUnitFilter​(CompilationUnitFilter filter)
        Removes filter. Does nothing, if filter has not been added beforehand.
        Parameters:
        filter - The CompilationUnitFilter to remove.