Package io.debezium.relational
Class TableId
- java.lang.Object
-
- io.debezium.relational.TableId
-
- All Implemented Interfaces:
DataCollectionId,Comparable<TableId>
@Immutable public final class TableId extends Object implements DataCollectionId, Comparable<TableId>
Unique identifier for a database table.- Author:
- Randall Hauch
-
-
Field Summary
Fields Modifier and Type Field Description private StringcatalogNameprivate Stringidprivate StringschemaNameprivate StringtableName
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcatalog()Get the name of the JDBC catalog.intcompareTo(TableId that)intcompareToIgnoreCase(TableId that)booleanequals(Object obj)inthashCode()Stringidentifier()Get the fully qualified identifier of the data collection.static TableIdparse(String str)Parse the supplied string, extracting up to the first 3 parts into a TableID.protected static TableIdparse(String[] parts, int numParts, boolean useCatalogBeforeSchema)Parse the supplied string, extracting up to the first 3 parts into a TableID.static TableIdparse(String str, boolean useCatalogBeforeSchema)Parse the supplied string, extracting up to the first 3 parts into a TableID.private static Stringquote(String identifierPart, char quotingChar)Quotes the given identifier part, e.g.private static Stringrepeat(char quotingChar)Stringschema()Get the name of the JDBC schema.Stringtable()Get the name of the table.private static StringtableId(String catalog, String schema, String table)TableIdtoDoubleQuoted()Returns a newTableIdwith all parts of the identifier using"character.StringtoDoubleQuotedString()Returns a dot-separated String representation of this identifier, quoting all name parts with the"char.TableIdtoLowercase()TableIdtoQuoted(char quotingChar)Returns a newTableIdthat has all parts of the identifier quoted.StringtoQuotedString(char quotingChar)Returns a dot-separated String representation of this identifier, quoting all name parts with the given quoting char.StringtoString()
-
-
-
Constructor Detail
-
TableId
public TableId(String catalogName, String schemaName, String tableName, Selectors.TableIdToStringMapper tableIdMapper)
Create a new table identifier.- Parameters:
catalogName- the name of the database catalog that contains the table; may be null if the JDBC driver does not show a schema for this tableschemaName- the name of the database schema that contains the table; may be null if the JDBC driver does not show a schema for this tabletableName- the name of the table; may not be nulltableIdMapper- the customization of fully quailified table name
-
TableId
public TableId(String catalogName, String schemaName, String tableName)
Create a new table identifier.- Parameters:
catalogName- the name of the database catalog that contains the table; may be null if the JDBC driver does not show a schema for this tableschemaName- the name of the database schema that contains the table; may be null if the JDBC driver does not show a schema for this tabletableName- the name of the table; may not be null
-
-
Method Detail
-
parse
public static TableId parse(String str)
Parse the supplied string, extracting up to the first 3 parts into a TableID.- Parameters:
str- the string representation of the table identifier; may not be null- Returns:
- the table ID, or null if it could not be parsed
-
parse
public static TableId parse(String str, boolean useCatalogBeforeSchema)
Parse the supplied string, extracting up to the first 3 parts into a TableID.- Parameters:
str- the string representation of the table identifier; may not be nulluseCatalogBeforeSchema-trueif the parsed string contains only 2 items and the first should be used as the catalog and the second as the table name, orfalseif the first should be used as the schema and the second as the table name- Returns:
- the table ID, or null if it could not be parsed
-
parse
protected static TableId parse(String[] parts, int numParts, boolean useCatalogBeforeSchema)
Parse the supplied string, extracting up to the first 3 parts into a TableID.- Parameters:
parts- the parts of the identifier; may not be nullnumParts- the number of parts to use for the table identifieruseCatalogBeforeSchema-trueif the parsed string contains only 2 items and the first should be used as the catalog and the second as the table name, orfalseif the first should be used as the schema and the second as the table name- Returns:
- the table ID, or null if it could not be parsed
-
catalog
public String catalog()
Get the name of the JDBC catalog.- Returns:
- the catalog name, or null if the table does not belong to a catalog
-
schema
public String schema()
Get the name of the JDBC schema.- Returns:
- the JDBC schema name, or null if the table does not belong to a JDBC schema
-
table
public String table()
Get the name of the table.- Returns:
- the table name; never null
-
identifier
public String identifier()
Description copied from interface:DataCollectionIdGet the fully qualified identifier of the data collection.- Specified by:
identifierin interfaceDataCollectionId- Returns:
- the collection's fully qualified identifier.
-
compareTo
public int compareTo(TableId that)
- Specified by:
compareToin interfaceComparable<TableId>
-
compareToIgnoreCase
public int compareToIgnoreCase(TableId that)
-
toDoubleQuotedString
public String toDoubleQuotedString()
Returns a dot-separated String representation of this identifier, quoting all name parts with the"char.
-
toDoubleQuoted
public TableId toDoubleQuoted()
Returns a newTableIdwith all parts of the identifier using"character.
-
toQuoted
public TableId toQuoted(char quotingChar)
Returns a newTableIdthat has all parts of the identifier quoted.- Parameters:
quotingChar- the character to be used to quote the identifier parts.
-
toQuotedString
public String toQuotedString(char quotingChar)
Returns a dot-separated String representation of this identifier, quoting all name parts with the given quoting char.
-
quote
private static String quote(String identifierPart, char quotingChar)
Quotes the given identifier part, e.g. schema or table name.
-
repeat
private static String repeat(char quotingChar)
-
toLowercase
public TableId toLowercase()
-
-