Class Command (0.25.0)

public abstract class Command

This abstract class concerns itself with representing a method of matching a specific statement and translating it to a form that Spanner understands. The user should call is() to determine whether it matches before trying to translate.

Inheritance

java.lang.Object > Command

Static Methods

getCommands(String sql, Connection connection, JSONObject commandMetadataJSON)

public static List<Command> getCommands(String sql, Connection connection, JSONObject commandMetadataJSON)

The list of all subcommands to this command. When subclassing this, make sure to add the new command to the below list, if applicable (i.e.: if you want it to be run). Commands may also be specified via Dynamic Commands, which are defined from an input JSON file. These commands precede the hard-coded ones in execution.

Parameters
NameDescription
sqlString

The SQL command to be translated.

connectionConnection

The connection currently in use.

commandMetadataJSONorg.json.simple.JSONObject
Returns
TypeDescription
List<Command>

A list of all Command subclasses.

Fields

matcher

protected Matcher matcher
Field Value
TypeDescription
Matcher

sql

protected String sql
Field Value
TypeDescription
String

Methods

getPattern()

protected abstract Pattern getPattern()

The pattern expected by this command: is() will only return true if it matches this pattern.

Returns
TypeDescription
Pattern

The pattern apposite (in relation to) the command.

is()

public boolean is()
Returns
TypeDescription
boolean

True if the SQL statement matches the pattern.

translate()

public abstract String translate()
Returns
TypeDescription
String

The equivalent Spanner statement for the specified SQL statement.