Class JavaProject

java.lang.Object
org.jtool.srcmodel.JavaProject

public class JavaProject extends Object
An object representing a project that contains source files to be analyzed.
  • Field Details

    • name

      protected final String name
      The name of this project.
    • pathInWorkspace

      protected String pathInWorkspace
      The absolute path string that indicates the root directory of this project relative to the workspace.
    • path

      protected String path
      The absolute path string that indicates the root directory of this project in the file system.
    • topPath

      protected String topPath
      The absolute path string that indicates the root directory of the top project enclosing this project in the file system.
    • fileStore

      protected Map<String,JavaFile> fileStore
      The map paths and source files corresponding to the paths.
    • packageStore

      protected Map<String,JavaPackage> packageStore
      The map between package names and their corresponding packages.
    • classStore

      protected Map<String,JavaClass> classStore
      The map between the fully-qualified names and their corresponding classes.
    • externalClassStore

      protected Map<String,JavaClass> externalClassStore
      The map between the fully-qualified names and their corresponding classes not having their files.
    • classPath

      protected String[] classPath
      The collection of class paths that store class files for this project.
    • sourcePath

      protected String[] sourcePath
      The collection of class paths that store source files for this project.
    • binaryPath

      protected String[] binaryPath
      The collection of class paths that store binary files for this project.
    • compilerSourceVersion

      protected String compilerSourceVersion
      The version of the compiler source.
    • compilerTargetVersion

      protected String compilerTargetVersion
      The the version of the compiler target platform.
    • cfgStore

      protected final org.jtool.cfg.internal.CFGStore cfgStore
      A CFG repository that stores CFGs for source files for this project.
    • pdgStore

      protected final org.jtool.pdg.internal.PDGStore pdgStore
      A PDG repository that stores PDGs for source files for this project.
  • Constructor Details

    • JavaProject

      public JavaProject(String name, String path, String topPath)
      Creates a project that stores source files and their related information.
      Parameters:
      name - the name of this project
      path - the absolute path that indicates the root directory of this project in the file system
      topPath - the absolute path string that indicates the root directory of the top project enclosing this project
    • JavaProject

      public JavaProject(String name, String wpath, String path, String topPath)
      Creates a project that stores source files and their related information.
      Parameters:
      name - the name of this project
      wpath - the absolute path that indicates the root directory of this project relative to the workspace
      path - the absolute path that indicates the root directory of this project in the file system
      topPath - the absolute path string that indicates the root directory of the top project enclosing this project
    • JavaProject

      public JavaProject(String name, String wpath, String path, String topPath, org.jtool.cfg.internal.CFGStore cfgStore, org.jtool.pdg.internal.PDGStore pdgStore)
      Creates a project that stores source files and their related information.
      Parameters:
      name - the name of this project
      wpath - the absolute path that indicates the root directory of this project relative to the workspace
      path - the absolute path that indicates the root directory of this project in the file system
      topPath - the absolute path string that indicates the root directory of the top project enclosing this project
      cfgStore - a CFG repository that stores CFGs for source files for this project
      pdgStore - a PDG repository that stores PDGs for source files for this project.
  • Method Details

    • setModelBuilder

      public void setModelBuilder(ModelBuilder modelBuilder)
      Sets a model builder that creates Java models in this project.
      Parameters:
      modelBuilder - the model builder
    • getModelBuilder

      public ModelBuilder getModelBuilder()
      Return the model builder that creates Java models in this project.
      Returns:
      the model builder
    • getModelBuilderImpl

      public org.jtool.jxplatform.project.ModelBuilderImpl getModelBuilderImpl()
      Return the model builder implementation that creates Java models in this project.
      Returns:
      the model builder implementation
    • getAllProjects

      public static List<JavaProject> getAllProjects()
      Returns the collection of all projects.
      Returns:
      the collection of all the projects that were already analyzed
    • findProject

      public static JavaProject findProject(String path)
      Finds a project of interest
      Parameters:
      path - the absolute path of the project to be retrieved
      Returns:
      the found project, or null if there is no project related to the path
    • clear

      public void clear()
      Clears information on this project.
    • getName

      public String getName()
      Returns the name of this project.
      Returns:
      the project name
    • getPathRelativeToWorkspace

      public String getPathRelativeToWorkspace()
      Returns the path string that indicates the root directory of this project relative to the workspace.
      Returns:
      the relative path of this project, or the absolute path when there is no workspace
    • getPath

      public String getPath()
      Returns the path string that indicates the root directory of this project in the file system.
      Returns:
      the absolute path of this project
    • getTopPath

      public String getTopPath()
      Returns the path string that indicates the root directory of the top project enclosing this project in the file system.
      Returns:
      the absolute path of the top project
    • removeFile

      public void removeFile(String path)
      Removes a file from this project. This method is not intended to be invoked by clients.
      Parameters:
      path - the path of a file to be removed
    • getFile

      public JavaFile getFile(String path)
      Obtains the source file located at a given absolute path.
      Parameters:
      path - the absolute path of the file in the file system
      Returns:
      the found source file, null if no file is found
    • getFiles

      public List<JavaFile> getFiles()
      Obtains source files existing in this project.
      Returns:
      the collection of the existing files
    • getSortedFiles

      public List<JavaFile> getSortedFiles()
      Obtains source files existing in this project.
      Returns:
      the sorted collection of the existing files
    • removePackage

      public void removePackage(JavaPackage jpackage)
      Removes a package from this project. This method is not intended to be invoked by clients.
      Parameters:
      jpackage - the package to be removed
    • getPackages

      public List<JavaPackage> getPackages()
      Obtains packages appearing in this project.
      Returns:
      the collection of the existing packages
    • getPackagesInProject

      public List<JavaPackage> getPackagesInProject()
      Obtains packages appearing in this project.
      Returns:
      the collection of the existing packages
    • getSortedPackages

      public List<JavaPackage> getSortedPackages()
      Obtains packages appearing in this project.
      Returns:
      the sorted collection of the existing packages
    • getPackage

      public JavaPackage getPackage(String name)
      Obtains a package having a given name.
      Parameters:
      name - the name of the package to be retrieved
      Returns:
      the found package, or null if no package is found
    • removeClass

      public void removeClass(JavaClass jclass)
      Removes a class from this project. This method is not intended to be invoked by clients.
      Parameters:
      jclass - the class to be removed
    • getClasses

      public List<JavaClass> getClasses()
      Obtains classes existing in this project.
      Returns:
      the collection of the classes in this project
    • getSortedClasses

      public List<JavaClass> getSortedClasses()
      Obtains classes existing in this project.
      Returns:
      the sorted collection of the classes in this project
    • getClass

      public JavaClass getClass(String fqn)
      Obtains a class having a given fully-qualified name from the inside of this project.
      Parameters:
      fqn - the fully-qualified name of the class
      Returns:
      the found class, or null if no class is found
    • getExternalClasses

      public List<JavaClass> getExternalClasses()
      Obtains classes existing outside this project.
      Returns:
      the collection of the outside classes
    • getAllClasses

      public List<JavaClass> getAllClasses()
      Obtains all classes related to this project.
      Returns:
      the collection of all the related classes
    • getExternalClass

      public JavaClass getExternalClass(String fqn)
      Obtains a class having a given fully-qualified name from the outside of this project.
      Parameters:
      fqn - the fully-qualified name of the class
      Returns:
      the found class, or null if no class is found
    • collectClassesDependingOn

      public Set<JavaClass> collectClassesDependingOn(JavaClass jclass)
      Obtains the classes depending on a given class, which are needed to be re-analyzed when the given class is modified
      Parameters:
      jclass - the class of interest
      Returns:
      the collection of the dependent classes
    • setClassPath

      public void setClassPath(String[] classPath)
      Sets the class paths.
      Parameters:
      classPath - the absolute paths that store class files
    • setSourceBinaryPaths

      public void setSourceBinaryPaths(String sourcePath, String binaryPath)
      Sets a source path and a binary path.
      Parameters:
      sourcePath - the absolute path that stores source files
      binaryPath - the absolute path that stores binary files
    • setSourceBinaryPaths

      public void setSourceBinaryPaths(String[] sourcePath, String[] binaryPath)
      Sets source paths and binary paths.
      Parameters:
      sourcePath - the absolute paths that store source files
      binaryPath - the absolute paths that store binary files
    • getClassPath

      public String[] getClassPath()
      Returns the absolute path where class files (jar or zip archives) are located in the project. The class path will be searched when finding class files are loaded.
      Returns:
      the absolute path of the class files
    • getSourcePath

      public String[] getSourcePath()
      Returns the absolute path where source files are located in the project.
      Returns:
      the collection of the absolute path of the source files
    • getBinaryPath

      public String[] getBinaryPath()
      Returns the absolute path where binary files are located in the project.
      Returns:
      the collection of the absolute path of the binary files
    • setCompilerVersions

      public void setCompilerVersions(String compilerSourceVersion, String compilerTargetVersion)
      Sets the versions for compilation.
      Parameters:
      compilerSourceVersion - the version of the compiler source.
      compilerTargetVersion - the version of the compiler target platform.
    • getCompilerSourceVersion

      public String getCompilerSourceVersion()
      Returns the version of the compiler source.
      Returns:
      the version number
    • getCompilerTargetVersion

      public String getCompilerTargetVersion()
      Returns the version of the compiler target platform.
      Returns:
      the version number
    • collectInfo

      public void collectInfo(JavaClass jclass)
      Collects additional information on a given class. This method is not intended to be invoked by clients, which will be automatically invoked as needed.
      Parameters:
      jclass - the class of interest
    • getCFGStore

      public org.jtool.cfg.internal.CFGStore getCFGStore()
      Return the repository that stores CFGs for source files in this project.
      Returns:
      the CFG repository
    • getPDGStore

      public org.jtool.pdg.internal.PDGStore getPDGStore()
      Return the repository that stores PDGs for source files in this project.
      Returns:
      the PDG repository
    • toString

      public String toString()
      Obtains information on this project.
      Overrides:
      toString in class Object
      Returns:
      the string representing the information
    • sortFiles

      public static List<JavaFile> sortFiles(List<? extends JavaFile> files)
      Sorts the list of source files.
      Parameters:
      files - the file list
      Returns:
      the sorted file list
    • sortPackages

      public static List<JavaPackage> sortPackages(List<? extends JavaPackage> packages)
      Sorts the list of packages.
      Parameters:
      packages - the package list
      Returns:
      the sorted package list