- 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
public abstract static class Lexicals.Identifier extends Object implements Serializable
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, andequals
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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Lexicals.Identifier.Operator
Class representing an Identifier that names a PostgreSQL operator.static class
Lexicals.Identifier.Pseudo
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
Lexicals.Identifier.Qualified<T extends Lexicals.Identifier.Unqualified<T>>
Class representing a schema-qualified identifier.static class
Lexicals.Identifier.Simple
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
Lexicals.Identifier.Unqualified<T extends Lexicals.Identifier.Unqualified<T>>
-
Method Summary
Modifier and Type Method Description abstract String
deparse(Charset cs)
This Identifier represented as it would be in SQL source.boolean
equals(Object other)
Equality test with the case-sensitivity rules of SQL.abstract boolean
equals(Object other, Messager msgr)
For use in an annotation processor, a version ofequals
that can take aMessager
and use it to emit warnings.String
toString()
Convert toString
as bydeparse
passing a character set ofUTF_8
.
-
-
-
Method Detail
-
deparse
public abstract String deparse(Charset cs)
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
public boolean equals(Object other)
Equality test with the case-sensitivity rules of SQL.
-
equals
public abstract boolean equals(Object other, Messager msgr)
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.
-
-