Class Lexicals.Identifier

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, 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:
Serialized Form
  • Method Details

    • 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)
      Indicates whether some other object is "equal to" this one.
      Overrides:
      equals in class Object
    • equals

      public abstract boolean equals​(Object other, Messager msgr)
      For use in an annotation processor, a version of equals that can take a Messager 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 to
      msgr - a Messager to use for warnings; if null, 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

      public String toString()
      Convert to String as by deparse passing a character set of UTF_8.
      Overrides:
      toString in class Object