view src/main/java/nl/cwi/monetdb/mcl/connection/MonetDBLanguage.java @ 64:bb0d66ad7dc6 embedded

More done
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Thu, 01 Dec 2016 16:52:27 +0100 (2016-12-01)
parents 6325594f01af
children 7307caacc2d5
line wrap: on
line source
package nl.cwi.monetdb.mcl.connection;

/**
 * Created by ferreira on 11/30/16.
 */
public enum MonetDBLanguage {

    /** the SQL language */
    LANG_SQL(new byte[][]{"s".getBytes(), "\n;".getBytes(), "\n;\n".getBytes()}, new byte[][]{"X".getBytes(), null, "\nX".getBytes()}, "sql"),
    /** the MAL language (officially *NOT* supported) */
    LANG_MAL(new byte[][]{null, ";\n".getBytes(), ";\n".getBytes()}, new byte[][]{null, null, null}, "mal"),
    /** an unknown language */
    LANG_UNKNOWN(null, null, "unknown");

    MonetDBLanguage(byte[][] queryTemplates, byte[][] commandTemplates, String representation) {
        this.queryTemplates = queryTemplates;
        this.commandTemplates = commandTemplates;
        this.representation = representation;
    }

    private final byte[][] queryTemplates;

    private final byte[][] commandTemplates;

    private final String representation;

    public byte[] getQueryTemplateIndex(int index) {
        return queryTemplates[index];
    }

    public byte[] getCommandTemplateIndex(int index) {
        return commandTemplates[index];
    }

    public String getRepresentation() {
        return representation;
    }

    public static MonetDBLanguage GetLanguageFromString(String language) {
        switch (language) {
            case "sql":
                return LANG_SQL;
            case "mal":
                return LANG_MAL;
            default:
                return LANG_UNKNOWN;
        }
    }
}