Class SourceToObjectUtils

java.lang.Object
edu.university.ecs.lab.common.utils.SourceToObjectUtils

public class SourceToObjectUtils extends Object
Static utility class for parsing a file and returning associated models from code structure.
  • Constructor Details

    • SourceToObjectUtils

      public SourceToObjectUtils()
  • Method Details

    • parseClass

      public static JClass parseClass(File sourceFile, Config config)
      This method parses a Java class file and return a JClass object.
      Parameters:
      sourceFile - the file to parse
      Returns:
      the JClass object representing the file
    • parseMethods

      public static Set<Method> parseMethods(String preURL, List<com.github.javaparser.ast.body.MethodDeclaration> methodDeclarations)
      This method parses methodDeclarations list and returns a Set of Method models
      Parameters:
      preURL - the preURL
      methodDeclarations - the list of methodDeclarations to be parsed
      Returns:
      a set of Method models representing the MethodDeclarations
    • convertValidEndpoints

      public static Method convertValidEndpoints(String preURL, com.github.javaparser.ast.body.MethodDeclaration methodDeclaration, Method method)
      This method converts a valid Method to an Endpoint
      Parameters:
      preURL - the preURL
      methodDeclaration - the MethodDeclaration associated with Method
      method - the Method to be converted
      Returns:
      returns method if it is invalid, otherwise a new Endpoint
    • parseMethodCalls

      public static Set<MethodCall> parseMethodCalls(List<com.github.javaparser.ast.body.MethodDeclaration> methodDeclarations)
      This method parses methodDeclarations list and returns a Set of MethodCall models
      Parameters:
      methodDeclarations - the list of methodDeclarations to be parsed
      Returns:
      a set of MethodCall models representing MethodCallExpressions found in the MethodDeclarations
    • convertValidRestCalls

      public static MethodCall convertValidRestCalls(com.github.javaparser.ast.expr.MethodCallExpr methodCallExpr, MethodCall methodCall)
      This method converts a valid MethodCall to an RestCall
      Parameters:
      methodCallExpr - the MethodDeclaration associated with Method
      methodCall - the MethodCall to be converted
      Returns:
      returns methodCall if it is invalid, otherwise a new RestCall