Class JaMoPPJDTParser

java.lang.Object
tools.mdsd.jamopp.parser.JaMoPPJDTParser
All Implemented Interfaces:
JaMoPPParserAPI

public class JaMoPPJDTParser extends Object implements JaMoPPParserAPI
  • Field Details

    • DEFAULT_ENCODING

      public static final String DEFAULT_ENCODING
    • DEFAULT_JAVA_VERSION

      public static final String DEFAULT_JAVA_VERSION
  • Constructor Details

    • JaMoPPJDTParser

      public JaMoPPJDTParser()
  • Method Details

    • convertCompilationUnits

      public List<JavaRoot> convertCompilationUnits(Map<String,org.eclipse.jdt.core.dom.CompilationUnit> compilationUnits)
      Description copied from interface: JaMoPPParserAPI
      Convert compilation units.
      Specified by:
      convertCompilationUnits in interface JaMoPPParserAPI
      Parameters:
      compilationUnits - the compilation units
      Returns:
      the list
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • get

      public <T> Set<T> get(Class<T> type)
      Description copied from interface: JaMoPPParserAPI
      Gets the.
      Specified by:
      get in interface JaMoPPParserAPI
      Type Parameters:
      T - the generic type
      Parameters:
      type - the type
      Returns:
      the sets the
    • getResourceSet

      public ResourceSet getResourceSet()
      Description copied from interface: JaMoPPParserAPI
      Gets the resource set.
      Specified by:
      getResourceSet in interface JaMoPPParserAPI
      Returns:
      the resource set
    • getSourcepathEntries

      public String[] getSourcepathEntries(Path dir)
      Description copied from interface: JaMoPPParserAPI
      Gets the sourcepath entries.
      Specified by:
      getSourcepathEntries in interface JaMoPPParserAPI
      Parameters:
      dir - the dir
      Returns:
      the sourcepath entries
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • parse

      public JavaRoot parse(String fileName, InputStream input)
      Description copied from interface: JaMoPPParserAPI
      Reads an InputStream and parses its content into a Java model instance.
      Specified by:
      parse in interface JaMoPPParserAPI
      Parameters:
      fileName - name of the Java source file which will be read.
      input - the InputStream to read.
      Returns:
      the created Java model instance or null if the InputStream could not be read.
    • parseDirectory

      public ResourceSet parseDirectory(org.eclipse.jdt.core.dom.ASTParser parser, Path dir)
      Description copied from interface: JaMoPPParserAPI
      Parses the directory.
      Specified by:
      parseDirectory in interface JaMoPPParserAPI
      Parameters:
      parser - the parser
      dir - the dir
      Returns:
      the resource set
    • parseDirectory

      public ResourceSet parseDirectory(Path dir)
      Description copied from interface: JaMoPPParserAPI
      Visits all files and directories in a directory and parses all found Java source files. It is assumed that the given directory is a Java source folder containing sub-directories representing a Java package hierarchy.
      Specified by:
      parseDirectory in interface JaMoPPParserAPI
      Parameters:
      dir - the directory to search for Java source files.
      Returns:
      a ResourceSet containing all parsed source files with their associated Resources.
    • parseFile

      public Resource parseFile(Path file)
      Description copied from interface: JaMoPPParserAPI
      Reads a file and parses its content into a Java model instance.
      Specified by:
      parseFile in interface JaMoPPParserAPI
      Parameters:
      file - the Java source file.
      Returns:
      the created Java model instance contained in its associated Resource instance or null if the file could not be read.
    • parsePackage

      public ResourceSet parsePackage(org.eclipse.jdt.core.IPackageFragment javaPackage)
      Description copied from interface: JaMoPPParserAPI
      Parses the package.
      Specified by:
      parsePackage in interface JaMoPPParserAPI
      Parameters:
      javaPackage - the java package
      Returns:
      the resource set
    • parseProject

      public ResourceSet parseProject(org.eclipse.jdt.core.IJavaProject javaProject)
      Description copied from interface: JaMoPPParserAPI
      Parses the project.
      Specified by:
      parseProject in interface JaMoPPParserAPI
      Parameters:
      javaProject - the java project
      Returns:
      the resource set
    • setResourceSet

      public void setResourceSet(ResourceSet set)
      Description copied from interface: JaMoPPParserAPI
      Sets the ResourceSet that is used to create Resources if new Resource instances are needed. If no ResourceSet is provided, a ResourceSet is created.
      Specified by:
      setResourceSet in interface JaMoPPParserAPI
      Parameters:
      set - the ResourceSet.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getClasspathEntries

      public static String[] getClasspathEntries(Path dir)
    • getCompilationUnits

      public static Map<String,org.eclipse.jdt.core.dom.CompilationUnit> getCompilationUnits(org.eclipse.jdt.core.dom.ASTParser parser, String[] classpathEntries, String[] sources, String[] encodings)
    • getJavaParser

      public static org.eclipse.jdt.core.dom.ASTParser getJavaParser(String version)