public class QualifiedName extends Object
A qualified name can be represented in two ways:
For table names, the structured fields provide:
// Legacy list-based construction
QualifiedName q1 = new QualifiedName("schema", "table");
// Structured table name construction
QualifiedName q2 = QualifiedName.forTable("mydb", "dbo", "users");
// Apply defaults for unqualified names
QualifiedName q3 = QualifiedName.forTable(null, null, "users")
.withDefaults("mydb", "dbo");
// Result: catalog=mydb, schema=dbo, name=users
QualifiedNameResolver| Constructor and Description |
|---|
QualifiedName(List<String> parts)
Create a qualified name from a list of parts (legacy mode).
|
QualifiedName(String... parts)
Create a qualified name from varargs parts (legacy mode).
|
| Modifier and Type | Method and Description |
|---|---|
QualifiedName |
append(String part)
Returns a new qualified name with an additional part appended (legacy mode).
|
boolean |
equals(Object o) |
boolean |
equalsIgnoreCase(QualifiedName other)
Check equality ignoring case.
|
static QualifiedName |
forTable(String tableName)
Create a qualified name from just the table name.
|
static QualifiedName |
forTable(String schema,
String tableName)
Create a qualified name from schema and table name.
|
static QualifiedName |
forTable(String catalog,
String schema,
String tableName)
Create a structured qualified name for a table.
|
String |
getCatalog()
Get the catalog (database) part.
|
String |
getFirstPart() |
String |
getLastPart() |
String |
getName()
Alias for getTableName() - returns the object name.
|
String |
getPart(int index) |
int |
getPartCount() |
List<String> |
getParts() |
String |
getSchema()
Get the schema part.
|
String |
getTableName()
Get the table name.
|
boolean |
hasCatalog()
Check if this qualified name has a catalog specified.
|
int |
hashCode() |
boolean |
hasSchema()
Check if this qualified name has a schema specified.
|
boolean |
isFullyQualified()
Check if this is a fully qualified name (all three parts in structured mode).
|
boolean |
isStructuredMode()
Check if this instance uses structured mode.
|
boolean |
matches(QualifiedName other,
INameMatcher matcher)
Check if this qualified name matches another, using the given name matcher.
|
boolean |
matchesExact(QualifiedName other,
INameMatcher matcher)
Check exact match (all parts must match, including nulls).
|
QualifiedName |
prepend(String part)
Returns a new qualified name with an additional part prepended (legacy mode).
|
QualifiedName |
removeFirst()
Returns a new qualified name with the first part removed (legacy mode).
|
QualifiedName |
toFullyQualified(String defaultCatalog,
String defaultSchema)
Create a fully qualified name by applying defaults for all missing parts.
|
String |
toNormalizedKey()
Create a key suitable for use in maps/sets.
|
String |
toString() |
String |
toStringWithPlaceholders(String catalogPlaceholder,
String schemaPlaceholder)
Convert to a fully qualified string representation, using placeholders for missing parts.
|
QualifiedName |
withDefaults(String defaultCatalog,
String defaultSchema)
Create a new qualified name by filling in missing parts from defaults.
|
public QualifiedName(List<String> parts)
public QualifiedName(String... parts)
public static QualifiedName forTable(String catalog, String schema, String tableName)
catalog - The catalog/database name (nullable)schema - The schema name (nullable)tableName - The table name (required)public static QualifiedName forTable(String tableName)
public static QualifiedName forTable(String schema, String tableName)
public int getPartCount()
public String getFirstPart()
public String getLastPart()
public String getCatalog()
public String getTableName()
public boolean isStructuredMode()
public boolean hasCatalog()
public boolean hasSchema()
public boolean isFullyQualified()
public QualifiedName removeFirst()
public QualifiedName prepend(String part)
public QualifiedName append(String part)
public QualifiedName withDefaults(String defaultCatalog, String defaultSchema)
This does NOT override existing parts - it only fills in nulls. Only works in structured mode.
defaultCatalog - The default catalog to use if this.catalog is nulldefaultSchema - The default schema to use if this.schema is nullpublic QualifiedName toFullyQualified(String defaultCatalog, String defaultSchema)
defaultCatalog - The default catalogdefaultSchema - The default schemapublic boolean matches(QualifiedName other, INameMatcher matcher)
Matching rules:
other - The other qualified name to comparematcher - The name matcher for comparison (handles case sensitivity)public boolean matchesExact(QualifiedName other, INameMatcher matcher)
public String toNormalizedKey()
The key is lowercase and includes all three parts separated by null characters to ensure uniqueness.
public String toStringWithPlaceholders(String catalogPlaceholder, String schemaPlaceholder)
catalogPlaceholder - Placeholder for missing catalog (e.g., "*" or "?")schemaPlaceholder - Placeholder for missing schemapublic boolean equalsIgnoreCase(QualifiedName other)
other - The other qualified name