public class NameService extends Object
Equality delegates to IdentifierService.areEqual(java.lang.String, java.lang.String, gudusoft.gsqlparser.sqlenv.ESQLDataObjectType) on THIS service's configured
profile and the set/dedup utilities key by CanonKey from the same service, so every
operation here observes exactly one relation. Built from a bare vendor that relation is the
vendor default (SQLUtil.sameName / TSQLEnv.compareIdentifier); built from an
analysis's IdentifierService it is that analysis's effective configuration. The previous
implementation routed through the SqlNameMatcher framework configured from the legacy
per-type case booleans, which collapsed quoted-case distinctions the canonical rules
preserve (e.g. BigQuery tables, Couchbase).
| Constructor and Description |
|---|
NameService(EDbVendor vendor)
Creates a new NameService under the vendor's DEFAULT identifier configuration.
|
| Modifier and Type | Method and Description |
|---|---|
Set<String> |
createSet(ESQLDataObjectType type)
Creates a Set whose membership follows canonical name equality: names are the
same element iff their
CanonKeys are equal. |
List<String> |
distinctCopy(ESQLDataObjectType type,
Iterable<String> names)
Creates a distinct copy of a collection, removing canonical duplicates.
|
boolean |
equals(ESQLDataObjectType type,
String name1,
String name2)
Checks if two names are equal under the canonical identifier-equality relation
(
IdentifierService.areEqual(java.lang.String, java.lang.String, gudusoft.gsqlparser.sqlenv.ESQLDataObjectType)) for this service’s configuration and object type. |
static NameService |
forIdentifierService(IdentifierService service)
A NameService over ONE analysis's identifier service, so the comparisons and sets built here
observe that analysis's per-category configuration instead of the vendor default.
|
IdentifierProfile |
getIdentifierProfile()
The effective identifier configuration behind
getIdentifierService(). |
IdentifierService |
getIdentifierService()
The identifier service every comparison here delegates to — the single engine, configured
for this environment.
|
EDbVendor |
getVendor()
Returns the database vendor associated with this service.
|
int |
indexOf(ESQLDataObjectType type,
Iterable<String> names,
String target)
Finds the index of a name in a collection under canonical equality.
|
boolean |
isCaseSensitive(ESQLDataObjectType type)
Whether the UNQUOTED comparison policy for this object type is case-sensitive.
|
public NameService(EDbVendor vendor)
vendor - the database vendorpublic static NameService forIdentifierService(IdentifierService service)
A factory rather than a constructor overload on purpose: new NameService(null)
would otherwise become ambiguous against NameService(EDbVendor) and break callers
that already compile.
service - the frozen service of the current analysispublic IdentifierService getIdentifierService()
public IdentifierProfile getIdentifierProfile()
getIdentifierService().public EDbVendor getVendor()
public boolean equals(ESQLDataObjectType type, String name1, String name2)
IdentifierService.areEqual(java.lang.String, java.lang.String, gudusoft.gsqlparser.sqlenv.ESQLDataObjectType)) for this service’s configuration and object type.type - the SQL object type (table, column, function, etc.)name1 - the first name to comparename2 - the second name to comparepublic int indexOf(ESQLDataObjectType type, Iterable<String> names, String target)
This is a case-aware version of List.indexOf().
type - the SQL object typenames - the collection of names to searchtarget - the name to findpublic List<String> distinctCopy(ESQLDataObjectType type, Iterable<String> names)
Preserves insertion order and the first spelling seen. For example, for a case-insensitive domain:
["foo", "FOO", "bar", "Bar"] → ["foo", "bar"]
type - the SQL object typenames - the collection of names (may contain duplicates)public Set<String> createSet(ESQLDataObjectType type)
CanonKeys are equal.type - the SQL object typepublic boolean isCaseSensitive(ESQLDataObjectType type)
Quoted operands may follow a different rule (quoted-case-preserving vendors);
this describes only the unquoted policy from the vendor's identifier rules. A
collation-based cell answers from its collation (_CS_AI, _BIN2: yes;
_CI_AS: no) — see IdentifierService.isCaseSensitive(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType).
type - the object type