Package org.cytoscape.equations
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 Summary
Modifier and TypeMethodDescriptionboolean
Compiles a string to byte code plus some metadata as encapsulated by theEquation
classIf compile() returns true, this returns the result of the compilation.getErrorEquation(String equation, Class<?> type, String errorMessage)
A factory method that returns an Equation that always fails at runtime.int
If compile() failed, this will return the index in the equation where the error was encountered.Returns an error message for an error encountered during a call to compile, if any.Returns the parser which can be used for checking the syntax of equations.
-
Method Details
-
compile
Compiles a string to byte code plus some metadata as encapsulated by theEquation
class- Parameters:
equation
- a textual representation of an equationvariableNameToTypeMap
- 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.
-
getErrorLocation
int getErrorLocation()If compile() failed, this will return the index in the equation where the error was encountered. The value -1 is returned if the compile did not fail or if the error location could not be determined.- Returns:
- the error location
-
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
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 equationtype
- the return type of the error equationerrorMessage
- 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
-