Class Lexicals.Identifier.Qualified<T extends Lexicals.Identifier.Unqualified<T>>

    • Method Detail

      • nameFromCatalog

        public static Lexicals.Identifier.Qualified<Lexicals.Identifier.Simple> nameFromCatalog​(String qualifier,
                                                                                                String local)
        Create an Identifier.Qualified from name strings found in PostgreSQL system catalogs.

        There is not an explicit indication in the catalog of whether a 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).

        Parameters:
        qualifier - string with the name of a schema, as found in the pg_namespace system catalog.
        local - string with the local name of an object in that schema.
        Returns:
        an Identifier.Qualified
        Throws:
        NullPointerException - if the local name is null.
      • operatorFromCatalog

        public static Lexicals.Identifier.Qualified<Lexicals.Identifier.Operator> operatorFromCatalog​(String qualifier,
                                                                                                      String local)
        Create an Identifier.Qualified representing an operator from name strings found in PostgreSQL system catalogs.
        Parameters:
        qualifier - string with the name of a schema, as found in the pg_namespace system catalog.
        local - string with the local name of an object in that schema.
        Returns:
        an Identifier.Qualified
        Throws:
        NullPointerException - if the local name is null.
      • nameFromJava

        public static Lexicals.Identifier.Qualified<Lexicals.Identifier.Simple> nameFromJava​(String s,
                                                                                             Messager msgr)
        Create an Identifier.Qualified<Simple> from a name string supplied in Java source, such as an annotation value.

        Explicit delimited-identifier syntax is recognized if it spans the entire string (producing a local name and null qualifier), or from the beginning to a dot (representing the qualifier), or from a dot to the end (representing the local name). If both the qualifier and local name are given in the delimited syntax, they define the result.

        Otherwise, if either component is given in the delimited syntax as above, the other component is taken from the rest of the string on the other side of the dot, as a folding regular identifier if it is one, otherwise as an implicitly quoted one.

        Any subsequence that resembles delimited syntax but does not appear where it is recognized as above will be treated as literal content (so, its quotes will be doubled when deparsed, etc.), and produce a compiler warning if called in a compilation context.

        If neither component is given in delimited syntax, the string must contain at most one dot. If it contains none, it is a local name with null qualifier, again treated as a regular identifier if it is one, or an implicitly quoted one. If there is one dot, the substrings that precede and follow it are the qualifier and the local name, treated the same way. It is an error if there is more than one dot.

        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 - the qualified identifier, as found in Java source.
        msgr - a Messager for reporting diagnostics at compile time, or null if not in a compilation context.
        Returns:
        the Identifier.Qualified<Simple>
      • operatorFromJava

        public static Lexicals.Identifier.Qualified<Lexicals.Identifier.Operator> operatorFromJava​(String s,
                                                                                                   Messager msgr)
        Create an Identifier.Qualified<Operator> from a name string supplied in Java source, such as an annotation value.

        The string must end in a valid operator name. That is either the entire string (representing a local name and null qualifier), or follows a dot. Whatever precedes the dot becomes the qualifier, treated as a folding regular identifier if it is one, or as a delimited identifier if it has that form, or as an implicitly quoted one.

        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 - the qualified identifier, as found in Java source.
        msgr - a Messager for reporting diagnostics at compile time, or null if not in a compilation context.
        Returns:
        the Identifier.Qualified<Operator>
      • deparse

        public String deparse​(Charset cs)
        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 class Lexicals.Identifier
        Returns:
        The identifier, quoted, unless it is folding.
      • hashCode

        public int hashCode()
        Combines the hash codes of the qualifier and local part.

        Equal to the local part's hash if the qualifier is null, though a Qualified with null qualifier is still not considered "equal" to an Unqualified with the same name.

        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(Object other,
                              Messager msgr)
        Description copied from class: Lexicals.Identifier
        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.
        Specified by:
        equals in class Lexicals.Identifier
        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.
      • local

        public T local()
        Returns the local part, a Simple or an Operator, as the case may be.