Package util

Class FunctionManager


  • public class FunctionManager
    extends java.lang.Object
    Author:
    JIBOYE OLUWAGBEMIRO OLAOLUWA
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Map<java.lang.String,​Function> FUNCTIONS  
    • Constructor Summary

      Constructors 
      Constructor Description
      FunctionManager()  
    • Method Summary

      Modifier and Type Method Description
      static void add​(java.lang.String expression)
      Adds a Function object to this FunctionManager.
      static void add​(Function f)  
      static void clearAnonymousFunctions()
      Deletes all anonymous functions
      static boolean contains​(java.lang.String fName)  
      static int countAnonymousFunctions()  
      static void delete​(java.lang.String fName)
      Removes a Function object from this FunctionManager.
      static java.util.ArrayList<Function> getDefinedFunctions()  
      static Function getFunction​(java.lang.String fName)  
      static void initializeFunctionVars()
      Registers the parameters of all registered functions as Variables on the Variable Registry.
      static void load​(java.util.Map<java.lang.String,​Function> functions)
      Loads the Function objects in this Map into the FUNCTIONS Map.
      static void load​(java.util.Map<java.lang.String,​Function> functions, boolean clearFirst)
      Loads the Function objects in this Map into the FUNCTIONS Map.
      static Function lookUp​(java.lang.String functionName)
      Attempts to retrieve a Function object from a FunctionManager based on its name.
      static void update()
      Saves stored functions and: updates the client UIs that use this manager.
      static void update​(java.lang.String expression)
      Updates a Function object in this FunctionManager.
      • Methods inherited from class java.lang.Object

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

      • FUNCTIONS

        public static final java.util.Map<java.lang.String,​Function> FUNCTIONS
    • Constructor Detail

      • FunctionManager

        public FunctionManager()
    • Method Detail

      • contains

        public static boolean contains​(java.lang.String fName)
        Parameters:
        fName - The name of the dependent variable of the function or the full name of the function which is a combination of the name of its dependent variable and its independent variables enclosed in circular parentheses. e.g in y = x^3, either y or y(x) may be supplied.
        Returns:
        true if a Function exists by the name supplied.
      • getFunction

        public static Function getFunction​(java.lang.String fName)
        Parameters:
        fName - The name of the dependent variable of the function.
        Returns:
        the Function object that has the name supplied if it exists. If no such Function object exists, then it returns null.
      • lookUp

        public static Function lookUp​(java.lang.String functionName)
        Attempts to retrieve a Function object from a FunctionManager based on its name.
        Parameters:
        functionName - The name of the Function object.
        Returns:
        the Function object that has that name or null if the Function is not found.
      • add

        public static void add​(java.lang.String expression)
        Adds a Function object to this FunctionManager.
        Parameters:
        expression - The expression that creates the Function to add. The form is:F=@(x,y,z,...)mathexpr. e.g y=@(x)3x-x^2; Functions take precedence over variables.. so if a function called sin_func is created and there exists a variable with that name, the system discards that variable
      • add

        public static void add​(Function f)
        Parameters:
        f - The Function object to add to this object.
      • load

        public static void load​(java.util.Map<java.lang.String,​Function> functions)
        Loads the Function objects in this Map into the FUNCTIONS Map.
        Parameters:
        functions - A Map of Function objects.
      • load

        public static void load​(java.util.Map<java.lang.String,​Function> functions,
                                boolean clearFirst)
        Loads the Function objects in this Map into the FUNCTIONS Map.
        Parameters:
        functions - A Map of Function objects.
        clearFirst - If true, then the FUNCTIONS is cleared first before new content is loaded into it.
      • delete

        public static void delete​(java.lang.String fName)
        Removes a Function object from this FunctionManager.
      • update

        public static void update​(java.lang.String expression)
        Updates a Function object in this FunctionManager.
      • clearAnonymousFunctions

        public static void clearAnonymousFunctions()
        Deletes all anonymous functions
      • countAnonymousFunctions

        public static int countAnonymousFunctions()
        Returns:
        the number of anonymous functions in the FunctionManager.
      • getDefinedFunctions

        public static final java.util.ArrayList<Function> getDefinedFunctions()
        Returns:
        An ArrayList of all non-anonymous functions.
      • update

        public static void update()
        Saves stored functions and: updates the client UIs that use this manager.
      • initializeFunctionVars

        public static void initializeFunctionVars()
        Registers the parameters of all registered functions as Variables on the Variable Registry.