Class FunctionUtility


  • public class FunctionUtility
    extends java.lang.Object
    Utility methods for performing function related actions.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getFunctionTitle​(Function function)
      Gets a title string wrapped as HTML and indicating the function's name and the program containing it.
      static boolean isSameLanguage​(Program program1, Program program2)
      Determines whether or not the two programs are considered to have the same processor language and compiler specification.
      static void setUniqueParameterNames​(Function function, java.util.List<Parameter> parameters)
      Changes the names of the parameters in the array to unique names that won't conflict with any other names in the function's namespace when the parameters are used to replace the existing parameters in the function.
      static void updateFunction​(Function destinationFunction, Function sourceFunction)
      Updates the destination function so its signature will match the source function's signature as closely as possible.
      • Methods inherited from class java.lang.Object

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

      • updateFunction

        public static void updateFunction​(Function destinationFunction,
                                          Function sourceFunction)
                                   throws InvalidInputException,
                                          DuplicateNameException
        Updates the destination function so its signature will match the source function's signature as closely as possible. This method will try to create conflict names if necessary for the function and its parameters.
        Parameters:
        destinationFunction - the destination function to update
        sourceFunction - the source function to use as a template
        Throws:
        InvalidInputException - if the function name or a variable name is invalid or if a parameter data type is not a fixed length.
        DuplicateNameException - This shouldn't happen since it will try to create conflict names for the function and its variables if necessary. Otherwise, this would be because the function's name or a variable name already exists.
      • setUniqueParameterNames

        public static void setUniqueParameterNames​(Function function,
                                                   java.util.List<Parameter> parameters)
                                            throws DuplicateNameException,
                                                   InvalidInputException
        Changes the names of the parameters in the array to unique names that won't conflict with any other names in the function's namespace when the parameters are used to replace the existing parameters in the function. Appends an integer number to the base name if necessary to create a unique name in the function's namespace.
        Parameters:
        function - the function
        parameters - the parameters that need names that won't conflict. These should be Impl objects and not DB objects since their names will be changed within this method.
        Throws:
        InvalidInputException
        DuplicateNameException
      • isSameLanguage

        public static boolean isSameLanguage​(Program program1,
                                             Program program2)
        Determines whether or not the two programs are considered to have the same processor language and compiler specification.
        Parameters:
        program1 - the first program
        program2 - the second program
        Returns:
        true if the two programs have the same processor language and compiler spec.
      • getFunctionTitle

        public static java.lang.String getFunctionTitle​(Function function)
        Gets a title string wrapped as HTML and indicating the function's name and the program containing it.
        Parameters:
        function - the function to be indicated in the title.
        Returns:
        the title string as HTML.