Class MySQLTranslator

  • All Implemented Interfaces:
    Function<String,​String>, UnaryOperator<String>
    Direct Known Subclasses:
    VanillaSQLTranslator

    public class MySQLTranslator
    extends Object
    implements UnaryOperator<String>
    Object that translates statements designed for MySQL's flavour of SQL to the flavour used by the graph service.

    Where necessary for performance or functionality, annotators may need to use features of SQL that are specific to MySQL, e.g. specifying the ENGINE when creating tables, using the utf8mb4 CHARACTER SET etc.

    For implementations that don't use MySQL (e.g. for local command-line annatotator processing), this class provides the possibility of intercepting SQL statements and converting them into variants that will work with whatever RDBMS has been chosen. Other implementations migth simply strip out unsupported syntax, or may convert operators or functions to equivalants.

    The default implementation simply passes statements through unchanged.

    Author:
    Robert Fromont robert@fromont.net.nz
    • Constructor Detail

      • MySQLTranslator

        public MySQLTranslator()
    • Method Detail

      • getRdbms

        public String getRdbms()
        Getter for rdbms: Name of the Relational Database Management System the translator is for.
        Returns:
        Name of the Relational Database Management System the translator is for.
      • getTrace

        public boolean getTrace()
        Getter for trace: Whether to print statements passed to apply(String)
        Returns:
        Whether to print statements passed to apply(String)
      • setTrace

        public MySQLTranslator setTrace​(boolean newTrace)
        Setter for trace: Whether to print statements passed to apply(String)
        Parameters:
        newTrace - Whether to print statements passed to apply(String)
      • apply

        public String apply​(String sql)
        Translate the given statement.

        This implementation simply returns the given statement.

        Specified by:
        apply in interface Function<String,​String>
        Parameters:
        sql - The SQL statement to translate
        Returns:
        The translated version of the the SQL statement.