java.lang.Object
org.postgresql.pljava.sqlgen.Lexicals.Identifier
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Lexicals.Identifier.Qualified
,Lexicals.Identifier.Unqualified
- Enclosing class:
Lexicals
Class representing a SQL identifier. These have wild and wooly behavior
depending on whether they were represented in the source in quoted form
or not. Quoted ones are case-sensitive,
and
equals
will only recognize exact matches.
Non-quoted ones match case-insensitively; just to make this interesting,
ISO SQL has one set of case-folding rules, while PostgreSQL has another.
Also, a non-quoted identifier can match a quoted one, if the quoted one's
exact spelling matches the non-quoted one's case-folded form.
For even more fun, the PostgreSQL rules depend on the server encoding. For any multibyte encoding, only the 26 ASCII uppercase letters are folded to lower, leaving all other characters alone. In single-byte encodings, more letters can be touched. But this code has to run in a javac annotation processor without knowledge of any particular database's server encoding. The recommended encoding, UTF-8, is multibyte, so the PostgreSQL rule will be taken to be: only the 26 ASCII letters, always.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
What is the name of an unnamed parameter or column?static class
Class representing an Identifier that names a PostgreSQL operator.static final class
Displays/deparses like aSimple
identifier, but no singleton of this class matches anything but itself, to represent pseudo-identifiers likePUBLIC
as a privilege grantee.static class
Class representing a schema-qualified identifier.static class
Class representing an unqualified identifier in the form of a name (whether a case-insensitive "regular identifier" without quotes, or a delimited form).static class
-
Method Summary
Modifier and TypeMethodDescriptionabstract String
This Identifier represented as it would be in SQL source.boolean
Equality test with the case-sensitivity rules of SQL.abstract boolean
For use in an annotation processor, a version ofequals
that can take aMessager
and use it to emit warnings.boolean
Whether this instance represents the name of something unnamed.toString()
Convert toString
as bydeparse
passing a character set ofUTF_8
.
-
Method Details
-
deparse
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.- Returns:
- The identifier, quoted, unless it is folding.
-
equals
Equality test with the case-sensitivity rules of SQL. -
equals
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.- 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.
-
toString
Convert toString
as bydeparse
passing a character set ofUTF_8
. -
isUnnamed
public boolean isUnnamed()Whether this instance represents the name of something unnamed.- Returns:
- false except where overridden
- See Also:
-