public final class SqlNameGenerator extends Object
See docs/refactor/identifier/README.md, "Catalog inputs and name output".
This capability lets existing getters such as
procedure.getName() can keep their historical output while correct
quoting, escaping and qualification live in one place that actually promises
them.
db name, not [db name].
A stored name whose real content includes delimiter characters
([db name] with the brackets being part of the name) is legal
input and is escaped, not reinterpreted.db.part) is ONE segment. This class never splits a segment and
never joins pre-rendered text.dbo, no current database. A missing or
empty segment is a failure, not a hint to fill in.Validity is at the identifier level: delimiters, escaping, characters and segment structure. Whether the vendor accepts that many segments in a given statement position, length limits, and whether the object exists are outside this class.
| Modifier and Type | Class and Description |
|---|---|
static class |
SqlNameGenerator.Failure
Why a name could not be generated.
|
static class |
SqlNameGenerator.QuotePolicy
How to choose between the bare and the delimited spelling of a segment.
|
static class |
SqlNameGenerator.Result
Outcome of a generation: either the SQL text, or the reason there is none.
|
static class |
SqlNameGenerator.Segment
One stored name segment together with its syntactic role.
|
| Modifier and Type | Method and Description |
|---|---|
static SqlNameGenerator.Result |
generate(EDbVendor vendor,
List<SqlNameGenerator.Segment> segments)
Convenience for callers holding an immutable segment list.
|
static SqlNameGenerator.Result |
generate(EDbVendor vendor,
SqlNameGenerator.QuotePolicy policy,
List<SqlNameGenerator.Segment> segments)
Generate a SQL name.
|
static SqlNameGenerator.Result |
generate(EDbVendor vendor,
SqlNameGenerator.QuotePolicy policy,
SqlNameGenerator.Segment... segments) |
static SqlNameGenerator.Result |
generate(EDbVendor vendor,
SqlNameGenerator.Segment... segments)
Generate with every segment delimited.
|
static SqlNameGenerator.Result |
respell(EDbVendor vendor,
SqlNameGenerator.QuotePolicy policy,
ESQLDataObjectType role,
String lexical)
Re-spell ONE identifier that was read from SQL text, as valid SQL naming the same object.
|
public static SqlNameGenerator.Result generate(EDbVendor vendor, SqlNameGenerator.Segment... segments)
public static SqlNameGenerator.Result generate(EDbVendor vendor, SqlNameGenerator.QuotePolicy policy, SqlNameGenerator.Segment... segments)
public static SqlNameGenerator.Result generate(EDbVendor vendor, SqlNameGenerator.QuotePolicy policy, List<SqlNameGenerator.Segment> segments)
vendor - target dialect (non-null)policy - bare-versus-delimited choice (non-null)segments - stored name segments, outermost firstpublic static SqlNameGenerator.Result respell(EDbVendor vendor, SqlNameGenerator.QuotePolicy policy, ESQLDataObjectType role, String lexical)
This is the entry point for a name that HAS a source spelling, as opposed to
generate(gudusoft.gsqlparser.EDbVendor, gudusoft.gsqlparser.sqlenv.SqlNameGenerator.Segment...), which starts from a stored name. The difference matters for case:
DB51_CAD into db51_cad.generate(gudusoft.gsqlparser.EDbVendor, gudusoft.gsqlparser.sqlenv.SqlNameGenerator.Segment...) decides whether the delimiters can be dropped.So two references to one object may still re-spell differently (Sales and
SALES on Oracle). Making a LISTING show one of them is the job of identity
grouping plus a display-name policy, which can consult the catalog; it is not something a
single spelling can decide.
public static SqlNameGenerator.Result generate(EDbVendor vendor, List<SqlNameGenerator.Segment> segments)