Package uk.ac.starlink.vo

# Class AdqlSyntax

java.lang.Object
uk.ac.starlink.table.jdbc.SqlSyntax
uk.ac.starlink.vo.AdqlSyntax

public class AdqlSyntax extends uk.ac.starlink.table.jdbc.SqlSyntax
SqlSyntax instance for the ADQL 2.* grammar.

Instances `INSTANCE20` and `INSTANCE21` are currently provided for ADQL versions 2.0 and 2.1 respectively. However the differences between these are very small (just a few extra reserved words for V2.1) so the method `getInstance()` is usually an appropriate way to obtain an instance of this class.

Since:
  22 Jun 2011
Author:
  Mark Taylor
See Also:
  - ADQL 2.0 Standard
  - ADQL 2.0 BNF

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String[]`
`ADQL_RESERVED`
ADQL reserved words additional to the SQL92 set, taken from the ADQL standard.
`static final String[]`
`ADQL21_RESERVED`
Additional reserved words from ADQL 2.1 section 2.1.4.
`static final AdqlSyntax`
`INSTANCE20`
Instance for V2.0 of the ADQL standard.
`static final AdqlSyntax`
`INSTANCE21`
Instance for V2.1 of the ADQL standard.

### Fields inherited from class uk.ac.starlink.table.jdbc.SqlSyntax

`SQL92_IDENTIFIER_REGEX, SQL92_RESERVED`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`AdqlSyntax(AdqlVersion adqlVersion)`
Protected constructor to signal that static instances or methods should usually be used to obtain an instance.

## Method Summary

Modifier and Type
Method
Description
`String`
`characterLiteral(String txt)`
Returns ADQL text representing a character literal.
`String[]`
`getCatalogSchemaTable(String tableName)`
Takes an ADQL `<table_name>` token and returns a 3-element array giving the catalog, schema and table (delimited or regular) identifiers.
`static AdqlSyntax`
`getInstance()`
Returns an instance of this class.
`boolean`
`isAdqlColumnName(String token)`
Indicates whether the given token matches the ADQL `<column_name>` production.
`boolean`
`isAdqlDelimitedIdentifier(String token)`
Indicates whether the given token matches the ADQL `<delimited_identifier>` production.
`boolean`
`isAdqlTableName(String token)`
Indicates whether the given token matches the ADQL `<table_name>` production.
`String`
`unquote(String identifier)`
Takes a regular-or-delimited-identifier and returns its raw form.

### Methods inherited from class uk.ac.starlink.table.jdbc.SqlSyntax

`getParanoidReservedWords, getReservedWords, isIdentifier, isReserved, quote, quoteIfNecessary`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### ADQL_RESERVED

public static final String[] ADQL_RESERVED
ADQL reserved words additional to the SQL92 set, taken from the ADQL standard.

### ADQL21_RESERVED

public static final String[] ADQL21_RESERVED
Additional reserved words from ADQL 2.1 section 2.1.4.

### INSTANCE20

public static final AdqlSyntax INSTANCE20
Instance for V2.0 of the ADQL standard.

### INSTANCE21

public static final AdqlSyntax INSTANCE21
Instance for V2.1 of the ADQL standard.

## Constructor Details

### AdqlSyntax

protected AdqlSyntax(AdqlVersion adqlVersion)
Protected constructor to signal that static instances or methods should usually be used to obtain an instance.

Parameters:
  `adqlVersion` - version of the ADQL standard

## Method Details

### isAdqlDelimitedIdentifier

public boolean isAdqlDelimitedIdentifier(String token)
Indicates whether the given token matches the ADQL `<delimited_identifier>` production.

Parameters:
  `token` - token to test
Returns:
  true iff token is a delimited_identifier

### isAdqlColumnName

public boolean isAdqlColumnName(String token)
Indicates whether the given token matches the ADQL `<column_name>` production.

Parameters:
  `token` - token to test
Returns:
  true iff token is a column_name

### isAdqlTableName

public boolean isAdqlTableName(String token)
Indicates whether the given token matches the ADQL `<table_name>` production.

Parameters:
  `token` - token to test
Returns:
  true iff token is a table_name

### getCatalogSchemaTable

public String[] getCatalogSchemaTable(String tableName)
Takes an ADQL `<table_name>` token and returns a 3-element array giving the catalog, schema and table (delimited or regular) identifiers.

For a non-null result, the input token must match the ADQL `<table_name>` production, which is the same rule that TAP_SCHEMA table_name columns must follow, which roughly means it's of the form [catalog.[schema.[table]]]. Either catalog alone, or both catalog and schema, may be null. The return value is either a three-element array (with 1, 2 or 3 non-null elements) in case of a legal table_name input, or null in case of an illegal table_name input.

Parameters:
  `tableName` - table_name string
Returns:
  3-element array giving (catalog, schema, table) identifiers, or null for parse failure

### unquote

public String unquote(String identifier)
Takes a regular-or-delimited-identifier and returns its raw form. For a regular identifier, the output is the same as the input.

Parameters:
  `identifier` - regular or delimited identifier, or null
Returns:
  identifier with no surrounding quotes or other escaping, or null for null input

### characterLiteral

public String characterLiteral(String txt)
Returns ADQL text representing a character literal. This quotes the supplied string by surrounding it with single quotes, escaping any internal single quote characters appropriately.

Parameters:
  `txt` - raw text
Returns:
  character literal suitable for insertion into ADQL text

### getInstance

public static AdqlSyntax getInstance()
Returns an instance of this class. This currently returns the instance representing ADQL 2.1. There is very little difference between this and the ADQL 2.0 instance, just a few extra reserved words, so it's suitable for general use in most cases.

Returns:
  AdqlSyntax instance