Package org.jtool.jxplatform.builder
Class ModelBuilder
java.lang.Object
org.jtool.jxplatform.builder.ModelBuilder
- Direct Known Subclasses:
IncrementalModelBuilder
,ModelBuilderBatch
A builder that builds models from Java source code.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
A line break symbol, "\n" for macOS and Linux, "\r\n" for Windowsprotected org.jtool.jxplatform.project.ModelBuilderImpl
The implementation module of this model builder. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a new, empty object that builds Java models. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Tests if byte-code analysis is performed.void
analyzeBytecode
(boolean bool) Sets whether byte-code analysis is performed.Builds a source code model for target projects.Builds a source code model for a target project.Builds a source code model for a target project.Builds a source code model for a target project.copyJavaFile
(JavaFile jfile) Creates a copy of the filefindCCFG
(JavaProject jproject, String fqn) Finds a CCFG for a class having a given fully-qualified name.findCFG
(JavaProject jproject, String fqn) Finds a CFG for a class element having a given fully-qualified name.findClDG
(JavaProject jproject, String fqn) Finds a ClDG for a class having a given fully-qualified name.findPDG
(JavaProject jproject, String fqn) Finds a PDG for a class member having a given fully-qualified name.getAllClassesBackward
(JavaClass jclass) Obtains the classes backward related to a given class.getAllClassesForward
(JavaClass jclass) Obtains the classes forward related to a given class.getAllMethodsBackward
(JavaMethod jmethod) Obtains the methods backward related to a given class.getAllMethodsForward
(JavaMethod jmethod) Obtains the methods forward related to a given class.getCallGraph
(JavaProject jproject) Obtains a call graph for methods within a project.Obtains a CCFG for a given class.Obtains a CCFG for a given class.Obtains a CFG for a given field.Obtains a CFG for a given method.getCFG
(JavaMethod jmethod) Finds a CFG for a given method.getCFG
(JavaMethod jmethod, boolean force) Obtains a CFG for a given method.Obtains a ClDG for a given class from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.Obtains a ClDG for a given class.getClDG
(JavaProject jproject, CCFG ccfg) Obtains a ClDG for a given CCFG for a class from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.getClDG
(JavaProject jproject, CCFG ccfg, boolean force, boolean whole) Obtains a ClDG for a given CCFG for a class.getDependencyGraph
(Set<JavaClass> classes, boolean force, boolean whole) Obtains a dependency graph for classes related to given classes.getDependencyGraph
(JavaClass jclass) Obtains a dependency graph for classes related to a given class from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.getDependencyGraph
(JavaClass jclass, boolean force, boolean whole) Obtains a dependency graph for classes related to a given class.getgetDependencyGraph
(Set<JavaClass> classes) Obtains a dependency graph for classes related to given classes from the cache.org.jtool.jxplatform.project.ModelBuilderImpl
Obtains the implementation module of this model builder.Obtains a PDG for a given field from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.Obtains a PDG for a given field.getPDG
(JavaMethod jmethod) Obtains a PDG for a given method from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.getPDG
(JavaMethod jmethod, boolean force, boolean whole) Obtains a PDG for a given method.getPDG
(JavaProject jproject, CFG cfg) Obtains a PDG for a given CFG for a method or a field from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.getPDG
(JavaProject jproject, CFG cfg, boolean force, boolean whole) Obtains a PDG for a given CFG for a method or a field.getSDG
(JavaProject jproject) Obtains an SDG for all classes in a project from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.getSDG
(JavaProject jproject, boolean force) Obtains an SDG for all classes in a project, using the whole information related to calls to methods and accesses to fields of outside classes.getUnregisteredJavaFile
(String filepath, String code, JavaProject jproject) Create a temporary object corresponding to a file without registering project repository.getUnregisteredJavaFile
(String filepath, String code, JavaProject jproject, String charset) Create a temporary object corresponding to a file without registering project repository.void
setBytecodeAnalysisLevel
(int analysisChain) Sets the maximum number of a chain when analyzing byte-code classes.void
setConsoleVisible
(boolean visible) Sets whether information is displayed on console.void
setSourcecodeAnalysisChain
(int analysisChain) Sets the maximum number of a chain when analyzing class defined in source-code.void
unbuild()
Disposes the created models.boolean
useCache()
Tests if byte-code analysis is performed.void
useCache
(boolean bool) Sets whether byte-code analysis is performed.
-
Field Details
-
br
A line break symbol, "\n" for macOS and Linux, "\r\n" for Windows -
builderImpl
protected org.jtool.jxplatform.project.ModelBuilderImpl builderImplThe implementation module of this model builder.
-
-
Constructor Details
-
ModelBuilder
protected ModelBuilder()Creates a new, empty object that builds Java models.
-
-
Method Details
-
getModelBuilderImpl
public org.jtool.jxplatform.project.ModelBuilderImpl getModelBuilderImpl()Obtains the implementation module of this model builder.- Returns:
- the implementation module.
-
setSourcecodeAnalysisChain
public void setSourcecodeAnalysisChain(int analysisChain) Sets the maximum number of a chain when analyzing class defined in source-code.- Parameters:
analysisChain
- the maximum number of the chain
-
setBytecodeAnalysisLevel
public void setBytecodeAnalysisLevel(int analysisChain) Sets the maximum number of a chain when analyzing byte-code classes.- Parameters:
analysisChain
- the maximum number of the chain
-
analyzeBytecode
public void analyzeBytecode(boolean bool) Sets whether byte-code analysis is performed.- Parameters:
bool
-true
if byte-code analysis is performed, otherwisefalse
-
analyzeBytecode
public boolean analyzeBytecode()Tests if byte-code analysis is performed.- Returns:
true
if byte-code analysis is performed, otherwisefalse
-
useCache
public void useCache(boolean bool) Sets whether byte-code analysis is performed.- Parameters:
bool
-true
if byte-code analysis is performed, otherwisefalse
-
useCache
public boolean useCache()Tests if byte-code analysis is performed.- Returns:
true
if byte-code analysis is performed, otherwisefalse
-
build
Builds a source code model for target projects.- Parameters:
name
- the name of the created modeltarget
- the directory storing the target projects- Returns:
- the collection of created project data
-
build
Builds a source code model for a target project.- Parameters:
name
- the name of the created modeltarget
- the directory storing the target projectclasspath
- the path where the needed class (or jar) files are located- Returns:
- the created project data
-
build
public JavaProject build(String name, String target, String classpath, String srcpath, String binpath) Builds a source code model for a target project.- Parameters:
name
- the name of the created modeltarget
- the directory storing the target projectclasspath
- the path where the needed class (or jar) files are locatedsrcpath
- the path where the source files are locatedbinpath
- the path where the binary files are located- Returns:
- the created project data
-
build
public JavaProject build(String name, String target, String[] classpath, String[] srcpath, String[] binpath) Builds a source code model for a target project.- Parameters:
name
- the name of the created modeltarget
- the directory storing the target projectclasspath
- the collection of the paths where the needed class (or jar) files are locatedsrcpath
- the collection of the paths where the source files are locatedbinpath
- the collection of the paths where the binary files are located- Returns:
- the created project data
-
unbuild
public void unbuild()Disposes the created models. -
copyJavaFile
Creates a copy of the file- Parameters:
jfile
- the file to be copied- Returns:
- the copy
-
getUnregisteredJavaFile
Create a temporary object corresponding to a file without registering project repository.- Parameters:
filepath
- the path of the filecode
- the contents of the filejproject
- the project that should contain the file- Returns:
- the created file
-
getUnregisteredJavaFile
public JavaFile getUnregisteredJavaFile(String filepath, String code, JavaProject jproject, String charset) Create a temporary object corresponding to a file without registering project repository.- Parameters:
filepath
- the path of the filecode
- the contents of the filejproject
- the project that should contain the filecharset
- the character set of the file- Returns:
- the created file
-
findCFG
Finds a CFG for a class element having a given fully-qualified name.- Parameters:
jproject
- the project containing the class elementfqn
- the fully-qualified name of the class member (className#memeberName
)- Returns:
- the found CFG, or
null
if no CFG is found
-
findCCFG
Finds a CCFG for a class having a given fully-qualified name.- Parameters:
jproject
- the project containing the classfqn
- the fully-qualified name for the class (className
)- Returns:
- the found CFG, or
null
if no CFG is found
-
getCFG
Obtains a CFG for a given method.- Parameters:
jmethod
- the method of interestforce
-true
if the CFG will be forcibly recreated, orfalse
if a CFG stored in the repository will be reused- Returns:
- the created or found CFG, or
null
if no CFG is created or found
-
getCFG
Finds a CFG for a given method.- Parameters:
jmethod
- the method of interest- Returns:
- the created or found CFG, or
null
if no CFG is created or found
-
getCFG
Obtains a CFG for a given method.- Parameters:
jfield
- the field of interestforce
-true
if the CFG will be forcibly recreated, orfalse
if a CFG stored in the repository will be reused- Returns:
- the created or found CFG, or
null
if no CFG is created or found
-
getCFG
Obtains a CFG for a given field.- Parameters:
jfield
- the field of interest- Returns:
- the created or found CFG, or
null
if no CFG is created or found
-
getCCFG
Obtains a CCFG for a given class.- Parameters:
jclass
- the class of interestforce
-true
if the CCFG will be forcibly recreated, orfalse
if a CCFG stored in the repository will be reused- Returns:
- the created or found CCFG
-
getCCFG
Obtains a CCFG for a given class.- Parameters:
jclass
- the class of interest- Returns:
- the created or found CCFG
-
getCallGraph
Obtains a call graph for methods within a project.- Parameters:
jproject
- the target project- Returns:
- the created call graph
-
findPDG
Finds a PDG for a class member having a given fully-qualified name.- Parameters:
jproject
- the project containing the class elementfqn
- the fully-qualified name of the class member (className#memeberName
)- Returns:
- the found PDG, or
null
if no PDG is found
-
findClDG
Finds a ClDG for a class having a given fully-qualified name.- Parameters:
jproject
- the project containing the classfqn
- the fully-qualified name for the class (className
)- Returns:
- the found ClDG, or
null
if no ClDG is found
-
getPDG
Obtains a PDG for a given CFG for a method or a field.- Parameters:
jproject
- the project containing the target CFGcfg
- the target CFGforce
-true
if the PDG will be forcibly re-created, orfalse
if a PDG stored in the repository will be reusedwhole
-true
if the PDG will be created with the whole information related to calls to methods and accesses to fields of outside classes- Returns:
- the created or found PDG, or
null
if no PDG is created or found
-
getPDG
Obtains a PDG for a given CFG for a method or a field from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.- Parameters:
jproject
- the project containing the target CFGcfg
- the target CFG- Returns:
- the created or found PDG, or
null
if no PDG is created or found
-
getPDG
Obtains a PDG for a given method.- Parameters:
jmethod
- the method of interestforce
-true
if the PDG will be forcibly re-created, orfalse
if a PDG stored in the repository will be reusedwhole
-true
if the PDG will be created with the whole information related to calls to methods and accesses to fields of outside classes- Returns:
- the created or found PDG, or
null
if no PDG is created or found
-
getPDG
Obtains a PDG for a given method from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.- Parameters:
jmethod
- the method of interest- Returns:
- the created or found PDG, or
null
if no PDG is created or found
-
getPDG
Obtains a PDG for a given field.- Parameters:
jfield
- the field of interestforce
-true
if the PDG will be forcibly re-created, orfalse
if a PDG stored in the repository will be reusedwhole
-true
if the PDG will be created with the whole information related to calls to methods and accesses to fields of outside classes- Returns:
- the created or found PDG, or
null
if no PDG is created or found
-
getPDG
Obtains a PDG for a given field from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.- Parameters:
jfield
- the field of interest- Returns:
- the created or found PDG, or
null
if no PDG is created or found
-
getClDG
Obtains a ClDG for a given CCFG for a class.- Parameters:
jproject
- the project containing the target CCFGccfg
- the target CCFGforce
-true
if the ClDG will be forcibly recreated, orfalse
if a ClDG stored in the repository will be reusedwhole
-true
if a ClDG will be created with the whole information related to calls to methods and accesses to fields of outside classes- Returns:
- the created or found ClDG, or
null
if no ClDG is created or found
-
getClDG
Obtains a ClDG for a given CCFG for a class from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.- Parameters:
jproject
- the project containing the target CCFGccfg
- the target CCFG- Returns:
- the created or found ClDG, or
null
if no ClDG is created or found
-
getClDG
Obtains a ClDG for a given class.- Parameters:
jclass
- the class of interestforce
-true
if the PDG will be forcibly recreated, orfalse
if a ClDG stored in the repository will be reusedwhole
-true
if a ClDG will be created with the whole information related to calls to methods and accesses to fields of outside classes- Returns:
- the created or found ClDG, or
null
if no ClDG is created or found
-
getClDG
Obtains a ClDG for a given class from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.- Parameters:
jclass
- the class of interest- Returns:
- the created or found ClDG, or
null
if no ClDG is created or found
-
getSDG
Obtains an SDG for all classes in a project, using the whole information related to calls to methods and accesses to fields of outside classes.- Parameters:
jproject
- the target projectforce
-true
if an SDG will be forcibly recreated, orfalse
if an SDG stored in the repository will be reused- Returns:
- the created or found SDG
-
getSDG
Obtains an SDG for all classes in a project from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.- Parameters:
jproject
- the target project- Returns:
- the created or found SDG
-
getDependencyGraph
Obtains a dependency graph for classes related to a given class.- Parameters:
jclass
- the class of interestforce
-true
if the dependency graph will be forcibly recreated, orfalse
if a dependency graph stored in the repository will be reusedwhole
-true
if a dependency graph will be created with the whole information related to calls to methods and accesses to fields of outside classes- Returns:
- the created or found dependency graph
-
getDependencyGraph
Obtains a dependency graph for classes related to a given class from the cache, using the whole information related to calls to methods and accesses to fields of outside classes.- Parameters:
jclass
- the class of interest- Returns:
- the created or found dependency graph
-
getDependencyGraph
Obtains a dependency graph for classes related to given classes.- Parameters:
classes
- the collection of the classes of interestforce
-true
if a dependency graph will be forcibly recreated, orfalse
if a dependency graph stored in the repository will be reusedwhole
-true
if a dependency graph will be created with the whole information related to calls to methods and accesses to fields of outside classes- Returns:
- the created or found dependency graph
-
getgetDependencyGraph
Obtains a dependency graph for classes related to given classes from the cache.- Parameters:
classes
- the collection of the classes of interest- Returns:
- the created or found dependency graph
-
setConsoleVisible
public void setConsoleVisible(boolean visible) Sets whether information is displayed on console.- Parameters:
visible
-true
if the information is displayed, otherwisefalse
-
getAllClassesForward
Obtains the classes forward related to a given class.- Parameters:
jclass
- the class of interest- Returns:
- the collection of classes used by the class
-
getAllClassesBackward
Obtains the classes backward related to a given class.- Parameters:
jclass
- the class of interest- Returns:
- the collection of classes using the class
-
getAllMethodsForward
Obtains the methods forward related to a given class.- Parameters:
jmethod
- the method of interest- Returns:
- the collection of methods called by the method
-
getAllMethodsBackward
Obtains the methods backward related to a given class.- Parameters:
jmethod
- the method of interest- Returns:
- the collection of methods calling the method
-