public final class SegmentKeyV1 extends Object
CanonicalSegmentKeyV1 and the decoding of a delimited SQL spelling
(lineage-spec/identifier-rules/FORMAT.md, Sections 7.1 and 9) for one dialect's rule set under fixed
effective flags and collations.
The key is what a SQL-LR document carries as a segment's canonicalKey; it is an encoding of the
standard's rule data, not GSP's name equality. Binding decisions keep going through
IdentifierService; a producer compares the two and refuses a portable identity where they disagree.
Instances are immutable and thread-safe.
| Modifier and Type | Class and Description |
|---|---|
static class |
SegmentKeyV1.Decoded
The outcome of
decode(java.lang.String, java.lang.String): a segment's text and quoteState, or malformed. |
static class |
SegmentKeyV1.Result
The outcome of
key(java.lang.String, java.lang.String, java.lang.String, java.lang.String): a canonical segment key, or UNAVAILABLE_COLLATION. |
| Modifier and Type | Field and Description |
|---|---|
static String |
CATALOG_STORED |
static String |
DRAFT_SNAPSHOT
The path of the dependency snapshot the jar ships.
|
static String |
QUOTED |
static String |
SQL_LEXICAL |
static String |
UNQUOTED |
| Modifier and Type | Method and Description |
|---|---|
SegmentKeyV1.Decoded |
decode(String objectType,
String spelling)
FORMAT.md, Section 7.1: the
text and quoteState of one identifier token's spelling, using
the delimiter set the effective flags resolve for the object type. |
boolean |
definesObjectType(String objectType)
Whether the rule set defines the object type.
|
static SegmentKeyV1 |
draft(String dialect)
forSnapshot(java.util.Map<?, ?>, java.lang.String) of the snapshot the jar ships (DRAFT_SNAPSHOT). |
static SegmentKeyV1 |
forSnapshot(Map<?,?> snapshot,
String dialect)
The key function a dependency snapshot declares for a dialect: its rule set with its effective flags and
collations.
|
Map<String,String> |
getCollations()
The effective collations, by scope.
|
String |
getDialect() |
Map<String,Object> |
getFlags()
The effective flags, every declared flag included.
|
boolean |
hasQuotedForm(String objectType)
Whether a delimited form exists for the object type (its delimiter set is not empty).
|
SegmentKeyV1.Result |
key(String objectType,
String inputForm,
String quoteState,
String text)
CanonicalSegmentKeyV1. |
static SegmentKeyV1 |
of(Map<?,?> rules,
Map<String,?> effectiveFlags,
Map<String,String> effectiveCollations)
The key function of a rule set.
|
String[] |
preferredDelimiters(String objectType)
The preferred delimiters for writing a name of the object type back into SQL (the first entry of its delimiter
set, FORMAT.md Section 7): {open, close}, or
null when the type has no delimited form. |
public static final String DRAFT_SNAPSHOT
public static final String SQL_LEXICAL
public static final String CATALOG_STORED
public static final String QUOTED
public static final String UNQUOTED
public static SegmentKeyV1 of(Map<?,?> rules, Map<String,?> effectiveFlags, Map<String,String> effectiveCollations)
rules - a rule set file, parsedeffectiveFlags - flag values; a declared flag that is absent takes its defaulteffectiveCollations - collation scope (INSTANCE, DATABASE) to vendor collation name; an
absent scope means no collation is declared for itIllegalArgumentException - when the rule set is for another Unicode version than the case operations,
a flag is not declared, or its value is not an exact value of its domainpublic static SegmentKeyV1 forSnapshot(Map<?,?> snapshot, String dialect)
null when the snapshot does not list the dialectIllegalArgumentException - when the entry's dialect, rule set version, digest or Unicode version does
not match the rule set it namespublic static SegmentKeyV1 draft(String dialect)
forSnapshot(java.util.Map<?, ?>, java.lang.String) of the snapshot the jar ships (DRAFT_SNAPSHOT).public String getDialect()
public Map<String,String> getCollations()
public boolean definesObjectType(String objectType)
public SegmentKeyV1.Result key(String objectType, String inputForm, String quoteState, String text)
CanonicalSegmentKeyV1.objectType - an object type code of FORMAT.md, Section 4inputForm - SQL_LEXICAL or CATALOG_STOREDquoteState - QUOTED or UNQUOTED; read for SQL_LEXICAL onlytext - the decoded text (Section 3)IllegalArgumentException - on an input error: unknown object type or input form, missing or invalid
quote state, or text with an unpaired surrogatepublic SegmentKeyV1.Decoded decode(String objectType, String spelling)
text and quoteState of one identifier token's spelling, using
the delimiter set the effective flags resolve for the object type.IllegalArgumentException - when the object type is not definedpublic String[] preferredDelimiters(String objectType)
null when the type has no delimited form.public boolean hasQuotedForm(String objectType)