- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Lexicals.Identifier.None
,Lexicals.Identifier.Pseudo
- Enclosing class:
Lexicals.Identifier
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.postgresql.pljava.sqlgen.Lexicals.Identifier
Lexicals.Identifier.None, Lexicals.Identifier.Operator, Lexicals.Identifier.Pseudo, Lexicals.Identifier.Qualified<T extends Lexicals.Identifier.Unqualified<T>>, Lexicals.Identifier.Simple, Lexicals.Identifier.Unqualified<T extends Lexicals.Identifier.Unqualified<T>>
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionConcatenates one or more strings or identifiers to the end of this identifier.This Identifier represented as it would be in SQL source.deparse
(Lexicals.Identifier.Simple qualifier, Charset cs) Produce the deparsed form of a qualified identifier with the given qualifier and this as the local part.boolean
For use in an annotation processor, a version ofequals
that can take aMessager
and use it to emit warnings.boolean
folds()
Whether this Identifier case-folds.static Lexicals.Identifier.Simple
Create anIdentifier.Simple
given its original, non-folded spelling, and whether it represents a quoted identifier.static Lexicals.Identifier.Simple
Create anIdentifier.Simple
from a name string found in a PostgreSQL system catalog.static Lexicals.Identifier.Simple
Create anIdentifier.Simple
from a name string supplied in Java source, such as an annotation value.static Lexicals.Identifier.Simple
Create anIdentifier.Simple
from a name string supplied in Java source, such as an annotation value.int
hashCode()
For a quoted identifier that could not match any non-quoted one, the hash code of its non-folded spelling is good enough.This Identifier as ISO SQL would case-fold it (or the same as nonFolded if this was quoted and does not fold).This Identifier's original spelling.static String
Case-fold a string by the PostgreSQL rules (assuming a multibyte server encoding, where only the 26 uppercase ASCII letters fold to lowercase).pgFolded()
This Identifier as PostgreSQL would case-fold it (or the same as nonFolded if this was quoted and does not fold).withQualifier
(Lexicals.Identifier.Simple qualifier) Form anIdentifier.Qualified
with this as the local part.Methods inherited from class org.postgresql.pljava.sqlgen.Lexicals.Identifier
equals, isUnnamed, toString
-
Field Details
-
m_nonFolded
-
-
Method Details
-
from
Create anIdentifier.Simple
given its original, non-folded spelling, and whether it represents a quoted identifier.- Parameters:
s
- The exact, internal, non-folded spelling of the identifier (unwrapped from any quoting in its external form).quoted
- Passtrue
if this was parsed from any quoted external form, false if non-quoted.- Returns:
- A corresponding Identifier.Simple
- Throws:
IllegalArgumentException
- ifquoted
isfalse
buts
cannot be a non-quoted identifier, ors
is empty or longer than the ISO SQL maximum 128 codepoints.
-
concat
Concatenates one or more strings or identifiers to the end of this identifier.The arguments may be instances of
Simple
(but not ofNone
) or ofCharSequence
, in any combination.The resulting identifier folds if this identifier and all identifier arguments fold and the concatenation (with all
Simple
andCharSequence
components included) still matches theISO_AND_PG_REGULAR_IDENTIFIER
pattern. -
fromCatalog
Create anIdentifier.Simple
from a name string found in a PostgreSQL system catalog.There is not an explicit indication in the catalog of whether the name was originally quoted. It must have been, however, if it does not have the form of a regular identifier, or if it has that form but does not match its pgFold-ed form (without quotes, PG would have folded it in that case).
The PostgreSQL catalogs can contain empty strings in some contexts where a name might not be provided (for example, when
pg_proc.proargnames
is present because some parameters have names but not all of them do). So this method can accept an empty string, returning theNone
instance.- Parameters:
s
- name of the simple identifier, as found in a system catalog.- Returns:
- an Identifier.Simple or subclass appropriate to the form of the name.
-
fromJava
Create anIdentifier.Simple
from a name string supplied in Java source, such as an annotation value.Equivalent to
fromJava(s, null)
. -
fromJava
Create anIdentifier.Simple
from a name string supplied in Java source, such as an annotation value.Historically, PL/Java has treated these identifiers as regular ones, requiring delimited ones to be represented by adding quotes explicitly at start and end, and doubling internal quotes, all escaped for Java, naturally. This method accepts either of those forms, and will also accept a string that neither qualifies as a regular identifier nor starts and ends with quotes. Such a string will be treated as if it were a delimited identifier with the start/end quotes already stripped and internal ones already undoubled.
The SQL Unicode escape syntax is not accepted here. Java already has its own Unicode escape syntax, which is what should be used.
- Parameters:
s
- name of the simple identifier, as found in Java source.msgr
- a Messager for reporting diagnostics at compile time, or null if not in a compilation context.- Returns:
- an Identifier.Simple or subclass appropriate to the form of the name.
-
withQualifier
public Lexicals.Identifier.Qualified<Lexicals.Identifier.Simple> withQualifier(Lexicals.Identifier.Simple qualifier) Description copied from class:Lexicals.Identifier.Unqualified
Form anIdentifier.Qualified
with this as the local part.- Specified by:
withQualifier
in classLexicals.Identifier.Unqualified<Lexicals.Identifier.Simple>
-
deparse
Description copied from class:Lexicals.Identifier
This Identifier represented as it would be in SQL source.The passed
Charset
indicates the character encoding in which the deparsed result will be stored; the method should verify that the characters can be encoded there, or use the Unicode delimited identifier form and escape the ones that cannot.- Specified by:
deparse
in classLexicals.Identifier
- Returns:
- The identifier, quoted, unless it is folding.
-
deparse
Description copied from class:Lexicals.Identifier.Unqualified
Produce the deparsed form of a qualified identifier with the given qualifier and this as the local part.- Specified by:
deparse
in classLexicals.Identifier.Unqualified<Lexicals.Identifier.Simple>
-
folds
public boolean folds()Whether this Identifier case-folds.- Returns:
- true if this Identifier was non-quoted in the source, false if it was quoted.
-
nonFolded
This Identifier's original spelling.- Returns:
- The spelling as seen in the source, with no case folding.
-
pgFolded
This Identifier as PostgreSQL would case-fold it (or the same as nonFolded if this was quoted and does not fold).- Returns:
- The spelling with ASCII letters (only) folded to lowercase, if this Identifier folds.
-
isoFolded
This Identifier as ISO SQL would case-fold it (or the same as nonFolded if this was quoted and does not fold).- Returns:
- The spelling with lowercase and titlecase letters folded to (possibly length-changing) uppercase equivalents, if this Identifier folds.
-
hashCode
public int hashCode()For a quoted identifier that could not match any non-quoted one, the hash code of its non-folded spelling is good enough. In other cases, the code must be derived more carefully. -
equals
Description copied from class:Lexicals.Identifier
For use in an annotation processor, a version ofequals
that can take aMessager
and use it to emit warnings. It will emit a warning whenever it compares two Identifiers that are equal by one or the other of PostgreSQL's or ISO SQL's rules but not both.- Specified by:
equals
in classLexicals.Identifier
- Parameters:
other
- Object to compare tomsgr
- a Messager to use for warnings; ifnull
, no warnings will be generated.- Returns:
- true if two quoted Identifiers match exactly, or two non-quoted ones match in either the PostgreSQL or ISO SQL folded form, or a quoted one exactly matches either folded form of a non-quoted one.
-
pgFold
Case-fold a string by the PostgreSQL rules (assuming a multibyte server encoding, where only the 26 uppercase ASCII letters fold to lowercase).- Parameters:
s
- The non-folded value.- Returns:
- The folded value.
-