Class LineFactory


  • public final class LineFactory
    extends Object
    Some primitive utilities for generating Python code lines.
    • Method Detail

      • extractPythonCodelines

        public static String[] extractPythonCodelines​(PythonImplementation baseImplementation)
        Given a certain array of byte, extract the line-to-line python implementation. We expect a certain sequence of characters of python code. The relative indentation is assumed to be correct, and for compliance the initial indentation should be zero.
        Parameters:
        baseImplementation - Contains the byte array.
        Returns:
        Returns an array of Strings, with relative indentation, of the Python code for the defined function
      • generatePythonClass

        public static String generatePythonClass​(String className,
                                                 String parentName,
                                                 int level)
        Generates a class definition in Python for class
        Parameters:
        className - Name of the class
        parentName - Name of the parent class (may be NULL)
        level - Indentation level to use.
        Returns:
        An string defining the class using Python syntax "[_indent_*level]class className(parentName):\n"
      • generatePythonMethod

        public static String generatePythonMethod​(String methodName,
                                                  String[] parameters,
                                                  int level)
        Generates a method definition for a class in Python
        Parameters:
        methodName - Name of the method
        parameters - Array of parameter names
        level - Indentation level to use.
        Returns:
        An string defining the method using Python syntax "[_indent_*level]def methodName(self, parameters[0], parameters[1]...):\n"
      • generatePythonCodeline

        public static String generatePythonCodeline​(String line,
                                                    int level)
        Generate a single line of Python code taking into account the indentation level.
        Parameters:
        line - String with the Python line to include.
        level - Indentation level to use.
        Returns:
        An string with the line of code. "[_indent_*level]line\n"
      • generatePythonCommentLine

        public static String generatePythonCommentLine​(String comment,
                                                       int level)
        Generate a single line comment of Python code
        Parameters:
        comment - Readable comment (without # nor any prefix).
        level - Indentation level to use.
        Returns:
        A string with the line of code. "[_indent_*level]# line\n"