Class Lexicals.Identifier.Qualified<T extends Lexicals.Identifier.Unqualified<T>>
- java.lang.Object
-
- org.postgresql.pljava.sqlgen.Lexicals.Identifier
-
- org.postgresql.pljava.sqlgen.Lexicals.Identifier.Qualified<T>
-
- All Implemented Interfaces:
Serializable
- Enclosing class:
- Lexicals.Identifier
public static class Lexicals.Identifier.Qualified<T extends Lexicals.Identifier.Unqualified<T>> extends Lexicals.Identifier
Class representing a schema-qualified identifier. This is distinct from an Identifier.Unqualified even when it has no qualifier (and would therefore deparse the same way).- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.postgresql.pljava.sqlgen.Lexicals.Identifier
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>>
-
-
Method Summary
Modifier and Type Method Description String
deparse(Charset cs)
This Identifier represented as it would be in SQL source.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.int
hashCode()
Combines the hash codes of the qualifier and local part.T
local()
Returns the local part, aSimple
or anOperator
, as the case may be.static Lexicals.Identifier.Qualified<Lexicals.Identifier.Simple>
nameFromCatalog(String qualifier, String local)
Create anIdentifier.Qualified
from name strings found in PostgreSQL system catalogs.static Lexicals.Identifier.Qualified<Lexicals.Identifier.Simple>
nameFromJava(String s)
Create anIdentifier.Qualified<Simple>
from a name string supplied in Java source, such as an annotation value.static Lexicals.Identifier.Qualified<Lexicals.Identifier.Simple>
nameFromJava(String s, Messager msgr)
Create anIdentifier.Qualified<Simple>
from a name string supplied in Java source, such as an annotation value.static Lexicals.Identifier.Qualified<Lexicals.Identifier.Operator>
operatorFromCatalog(String qualifier, String local)
Create anIdentifier.Qualified
representing an operator from name strings found in PostgreSQL system catalogs.static Lexicals.Identifier.Qualified<Lexicals.Identifier.Operator>
operatorFromJava(String s)
Create anIdentifier.Qualified<Operator>
from a name string supplied in Java source, such as an annotation value.static Lexicals.Identifier.Qualified<Lexicals.Identifier.Operator>
operatorFromJava(String s, Messager msgr)
Create anIdentifier.Qualified<Operator>
from a name string supplied in Java source, such as an annotation value.Lexicals.Identifier.Simple
qualifier()
Returns the qualifier, possibly null, as aSimple
.-
Methods inherited from class org.postgresql.pljava.sqlgen.Lexicals.Identifier
equals, toString
-
-
-
-
Method Detail
-
nameFromCatalog
public static Lexicals.Identifier.Qualified<Lexicals.Identifier.Simple> nameFromCatalog(String qualifier, String local)
Create anIdentifier.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 anIdentifier.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)
Create anIdentifier.Qualified<Simple>
from a name string supplied in Java source, such as an annotation value.Equivalent to
nameFromJava(s, null)
.
-
nameFromJava
public static Lexicals.Identifier.Qualified<Lexicals.Identifier.Simple> nameFromJava(String s, Messager msgr)
Create anIdentifier.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)
Create anIdentifier.Qualified<Operator>
from a name string supplied in Java source, such as an annotation value.Equivalent to
operatorFromJava(s, null)
.
-
operatorFromJava
public static Lexicals.Identifier.Qualified<Lexicals.Identifier.Operator> operatorFromJava(String s, Messager msgr)
Create anIdentifier.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 classLexicals.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 anUnqualified
with the same name.
-
equals
public boolean equals(Object other, Messager msgr)
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.
-
qualifier
public Lexicals.Identifier.Simple qualifier()
Returns the qualifier, possibly null, as aSimple
.
-
local
public T local()
Returns the local part, aSimple
or anOperator
, as the case may be.
-
-