Interface EquationCompiler


  • public interface EquationCompiler
    Compiler that compiles equations to byte (non-Java) code.

    Module: equations-api

    To use this in your app, include the following dependency in your POM:

    <dependency>
        <groupId>org.cytoscape</groupId>
        <artifactId>equations-api</artifactId>
    </dependency>

    Cytoscape Backwards Compatibility (API Interface): We expect that this interface will be used but not implemented by developers using this interface. As such, we reserve the right to add methods to the interface as part of minor version upgrades. We will not remove methods for any changes other than major version upgrades.
    • Method Detail

      • compile

        boolean compile​(String equation,
                        Map<String,​Class<?>> variableNameToTypeMap)
        Compiles a string to byte code plus some metadata as encapsulated by the Equation class
        Parameters:
        equation - a textual representation of an equation
        variableNameToTypeMap - a mapping from variable names occurring in "equation" to their respective types
        Returns:
        true if the compiler successfully compiles the equation.
      • getLastErrorMsg

        String getLastErrorMsg()
        Returns an error message for an error encountered during a call to compile, if any.
        Returns:
        a human readable error message Please note that it is probably a good idea to only call this method if compile() returned false.
      • getEquation

        Equation getEquation()
        If compile() returns true, this returns the result of the compilation.
        Returns:
        an Equation representing the code compiled from the string passed into compile()
      • getErrorEquation

        Equation getErrorEquation​(String equation,
                                  Class<?> type,
                                  String errorMessage)
        A factory method that returns an Equation that always fails at runtime. The reason for why this exists is that the returned error equations can substitute for real equations as dummies.
        Parameters:
        equation - an arbitrary string that is usually a syntactically invalid equation
        type - the return type of the error equation
        errorMessage - the runtime error message that the returned equation will produce
        Returns:
        the error equation
      • getParser

        EquationParser getParser()
        Returns the parser which can be used for checking the syntax of equations.
        Returns:
        the parser used by the compiler