Class JavaParserUtil


  • public class JavaParserUtil
    extends java.lang.Object
    The JavaParserUtil class provides helper functions for generating parsed inputs
    • Constructor Summary

      Constructors 
      Constructor Description
      JavaParserUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.thoughtworks.qdox.model.JavaClass getFirstJavaClass​(java.io.Reader... reader)
      Returns the first JavaClass parsed by the given Reader, all upcoming parsed java files will be added to the class library
      static com.thoughtworks.qdox.model.JavaClass getFirstJavaClass​(java.lang.ClassLoader classLoader, java.io.Reader... reader)
      Returns the first JavaClass parsed by the given Reader, all upcoming parsed java files will be added to the class library.
      static net.sf.mmm.code.impl.java.JavaContext getJavaContext​(java.nio.file.Path inputFile, java.nio.file.Path inputProject)
      Tries to get the Java context by creating a new class loader of the input project that is able to load the input file.
      static java.lang.String resolveToSimpleType​(java.lang.String canonicalType)
      Converts the String representation of a canonical type into a String which represents the simple type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JavaParserUtil

        public JavaParserUtil()
    • Method Detail

      • getFirstJavaClass

        public static com.thoughtworks.qdox.model.JavaClass getFirstJavaClass​(java.io.Reader... reader)
        Returns the first JavaClass parsed by the given Reader, all upcoming parsed java files will be added to the class library
        Parameters:
        reader - Readers which contents should be parsed
        Returns:
        the parsed JavaClass
      • getFirstJavaClass

        public static com.thoughtworks.qdox.model.JavaClass getFirstJavaClass​(java.lang.ClassLoader classLoader,
                                                                              java.io.Reader... reader)
        Returns the first JavaClass parsed by the given Reader, all upcoming parsed java files will be added to the class library. By passing a ClassLoader, you can take impact on the class name resolving
        Parameters:
        classLoader - which should be used for class name resolving
        reader - Readers which contents should be parsed
        Returns:
        the parsed JavaClass
      • resolveToSimpleType

        public static java.lang.String resolveToSimpleType​(java.lang.String canonicalType)
        Converts the String representation of a canonical type into a String which represents the simple type. E.g.:
        • java.lang.String is converted into String
        • java.util.List<java.lang.String> is converted into List<String>
        Parameters:
        canonicalType - the String representation of the canonical type to be resolved
        Returns:
        the resolved simple type as String representation.
      • getJavaContext

        public static net.sf.mmm.code.impl.java.JavaContext getJavaContext​(java.nio.file.Path inputFile,
                                                                           java.nio.file.Path inputProject)
        Tries to get the Java context by creating a new class loader of the input project that is able to load the input file. We need this in order to perform reflection on the templates.
        Parameters:
        inputFile - input file the user wants to generate code from
        inputProject - input project where the input file is located. We need this in order to build the classpath of the input file
        Returns:
        the Java context created from the input project