Class QualifiedName
Object
gudusoft.gsqlparser.resolver2.model.QualifiedName
Represents a fully qualified name for a database object (table, view, etc.).
A qualified name can be represented in two ways:
- As a list of parts (legacy mode) - for generic N-part names
- As explicit catalog/schema/name (structured mode) - for table names
For table names, the structured fields provide:
- catalog (database) - The top-level container (e.g., "mydb")
- schema - The schema within the catalog (e.g., "dbo", "public")
- name - The object name itself (e.g., "users", "orders")
Usage Examples
// 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
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionQualifiedName(String... parts) Create a qualified name from varargs parts (legacy mode).QualifiedName(List<String> parts) Create a qualified name from a list of parts (legacy mode). -
Method Summary
Modifier and TypeMethodDescriptionReturns a new qualified name with an additional part appended (legacy mode).booleanbooleanequalsIgnoreCase(QualifiedName other) Check equality ignoring case.static QualifiedNameCreate a qualified name from just the table name.static QualifiedNameCreate a qualified name from schema and table name.static QualifiedNameCreate a structured qualified name for a table.Get the catalog (database) part.getName()Alias for getTableName() - returns the object name.getPart(int index) intgetParts()Get the schema part.Get the table name.booleanCheck if this qualified name has a catalog specified.inthashCode()booleanCheck if this qualified name has a schema specified.booleanCheck if this is a fully qualified name (all three parts in structured mode).booleanCheck if this instance uses structured mode.booleanmatches(QualifiedName other, INameMatcher matcher) Check if this qualified name matches another, using the given name matcher.booleanmatchesExact(QualifiedName other, INameMatcher matcher) Check exact match (all parts must match, including nulls).Returns a new qualified name with an additional part prepended (legacy mode).Returns a new qualified name with the first part removed (legacy mode).toFullyQualified(String defaultCatalog, String defaultSchema) Create a fully qualified name by applying defaults for all missing parts.Create a key suitable for use in maps/sets.toString()toStringWithPlaceholders(String catalogPlaceholder, String schemaPlaceholder) Convert to a fully qualified string representation, using placeholders for missing parts.withDefaults(String defaultCatalog, String defaultSchema) Create a new qualified name by filling in missing parts from defaults.
-
Constructor Details
-
QualifiedName
Create a qualified name from a list of parts (legacy mode). -
QualifiedName
Create a qualified name from varargs parts (legacy mode).
-
-
Method Details
-
forTable
Create a structured qualified name for a table.- Parameters:
catalog- The catalog/database name (nullable)schema- The schema name (nullable)tableName- The table name (required)- Returns:
- A new QualifiedName in structured mode
-
forTable
Create a qualified name from just the table name. -
forTable
Create a qualified name from schema and table name. -
getParts
-
getPartCount
-
getPart
-
getFirstPart
-
getLastPart
-
getCatalog
Get the catalog (database) part. Only meaningful in structured mode. -
getSchema
Get the schema part. Only meaningful in structured mode. -
getTableName
Get the table name. In structured mode, returns the explicit table name. In legacy mode, returns the last part. -
getName
Alias for getTableName() - returns the object name. -
isStructuredMode
Check if this instance uses structured mode. -
hasCatalog
Check if this qualified name has a catalog specified. -
hasSchema
Check if this qualified name has a schema specified. -
isFullyQualified
Check if this is a fully qualified name (all three parts in structured mode). -
removeFirst
Returns a new qualified name with the first part removed (legacy mode). -
prepend
Returns a new qualified name with an additional part prepended (legacy mode). -
append
Returns a new qualified name with an additional part appended (legacy mode). -
withDefaults
Create a new qualified name by filling in missing parts from defaults.This does NOT override existing parts - it only fills in nulls. Only works in structured mode.
- Parameters:
defaultCatalog- The default catalog to use if this.catalog is nulldefaultSchema- The default schema to use if this.schema is null- Returns:
- A new qualified name with defaults applied
-
toFullyQualified
Create a fully qualified name by applying defaults for all missing parts.- Parameters:
defaultCatalog- The default catalogdefaultSchema- The default schema- Returns:
- A fully qualified name (all three parts set)
-
matches
Check if this qualified name matches another, using the given name matcher.Matching rules:
- Object names must always match
- If both have schemas, they must match
- If both have catalogs, they must match
- Missing parts (null) are treated as wildcards
- Parameters:
other- The other qualified name to comparematcher- The name matcher for comparison (handles case sensitivity)- Returns:
- true if the names match according to the rules
-
matchesExact
Check exact match (all parts must match, including nulls). -
toNormalizedKey
Create a key suitable for use in maps/sets.The key is lowercase and includes all three parts separated by null characters to ensure uniqueness.
-
toString
-
toStringWithPlaceholders
Convert to a fully qualified string representation, using placeholders for missing parts.- Parameters:
catalogPlaceholder- Placeholder for missing catalog (e.g., "*" or "?")schemaPlaceholder- Placeholder for missing schema- Returns:
- String like "*.*.name" or "catalog.*.name"
-
equals
-
hashCode
-
equalsIgnoreCase
Check equality ignoring case.- Parameters:
other- The other qualified name- Returns:
- true if all parts match (ignoring case)
-