Class JavaParserUtil
- java.lang.Object
-
- com.devonfw.cobigen.javaplugin.inputreader.JavaParserUtil
-
public class JavaParserUtil extends java.lang.ObjectTheJavaParserUtilclass 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.JavaClassgetFirstJavaClass(java.io.Reader... reader)Returns the firstJavaClassparsed by the givenReader, all upcoming parsed java files will be added to the class librarystatic com.thoughtworks.qdox.model.JavaClassgetFirstJavaClass(java.lang.ClassLoader classLoader, java.io.Reader... reader)Returns the firstJavaClassparsed by the givenReader, all upcoming parsed java files will be added to the class library.static net.sf.mmm.code.impl.java.JavaContextgetJavaContext(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.StringresolveToSimpleType(java.lang.String canonicalType)Converts the String representation of a canonical type into a String which represents the simple type.
-
-
-
Method Detail
-
getFirstJavaClass
public static com.thoughtworks.qdox.model.JavaClass getFirstJavaClass(java.io.Reader... reader)
Returns the firstJavaClassparsed by the givenReader, 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 firstJavaClassparsed by the givenReader, all upcoming parsed java files will be added to the class library. By passing aClassLoader, you can take impact on the class name resolving- Parameters:
classLoader- which should be used for class name resolvingreader-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.Stringis converted intoStringjava.util.List<java.lang.String>is converted intoList<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 frominputProject- 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
-
-